bpf_xdp_metadata_rx_hash(9)
π 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
0on success or-errnoon 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:
xdp_reg_page_pool(9)xdp_unreg_page_pool(9)xdp_rxq_info_attach_page_pool(9)xdp_return_frag(9)xdp_build_skb_from_buff(9)xdp_copy_frags_from_zc(9)xdp_build_skb_from_zc(9)bpf_xdp_metadata_rx_timestamp(9)bpf_xdp_metadata_rx_vlan_tag(9)
all of them, no skips, go read them, they're literally so good π§
heads up bestie: those-errnovalues keep their meaning exactly β-EOPNOTSUPPgenuinely means the driver doesn't implement the kfunc, and-ENODATAgenuinely 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
- 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