udp4_lib_lookup1(9)
β¨ udp4_lib_lookup1 β¨
okay bestie, so this one's from the Kernel API Manual (yes, the kernel kernel, we're literally in the source code rn π ) and it's about the little lookup that could π«Ά
πΈ NAME πΈ
udp4_lib_lookup1 β a simplified lookup using the primary hash, and the hash key is the destination port. that's the whole vibe. π
π¦ SYNOPSIS π¦
struct sock * udp4_lib_lookup1 (const struct net *net , __be32 saddr ,
__be16 sport , __be32 daddr , unsigned int hnum , int dif , int sdif ,
const struct udp_table *udptable );
like, yes, that's a lot of arguments. it ate and left no crumbs, but also please count your parameters before calling it π
π ARGUMENTS π
netβ the network namespace. your lil world. πsaddrβ source address, in network order (do not reorder it, i'm serious π)sportβ source port, also in network orderdaddrβ destination address, network order again, consistency is iconichnumβ destination port, but in host order this time. yes, this one's different. i don't make the rules πdifβ destination interface indexsdifβ destination bridge port index, if relevant. if it's not relevant, don't come for me βudptableβ the set of UDP hash tables. the whole menu, basically π
π DESCRIPTION π
so here's the tea β β this is a simplified lookup meant to be used as a fallback if no sockets are found, because of a potential race between an (receive) address change and a lookup happening before the rehash operation. like the socket's still moving boxes and you're already knocking on the door π
the way this function does it: it ignores SO_REUSEPORT groups while scoring result sockets. why? because if we already have one, we literally don't need the fallback at all. no cap. π§
β οΈ important bestie: this gets called under rcu_read_lock. don't forget the lock, i'm begging π«Ά
β RETURN β
the socket with the highest matching score if there is one, or NULL if there isn't. that's it, that's the result π₯
π SEE ALSO π
- Kernel file
./net/ipv4/udp.c udp_lib_get_port(9)udp4_hwcsum(9)first_packet_length(9)udp_poll(9)
go read those next, i promise they're worth it π
kisses from ./net/ipv4 mwah π this page was dated October 2026, source and version and everything, so if it's stale that's a future problem, not mine πΈ bye bestie!! π¦π
π
π¦ 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