udp_lib_get_port(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… udp_lib_get_port(9) β€” like, the UDP port lookup for IPv4 and IPv6 🫢

okay so bestie, welcome to the Kernel API Manual ✨ this one's a little function from ./net/ipv4 that does the whole "is this UDP port free?" thing β€” except it's iconic and handles both IPv4 and IPv6, no cap πŸ‘‘


🌸 NAME 🌸

udp_lib_get_port β€” UDP port lookup for IPv4 and IPv6 πŸ’–


✨ SYNOPSIS ✨

int udp_lib_get_port (struct sock *sk , unsigned short snum , unsigned
       int hash2_nulladdr );

that's the whole vibe, three args, one int coming back at you πŸŽ€


πŸ¦‹ ARGUMENTS πŸ¦‹

  • sk β€” the socket struct in question πŸ’… like, the actual socket we're doing all this for
  • snum β€” the port number to look up πŸ” the one we're out here searching for
  • hash2_nulladdr β€” an AF-dependent hash value in the secondary hash chains, with the NULL address 🌈 yes she's specific, yes she's AF-dependent, and yes she's carrying the NULL address, we love a well-defined parameter

πŸŽ€ SEE ALSO πŸŽ€

kernel file ./net/ipv4/udp.c β€” and while you're in there, go say hi to:


lowkey a whole little friend group of functions in ./net/ipv4 and honestly? we're obsessed 😭

and that's the page, bestie πŸ’œ this cutie lives in ./net/ipv4, it's dated October 2026, and it's brought to you by the Kernel API Manual β€” stay slaying, go look up those ports responsibly βœ¨πŸ’…πŸ‘‘

πŸ“¦ where this page comes from