STRUCT NET_PREFIXES(9)
π struct net_prefixes β Kernel API Manual π
okay so bestie, welcome to this little manual page. it's giving "kernel API vibes" and honestly? we're obsessed. let's get into it. π«Ά
πΈ NAME πΈ
struct net_prefixes β literally just a whole lil collection of network prefixes, no cap. β¨
π SYNOPSIS π
here's what it actually looks like, and yes, you gotta keep it exact, iykyk:
struct net_prefixes {
struct rcu_head rcu;
seqcount_spinlock_t seq;
u8 len;
struct net_prefix nets[];
};
π MEMBERS π
rcuβ the RCU head. it's an RCU head. that's the whole vibe. πseqβ a sequence counter whose entire job is guarding the in-place reordering ofnets. it's the main character of consistency, fr fr. π₯lenβ the number of entries in the array. just a lil count, doing its best. πnetsβ the actual array ofnet_prefixstructures, and bestie, listen: it's sorted by CIDR descending. don't forget that part. β
π DESCRIPTION π
okay so here's the tea on how these nets entries get updated: they're updated in place under set's lock. iconic behavior.
a single entry's cidr/count pair is always updated atomically via READ_ONCE/WRITE_ONCE β so that one slot is safe, no drama there. slay. π¦
but here's the part where you need to pay attention: removing an entry also shifts every following entry down by one slot. like the whole line moves up. so if you're a lockless reader and you're scanning the whole array (i.e. more than a single indexed slot β read that again, it matters), you must use seq to detect and retry across such a shift. no shortcuts. periodt. π
warning bestie: if you're scanning the whole array locklessly and you ignore seq, you're gonna have a bad time. don't do it. π
π§ SEE ALSO π§
if you wanna go deeper (and you should, we love lore), check out these icons:
- Kernel file
./net/netfilter/ipset/ip_set_hash_gen.h struct net_prefix(9)mtype_add_cidr(9)mtype_del_cidr(9)
and that's the whole page! this was struct net_prefixes(9) from the Kernel API Manual, source ./net/netfilter/ipset, dated October 2026. mwah. ππβ¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms