mtype_add_cidr(9)
π 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 theip_set. like, the set. the actual one. keep your eyes on it πhβ pointer to thehtype. 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 thenet_prefixarray to addcidrto. 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
cidris 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
- 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