Re: [PATCH RFC net-next 4/4] veth: use generic skb XDP handling

From
Björn Töpel <bjorn@kernel.org>
Date
2026-05-13 11:31:41
Also in
bpf
Reply to
Maciej Fijalkowski, 2026-05-12
Maciej Fijalkowski [off-list ref] writes:
On Tue, May 12, 2026 at 04:32:43PM +0200, Björn Töpel wrote:
quoted
Maciej Fijalkowski [off-list ref] writes:
quoted
veth currently runs XDP for skb-backed packets by constructing an
xdp_buff and then, for XDP_TX and XDP_REDIRECT, converting that
skb-backed xdp_buff into an xdp_frame. The backing memory is still
skb-owned, so veth has to pin the skb data and frags manually before
consuming the skb.

Use the generic skb XDP helper for skb-backed packets instead. This
keeps skb-backed packets on the skb generic XDP path: XDP_REDIRECT uses
xdp_do_generic_redirect() and XDP_TX uses generic_xdp_tx(). Packets that
already arrive as xdp_frames keep using the existing veth xdp_frame path.

veth still provides its own page_pool and xdp_rxq_info through struct
xdp_generic_ctx. It also keeps using struct veth_xdp_buff storage so
metadata kfuncs that need the skb continue to work after a possible skb
COW.

Hmm, so now if veth with native XDP redirects to a native XDP NIC, we'll
end up in the generic path? We'll loose some bulking capabilities as
well, but maybe that's OK.
Hi Bjorn - thanks a lot for taking a look at these changes!

This touches a path where receiver has XDP prog loaded but sender used
ndo_start_xmit() to produce skbs onto another end of veth pair; these skbs
are then stored within ptr_ring where receiver picks them up. Native XDP
still has bulking, however the skb path has a little bit of back-and-forth
juggle between skb<->xdp_frame conversion. Now I got rid of these
conversions but also of home-grown generic XDP path as well as bulking and
the end result seems to land in the same performance results.

Does it make sense to you?
Hmm! Thanks! ...but doesn't this change the semantics of redirect, for
skb-input/native case?

target of redirect    before (skb-input)                     after (skb-input)

real NIC via devmap   ndo_xdp_xmit(), bulked, XDP TX queue   netdev_start_xmit(), regular qdisc/TX path    
cpumap                xdp_frame on remote CPU's ptr_ring     skb on remote CPU's softnet backlog           
AF_XDP socket         native (potentially ZC)                xsk_generic_rcv (copy, generic)               
veth peer (devmap)    xdp_frame into peer's xdp_ring         skb into peer's xdp_ring (same ring, skb tag) 


(Let me re-read it!)


Björn
Thread (16 messages) 16 messages, 4 authors, last reply 2026-05-28
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help