udp_lib_get_port(9)
π 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 socketstructin question π like, the actual socket we're doing all this forsnumβ the port number to look up π the one we're out here searching forhash2_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
- 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