Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by netdev-bot+sashiko
Mon, 23 Nov 2026 03:59
Re: [PATCH net-next v2 05/11] selftests: net: add tx_extra_headroom test
Author: netdev-bot+sashiko
Date: Mon, 23 Nov 2026 03:59
Date: Mon, 23 Nov 2026 03:59
123 lines
13729 bytes
13729 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] Two test cases assert tx_extra_headroom == XDP_PACKET_HEADROOM
under native veth XDP, and neither checks whether the copy is actually…
--
selftests: net: add tx_extra_headroom test
This adds a Python selftest and a TC BPF program. They check that generic
XDP on a veth or netkit peer stops copying locally generated skbs once the
kernel sets tx_extra_headroom on the other end. The test also checks the
tx_extra_headroom value on attach and detach for native and generic XDP,
for XDP propagated through a bond, and for a bridge with a vxlan port.
> diff --git a/tools/testing/selftests/net/tx_extra_headroom.py b/tools/testing/selftests/net/tx_extra_headroom.py
> new file mode 100755
> index 0000000000000..4058d0e64fc5a
> --- /dev/null
> +++ b/tools/testing/selftests/net/tx_extra_headroom.py
[ ... ]
> +@ksft_variants([
> + KsftNamedVariant("generic", "xdpgeneric"),
> + KsftNamedVariant("native", "xdpdrv"),
> +])
> +def test_detach(mode) -> None:
> + """Check that XDP on the veth peer sets tx_extra_headroom until detach."""
> + with NetNS() as send_ns, NetNS() as peer_ns, NetNSEnter(str(send_ns)):
> + _setup_veth(peer_ns)
> + map_id = _load_progs()
> + _attach_tcx("veth0", "egress", "record")
> + _attach_xdp(peer_ns, mode)
> + _send_udp4()
> + ksft_eq(_read_bss(map_id)["tx_extra_headroom"], XDP_PACKET_HEADROOM)
[Severity: Medium]
In the native variant, do the 256 reserved bytes actually prevent a copy?
With native XDP on veth1, the skb goes through veth_xmit() ->
veth_xdp_rcv_skb() -> veth_convert_skb_to_xdp_buff(). That function copies
whenever skb_head_is_locked() is true, whatever the headroom:
drivers/net/veth.c:veth_convert_skb_to_xdp_buff() {
...
if (skb_shared(skb) || skb_head_is_locked(skb) ||
skb_is_nonlinear(skb) ||
skb_headroom(skb) < XDP_PACKET_HEADROOM) {
if (skb_pp_cow_data(rq->page_pool, pskb, XDP_PACKET_HEADROOM))
goto drop;
...
}
include/linux/skbuff.h:
static inline bool skb_head_is_locked(const struct sk_buff *skb)
{
return !skb->head_frag || skb_cloned(skb);
}
The UDP, raw, AF_PACKET and AF_XDP copy-mode senders all allocate through
__alloc_skb()/kmalloc_reserve(), and those paths leave head_frag at 0.
With xdpdrv on the peer, does each of these skbs then get the extra 256
bytes of headroom, a larger truesize and a bigger sk_wmem charge, and still
get copied by skb_pp_cow_data()?
Generic XDP is different. netif_receive_generic_xdp() checks only for
cloned, nonlinear and headroom, so test_peer_xdp checks a real benefit.
test_bond() has the same problem. There, native XDP on bond0 is propagated
to veth1 through netif_xdp_propagate(), and the test also asserts
tx_extra_headroom == XDP_PACKET_HEADROOM.
The prerequisite patch "net: set tx_extra_headroom of the peer on XDP
attach" says it removes the copy for native XDP on veth in
veth_convert_skb_to_xdp_buff(). However, __netdev_update_tx_extra_headroom()
sets the reservation whenever dev_xdp_prog_count(peer) is non-zero, and that
includes XDP_MODE_DRV:
net/core/dev.c:__netdev_update_tx_extra_headroom() {
...
if (peer && dev_xdp_prog_count(peer) &&
needed_headroom < XDP_PACKET_HEADROOM)
tx_extra_headroom = XDP_PACKET_HEADROOM - needed_headroom;
...
}
Should the native and bond cases expect the reservation at all? A
native-mode variant of test_peer_xdp would likely see pp_recycle == True,
which would expose this.
No later patch in the series changes veth_convert_skb_to_xdp_buff() or
limits the reservation to generic mode.
> + ip(f"link set dev veth1 {mode} off", ns=peer_ns)
> + _send_udp4()
> + ksft_eq(_read_bss(map_id)["tx_extra_headroom"], 0)
> +
> +
> +def test_bond() -> None:
> + """Check that XDP that a bond propagates to the veth peer counts."""
[ ... ]
> + _attach_xdp(peer_ns, "xdpdrv", "bond0")
> + _send_udp4()
> + ksft_eq(_read_bss(map_id)["tx_extra_headroom"], XDP_PACKET_HEADROOM)
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261119013830.36935-1-tianyi%40cloudflare.com
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads