netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC net-next 0/5] selftests: drv-net: Convert XDP program to bpf_dynptr
@ 2025-09-09  8:52 Nimrod Oren
  2025-09-09  8:52 ` [PATCH RFC net-next 1/5] selftests: drv-net: Test XDP_TX with bpf_dynptr Nimrod Oren
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Nimrod Oren @ 2025-09-09  8:52 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman, Shuah Khan, Alexei Starovoitov, Daniel Borkmann,
	Jesper Dangaard Brouer, John Fastabend, Stanislav Fomichev,
	Mohsin Bashir
  Cc: Dragos Tatulea, Tariq Toukan, Carolina Jubran, netdev,
	linux-kselftest, linux-kernel, bpf, Nimrod Oren

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/20250905173352.3759457-1-ameryhung@gmail.com/

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(-)

-- 
2.45.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-09-09 21:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-09  8:52 [PATCH RFC net-next 0/5] selftests: drv-net: Convert XDP program to bpf_dynptr Nimrod Oren
2025-09-09  8:52 ` [PATCH RFC net-next 1/5] selftests: drv-net: Test XDP_TX with bpf_dynptr Nimrod Oren
2025-09-09  8:52 ` [PATCH RFC net-next 2/5] selftests: drv-net: Test XDP tail adjustment " Nimrod Oren
2025-09-09  8:52 ` [PATCH RFC net-next 3/5] selftests: drv-net: Test XDP head " Nimrod Oren
2025-09-09 17:26   ` Martin KaFai Lau
2025-09-09  8:52 ` [PATCH RFC net-next 4/5] selftests: drv-net: Adjust XDP header data " Nimrod Oren
2025-09-09  8:52 ` [PATCH RFC net-next 5/5] selftests: drv-net: Check " Nimrod Oren
2025-09-09 21:12 ` [PATCH RFC net-next 0/5] selftests: drv-net: Convert XDP program to bpf_dynptr Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).