bpf_xdp_metadata_rx_hash(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– bpf_xdp_metadata_rx_hash β€” the kernel API manual, bestie edition πŸ’–

okay so real talk, this is bpf_xdp_metadata_rx_hash(9) from the Kernel API Manual, and it's literally the page where your NIC tells you what it thinks the RX hash is. tiny function, big lore. let's get into it ✨


🌸 NAME 🌸

bpf_xdp_metadata_rx_hash β€” Read XDP frame RX hash. that's it. that's the whole job. she reads the hash off an XDP frame and she does it flawlessly πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

__bpf_kfunc int bpf_xdp_metadata_rx_hash (const struct xdp_md *ctx , u32
*hash , enum xdp_rss_hash_type *rss_type );

yes the __bpf_kfunc is part of the signature, don't come for me, copy it exactly like that 🫢


πŸ¦‹ ARGUMENTS πŸ¦‹

  • ctx β€” the XDP context pointer. like, the whole frame's main character. everything you need to know about the packet lives in here πŸ‘‘
  • hash β€” a return value pointer. this is where the actual hash number lands, so pls make sure it points somewhere real πŸ™ˆ
  • rss_type β€” another return value pointer, but this one's for the RSS type. the ~flavor~ of the hash if you will πŸ“

✨ DESCRIPTION ✨

so the RSS hash type (rss_type) specifies what portion of the packet headers the NIC hardware actually used when it calculated that RSS hash value. like, which bits of the packet got invited to the hash party πŸ’…

and the RSS type itself can be decoded via enum xdp_rss_hash_type, and there's two whole ways to do it:

  • matching on the individual L3/L4 bits β€” those are the XDP_RSS_L* ones 🌈
  • or going with the combined traditional RSS Hashing Types β€” the XDP_RSS_TYPE_L* crew ⭐

both valid, both iconic, pick your fighter. iykyk πŸ’œ


πŸ”₯ RETURN πŸ”₯

  • Returns 0 on success or -errno on error. classic. no notes πŸŽ€
  • -EOPNOTSUPP β€” means the device driver doesn't implement kfunc. so it's not you, it's the driver, and the driver is lowkey not slaying today 😭
  • -ENODATA β€” means there's no RX-hash available for this frame. like, the hash ghosted you. it happens πŸ’€

🌟 SEE ALSO 🌟

the kernel file ./net/core/xdp.c, plus the whole friend group:

all of them, no skips, go read them, they're literally so good 🧚


heads up bestie: those -errno values keep their meaning exactly β€” -EOPNOTSUPP genuinely means the driver doesn't implement the kfunc, and -ENODATA genuinely means there's no RX-hash for this frame. don't go reinterpreting them, the kernel will know πŸ™ˆ

and that's the whole page! came from ./net/core, dated October 2026, and honestly? iconic behavior from the kernel docs. stay hydrated, read your enums, and may your hashes always be available πŸ’–βœ¨πŸ¦‹πŸ’…

πŸ“¦ where this page comes from