Skip to content

xdp: Propagate RX HW hints for XDP_REDIRECTed packets via xdp_frame #9039

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

kernel-patches-daemon-bpf[bot]
Copy link

Pull request for series with
subject: xdp: Propagate RX HW hints for XDP_REDIRECTed packets via xdp_frame
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=968365

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: cd2e103
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=968365
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 7fdaba9
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=968365
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 919319b
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=968365
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 97744b4
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=968365
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: a570f38
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=968365
version: 1

LorenzoBianconi and others added 4 commits June 5, 2025 13:57
Introduce the `xdp_rx_meta` structure to serve as a container for XDP RX
hardware hints within XDP packet buffers. Initially, this structure will
accommodate `rx_hash` and `rx_vlan` metadata. (The `rx_timestamp` hint will
get stored in `skb_shared_info`).

A key design aspect is making this metadata accessible both during BPF
program execution (via `struct xdp_buff`) and later if an `struct
xdp_frame` is materialized (e.g., for XDP_REDIRECT).
To achieve this:
  - The `struct xdp_frame` embeds an `xdp_rx_meta` field directly for
    storage.
  - The `struct xdp_buff` includes an `xdp_rx_meta` pointer. This pointer
    is initialized (in `xdp_prepare_buff`) to point to the memory location
    within the packet buffer's headroom where the `xdp_frame`'s embedded
    `rx_meta` field would reside.

This setup allows BPF kfuncs, operating on `xdp_buff`, to populate the
metadata in the precise location where it will be found if an `xdp_frame`
is subsequently created.

The availability of this metadata storage area within the buffer is
indicated by the `XDP_FLAGS_META_AREA` flag in `xdp_buff->flags` (and
propagated to `xdp_frame->flags`). This flag is only set if sufficient
headroom (at least `XDP_MIN_HEADROOM`, currently 192 bytes) is present.
Specific hints like `XDP_FLAGS_META_RX_HASH` and `XDP_FLAGS_META_RX_VLAN`
will then denote which types of metadata have been populated into the
`xdp_rx_meta` structure.

This patch is a step for enabling the preservation and use of XDP RX
hints across operations like XDP_REDIRECT.

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Jesper Dangaard Brouer <[email protected]>
Patchset increased xdp_buff with a pointer 8 bytes, and the bpf/test_run
struct xdp_page_head have two xdp_buff's.  Thus adjust test with 16 bytes.

Signed-off-by: Jesper Dangaard Brouer <[email protected]>
Introduce the following kfuncs to store hw metadata provided by the NIC
into the xdp_buff struct:

- rx-hash: bpf_xdp_store_rx_hash
- rx-vlan: bpf_xdp_store_rx_vlan
- rx-hw-ts: bpf_xdp_store_rx_ts

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Jesper Dangaard Brouer <[email protected]>
Update the following hw metadata provided by the NIC building the skb
from a xdp_frame.
- rx hash
- rx vlan
- rx hw-ts

Signed-off-by: Lorenzo Bianconi <[email protected]>
@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 64a064c
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=968365
version: 1

LorenzoBianconi and others added 3 commits June 5, 2025 13:57
Report xdp_rx_meta info if available in xdp_buff struct in
xdp_metadata_ops callbacks for veth driver

Signed-off-by: Lorenzo Bianconi <[email protected]>
Introduce bpf selftests for the XDP rx_meta store kfuncs.

Signed-off-by: Lorenzo Bianconi <[email protected]>
Update the documentation[1] based on the changes in this patchset.

[1] https://docs.kernel.org/networking/xdp-rx-metadata.html

Signed-off-by: Jesper Dangaard Brouer <[email protected]>
@kernel-patches-daemon-bpf kernel-patches-daemon-bpf bot force-pushed the series/968365=>bpf-next branch from d000d1e to 6dfbf20 Compare June 5, 2025 20:57
@kernel-patches-daemon-bpf
Copy link
Author

At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=968365 expired. Closing PR.

@kernel-patches-daemon-bpf kernel-patches-daemon-bpf bot deleted the series/968365=>bpf-next branch June 9, 2025 05:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants