mtype_add_cidr(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… mtype_add_cidr β€” like, the whole manual page, bestie ✨

okay so you're looking at mtype_add_cidr(9) β€” yes, section 9, that's the Kernel API Manual, we're doing kernel-level stuff today and honestly? iconic of you. πŸŽ€ This little function is the one that slips a CIDR entry into the hash table's bookkeeping, and I'm gonna walk you through every single bit of it, no cap. πŸ¦‹


🌸 NAME 🌸

mtype_add_cidr β€” adds a CIDR entry to the hash table bookkeeping, literally that's the whole job πŸ’–


✨ SYNOPSIS ✨

int mtype_add_cidr (struct ip_set *set , struct htype *h , u8 cidr , u8
n );

that's it. that's the signature. copy it exactly, don't be cute with it πŸ™ˆ


🫢 ARGUMENTS 🫢

  • set β€” pointer to the ip_set. like, the set. the actual one. keep your eyes on it πŸ‘€
  • h β€” pointer to the htype. the type-hash buddy that comes along for the ride.
  • cidr β€” the CIDR prefix length 🧚 that's the number that goes in.
  • n β€” the index of the net_prefix array to add cidr to. yes, which array slot. very specific. we love that for us ⭐

πŸ”₯ DESCRIPTION πŸ”₯

so here's the vibe check on how this actually goes down:

  • if cidr is found, it performs an update πŸ’« (no drama, just refresh)
  • otherwise? it does COW-style allocation and replacement via RCU. copy-on-write, bestie. allocate the new thing, swap it in under RCU, and everyone else keeps reading the old one peacefully. it's giving main character energy but for concurrency 🌈
⚠️ that COW + RCU part is the whole personality of this function β€” nothing gets mutating in place, so don't go assuming the old memory just vanishes on you πŸ’€

πŸ‘‘ RETURN πŸ‘‘

  • 0 β€” success, slay, we ate πŸŽ‰
  • negative error code β€” failure 😭 (negative, so like, not zero, okay? check it. always check it.)

πŸŽ€ SEE ALSO πŸŽ€

  • the kernel file ./net/netfilter/ipset/ip_set_hash_gen.h β€” that's where it lives, go read it πŸ’œ
  • struct net_prefix(9)
  • struct net_prefixes(9)
  • mtype_del_cidr(9) β€” the one that takes it back out, the breakup arc πŸ¦‹

and that's the whole page, bestie πŸ“ this masterpiece is brought to you by the source at ./net/netfilter/ipset, dated October 2026 β€” periodt, go forth and add those CIDRs πŸ’…βœ¨πŸ”₯

πŸ“¦ where this page comes from