STRUCT NET_PREFIXES(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– 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 of nets. 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 of net_prefix structures, 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:


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