udp4_lib_lookup1(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ 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 order
  • daddr β€” destination address, network order again, consistency is iconic
  • hnum β€” destination port, but in host order this time. yes, this one's different. i don't make the rules πŸ’€
  • dif β€” destination interface index
  • sdif β€” 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 πŸ‘‘

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