On 11/12/26 00:46, Tianyi Gao wrote:
>
> On 11/11, Stanislav Fomichev wrote:
[...]
>
>> and slowly creeping more features into xdp making it
>> more and more like skb.
>
> I will leave this to Jesper.
>
Stanislav, you made the key point yourself: an XDP prog that changes
the packet needs a way to correct the HW offload info [3]. After a
decap, the outer csum status no longer holds, and today BPF cannot
flip it to NONE. The prog also cannot change a stripped VLAN tag.
So this is not a new feature. It fixes what Jakub called "a known bug"
[6]: after XDP changes the packet, the HW offload info is stale, and
XDP has no way to tell the kernel which part it changed.
And it is not another metadata area. It is part of the xdp_frame. In
Alexei's sketch, struct xdp_rx_meta sits right after struct xdp_frame,
in the same cache line, and flag bits in xdp->flags say which fields
are valid. It also has the same life as the xdp_frame. The prog writes
only the values it changed. In my proposal [7], the driver fills the
rest after the prog has run, and only for a frame that survives XDP.
So XDP_DROP does not touch it, and XDP_DROP performance stays the same.
data_meta and this area have different owners and different readers:
- data_meta belongs to the BPF progs. They define the format, and
BPF progs (XDP, TC) or AF_XDP read it.
- This area belongs to the kernel. The kernel defines the format, and
the kernel reads it when it builds the skb.
So they do not overlap. The kernel cannot use data_meta, because it
does not know the format.
A driver-local setter would also work, but only while the driver
builds the skb itself, on XDP_PASS. It does not work after
XDP_REDIRECT: the descriptor is recycled, and cpumap or veth builds
the skb on another CPU. And it cannot support the mini-SKB direction
[7], where the driver hands the xdp_frame to core code, and core code
builds the skb. Core code cannot read driver-local state. A
kernel-known area works in all three cases.
On feature creep: yes, the xdp_frame grows towards a mini-SKB. But it
only gets the fields that the skb needs from the HW offloads: hash,
VLAN and csum, and later maybe RX timestamp and RX queue index. These
are core skb fields, and they rarely change. So the list is short, and
it stays short.
--Jesper
[3] https://lore.kernel.org/all/amEo…@devvm7509.cco0.facebook.com/
[6] https://lore.kernel.org/all/2026…@kernel.org/
[7] https://lore.kernel.org/all/b3e6…@kernel.org/