register_pernet_subsys(9)
π register_pernet_subsys(9) β a Kernel API Manual moment β¨
okay so picture this: you're deep in the kernel, you've got a network namespace situation, and you need your subsystem to actually show up when namespaces get born and yeeted. that's literally this page, bestie. it's from the Kernel API Manual and it's giving "small function, huge responsibility" energy fr fr π
β¨ NAME β¨
register_pernet_subsys β register a network namespace subsystem π¦
β¨ SYNOPSIS β¨
int register_pernet_subsys (struct pernet_operations *ops );
β¨ ARGUMENTS β¨
opsβ the pernet operations structure for your subsystem π this is the whole personality of your registration, so treat it right.
πΈ DESCRIPTION πΈ
so what you're doing here is registering a subsystem that has init and exit functions, and those functions get called when network namespaces are created and destroyed respectively. like, that's the entire vibe. π
when you register, it's not just "ok cool, future namespaces will know about you" β nope! all the network namespace init functions get called for every existing network namespace. the way this slaps is that it lets kernel modules have a race free view of the set of network namespaces. no cap, that's the whole point. π₯
when a new network namespace is created, all of the init methods get called in the order in which they were registered. first come, first served, iconic behavior honestly. π
and when a network namespace is destroyed? all of the exit methods get called in the reverse of the order with which they were registered. yes bestie, it unwinds backwards. last in, first out, symmetry, we love to see it. π
π«Ά quick recap so you don't have to scroll: init = registration order, exit = reverse registration order, and registration fires init for every namespace that already exists. iykyk.
π¦ SEE ALSO π¦
- Kernel file
./net/core/net_namespace.cβ go read the source, it's giving main character energy π net_ns_get_ownership(9)net_ns_barrier(9)get_net_ns(9)unregister_pernet_subsys(9)β the breakup counterpart to this function, you'll need it πregister_pernet_device(9)unregister_pernet_device(9)
aaaand that's the page!! π it lives over in ./net/core, dated October 2026, and yes the title at the very top and the footer at the very bottom of the original are both right here in spirit β register_pernet_subsys(9), Kernel API Manual, ./net/core, October 2026. slay, go register your subsystem, 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