bpf_xdp_meta..._rx_vlan_tag(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… bpf_xdp_meta..._rx_vlan_tag(9) β€” like, the Kernel API Manual entry, bestie

okay so this is a page from the Kernel API Manual, and it's all about bpf_xdp_metadata_rx_vlan_tag β€” yes the title is long, no we're not shortening it, it's iconic that way πŸŽ€


✨ NAME ✨

bpf_xdp_metadata_rx_vlan_tag β€” grab the outermost VLAN tag off an XDP packet, no cap πŸ¦‹


🌸 SYNOPSIS 🌸

__bpf_kfunc int bpf_xdp_metadata_rx_vlan_tag (const struct xdp_md *ctx ,
__be16 *vlan_proto , u16 *vlan_tci );

πŸŽ€ ARGUMENTS πŸŽ€

  • ctx β€” the XDP context pointer. your main character pointer, honestly.
  • vlan_proto β€” destination pointer for the VLAN Tag protocol identifier (TPID).
  • vlan_tci β€” destination pointer for the VLAN TCI (VID + DEI + PCP). three besties in one field fr fr.

πŸ’– DESCRIPTION πŸ’–

In case of success, vlan_proto contains the Tag protocol identifier (TPID) β€” usually ETH_P_8021Q or ETH_P_8021AD, but some networks can use custom TPIDs, so don't assume πŸ‘€. vlan_proto is stored in network byte order (BE) and should be used like this:

if (vlan_proto == bpf_htons(ETH_P_8021Q)) do_something;

vlan_tci contains the remaining 16 bits of a VLAN tag. The driver is expected to provide those in host byte order (usually LE), so the bpf program should not perform byte conversion β€” literally don't, it's already been done for you πŸ’….

Per the 802.1Q standard, VLAN TCI (Tag control information) is a bit field containing:

  • VLAN identifier (VID) β€” readable with vlan_tci & 0xfff
  • Drop eligible indicator (DEI) β€” 1 bit
  • Priority code point (PCP) β€” 3 bits

For the detailed meaning of DEI and PCP, please refer to other sources β€” that's not this page's job, and honestly, respect the boundaries 🧚


πŸ”₯ RETURN πŸ”₯

  • Returns 0 on success or -errno on error.
  • -EOPNOTSUPP β€” the device driver doesn't implement kfunc. it's giving "not my department" 😭
  • -ENODATA β€” the VLAN tag was not stripped or is not available. the vibe check came back empty πŸ’€

πŸ‘‘ SEE ALSO πŸ‘‘

Kernel file ./net/core/xdp.c, plus these absolute legends:


⭐ friendly reminder from your girl: byte order is not a suggestion, it's a whole lifestyle. check BE vs host order before you ship, bestie 🫢

and that's the page!! 🌈 it lives in ./net/core, it's dated October 2026, and yeah the footer name is still the same gloriously long bpf_xdp_meta..._rx_vlan_tag(9) β€” we love a consistent brand πŸ’œβœ¨πŸ“

πŸ“¦ where this page comes from