rtnl_get_net_ns_capable(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… rtnl_get_net_ns_capable(9) πŸ’…

okay bestie, so this is a page from the Kernel API Manual (yes, the actual kernel, not your group chat) and it's about rtnl_get_net_ns_capable β€” a lil function with a big job. it's short, it's sweet, and it literally gatekeeps network namespaces. let's get into it πŸŽ€


✨ NAME ✨

rtnl_get_net_ns_capable β€” get netns if sufficiently privileged.

like, it hands you the netns only if you're that girl (privileged enough). no permission? no namespace. periodt πŸ‘‘


🌸 SYNOPSIS 🌸

struct net * rtnl_get_net_ns_capable (struct sock *sk , int netnsid );

yep, that's the whole signature. two args in, a struct net * out. slay ✨


πŸ¦‹ ARGUMENTS πŸ¦‹

  • sk β€” the netlink socket. this is your main character socket, the one going "hey, can i have that namespace please" πŸ₯Ί
  • netnsid β€” the network namespace identifier. it's literally the ID number of the netns you're asking about, iykyk πŸ”’

πŸ’œ DESCRIPTION πŸ’œ

so what does it actually do? it returns the network namespace identified by netnsid on success πŸŽ‰ β€” that's it, that's the win.

and on failure? it returns an error pointer 😭 not NULL, not a vibey empty struct, an error pointer. so pls, check it properly before you go dereferencing, bestie. no cap, do the IS_ERR() check or it's giving undefined chaos πŸ’€

that's genuinely the whole description. short and iconic. the function ate and left no crumbs 🫢


🌈 SEE ALSO 🌈

what else is in the ./net/core/rtnetlink.c circle? the whole friend group fr fr:

go read those too, they're all living in the Kernel file ./net/core/rtnetlink.c πŸ§šβ€β™€οΈ


πŸ’– cute lil sign-off: this page is brought to you by the ./net/core girlies, dated October 2026, straight out of the Kernel API Manual. mwah, go write some royal netlink code πŸ‘‘πŸ’…
πŸ“¦ where this page comes from