Skip to content

RFC selftests: drv-net: Convert XDP program to bpf_dynptr

Nimrod Oren bpf linux-kselftest lkml netdev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest5 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5selftests: drv-net: Test XDP_TX with bpf_dynptrtools/testing/selftests/net/lib/xdp_native.bpf.c+23 -260 replies
2/5selftests: drv-net: Test XDP tail adjustment with bpf_dynptrtools/testing/selftests/net/lib/xdp_native.bpf.c+11 -90 replies
3/5selftests: drv-net: Test XDP head adjustment with bpf_dynptrtools/testing/selftests/net/lib/xdp_native.bpf.c+12 -231 reply
4/5selftests: drv-net: Adjust XDP header data with bpf_dynptrtools/testing/selftests/net/lib/xdp_native.bpf.c+19 -160 replies
5/5selftests: drv-net: Check XDP header data with bpf_dynptrtools/testing/selftests/net/lib/xdp_native.bpf.c+31 -490 replies

Reviews trailers per patch

All 5 patches have a Reviewed-by or Acked-by.

PatchCarolina JubranDragos Tatulea
1/5R-b R-b
2/5R-b R-b
3/5R-b R-b
4/5R-b R-b
5/5R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH RFC net-next 0/5] selftests: drv-net: Convert XDP program to bpf_dynptr

Hi all,

This series updates the drv-net XDP program used by the new xdp.py selftest to use the bpf_dynptr APIs for packet access.

The selftest itself is unchanged.

The original program accessed packet headers directly via ctx->data/data_end, implicitly assuming headers are always in the linear region. That assumption is incorrect for multi-buffer XDP and does not hold across all drivers. For example, mlx5 with striding RQ can leave the linear area empty, causing the multi-buffer cases to fail.

Switching to bpf_xdp_load/store_bytes would work but always incurs copies. Instead, this series adopts bpf_dynptr, which provides safe, verifier-checked access across both linear and fragmented areas while avoiding copies.

Amery Hung has also proposed a series [1] that addresses the same issues in the program, but through the use of bpf_xdp_pull_data. My series is not intended as a replacement for that work, but rather as an exploration of another viable solution, each of which may be preferable under different circumstances.

In cases where the program does not return XDP_PASS, I believe dynptr has an advantage since it avoids an extra copy. Conversely, when the program returns XDP_PASS, bpf_xdp_pull_data may be preferable, as the copy will be performed in any case during skb creation.

It may make sense to split the work into two separate programs, allowing us to test both solutions independently. Alternatively, we can consider a combined approach, where the more fitting solution is applied for each use case. I welcome feedback on which direction would be most useful.

[1] https://lore.kernel.org/all/[email protected]/

Thanks!
Nimrod

Nimrod Oren (5):
selftests: drv-net: Test XDP_TX with bpf_dynptr
selftests: drv-net: Test XDP tail adjustment with bpf_dynptr
selftests: drv-net: Test XDP head adjustment with bpf_dynptr
selftests: drv-net: Adjust XDP header data with bpf_dynptr
selftests: drv-net: Check XDP header data with bpf_dynptr

 .../selftests/net/lib/xdp_native.bpf.c        | 219 ++++++++----------
 1 file changed, 96 insertions(+), 123 deletions(-)
Signature · 1 line
2.45.0