Article View: linux.kernel.netdev
Article #25106Re: [PATCH bpf-next 00/15] xdp: add SKB core extensions to keep RX metadata until skb creation
From: Jesper Dangaard Brouer
Date: Tue, 01 Dec 2026 09:09
Date: Tue, 01 Dec 2026 09:09
94 lines
14176 bytes
14176 bytes
On 11/12/26 15:55, Tianyi Gao wrote:
> Hi Alexei,
>
> On Thu, 12 Nov 2026 00:34:54 +0000, Alexei Starovoitov wrote:
>> I'm with Stan on this. It looks heavy.
>>
>> How about the following idea:
>
> Thank you very much for the patch and the idea. I really appreciate it!
>
> v1 uses the skb_ext-like layout mainly because of the earlier pushback
> on a fixed struct [1][2]. This series adds only the three most commonly
> needed types of RX metadata. A 12-byte fixed struct that takes headroom
> only when any RX metadata is stored can be a reasonable middle ground.
>
> I would like to hear from Jesper and Jakub before I move to v2.
>
Short version: the RX metadata must travel with the xdp_frame, in a
format the kernel knows. Fixed struct or skb_ext-like is secondary.
Jakub, this builds on your "driver always populates" idea [1].
I like Alexei's fixed struct, and I have changed my mind. In July I
proposed the skb_ext-like layout [2]. A fixed struct is simpler and
good enough. The fields are HW offloads that map to fixed skb members
(hash, VLAN, csum). The list is short and stable: 12 bytes today, and
below 24 bytes even with RX timestamp and RX queue index. It stays
inside the cache line of the xdp_frame.
Our main use case is XDP_REDIRECT into cpumap and veth. There, core
code builds the skb from the xdp_frame on another CPU: the cpumap
kthread, or veth in threaded NAPI mode, which we run in production.
Today the RX hash and the csum status are lost on the way. GRO on the
remote CPU then puts all flows in one bucket, and veth verifies every
checksum in software.
The values could travel in data_meta, with a second XDP prog at the
target that calls a setter. We do not want that. data_meta is a
contract between BPF progs, in a format the kernel does not know. And
it needs a BPF prog at every place an skb is built, also on veths
where a service owns the XDP prog.
Jakub, I know your objection is the model, not only the layout [3].
How I see it: the RX descriptor is a HW ABI. The NIC defines and
writes it, the kernel only reads it. The xmo callbacks (xmo_rx_hash,
xmo_rx_vlan_tag, ...) read the descriptor and decode it into one
common format, which maps to the skb.
A per-driver setter must store the value in one of two places:
- Back in the descriptor, in HW format. That is device-owned memory,
and some values have no field there (e.g. csum_level).
- In driver memory, in the decoded format. Then every driver keeps
its own copy of the same struct, with the same setter.
A kernel-known area after the xdp_frame is that copy, done once.
The bigger reason is the direction. When the kernel knows the format
(fixed struct or skb_ext-like), the xdp_frame becomes a mini-SKB: it
carries what the skb needs, so core code can build the skb. The end
goal is that NIC drivers stop allocating skbs, and send the xdp_frame
into the netstack instead. ice is already close: it builds the skb
with the generic xdp_build_skb_from_buff(), and then fills the fields
from its descriptor. Later, GRO can check an xdp_frame against the
current GRO packet, and skip the skb for every packet it merges. A
per-driver setter cannot get there. Driver-local state is gone when
the frame leaves the driver, and core code cannot read it.
Jakub, I agree with you that the driver should always populate the
area [1]. The difference is when: after the XDP prog has run.
1. The prog runs first. Nothing is populated, so XDP_DROP stays as
fast as today.
2. The prog stores the values it changed, for example the csum status
after a decap [4], or a new or cleared VLAN tag.
3. On XDP_PASS and XDP_REDIRECT, the driver fills the other fields
from its descriptor.
This also fixes XDP_PASS. Today the kernel does not know what XDP
changed, so the driver applies HW info that may no longer match the
packet, and XDP cannot change a stripped VLAN tag at all. We run with
VLAN offload disabled for this reason. A return code like
XDP_PASS_MODIFIED would only say "something changed". With a store,
the BPF-prog corrects exactly the fields it changed. This is the
explicit update/invalidate plan Jakub asked for [5].
--Jesper
[1] https://lore.kernel.org/all/20250805172831.213ddd8d@kernel.org/
[2]
https://lore.kernel.org/all/1d5521eb-84fc-4417-a3f5-6366694d160a@kernel.org/
[3] https://lore.kernel.org/all/20261117161856.6f6c2ce9@kernel.org/
[4] https://lore.kernel.org/all/20260227153231.78d16b69@kernel.org/
[5] https://lore.kernel.org/all/20260722113525.34092660@kernel.org/
Technical Details
Message-ID:
<b3e67ffc-5610-4598-9291-ee0264983a4a@kernel.org>Path:
mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374877-linux-kernel-netdev=dewy.ruReferences:
<cover.1794281983.git.tianyi@cloudflare.com> <DMST78XBB2RK.2BKP3O07GEWZQ@gmail.com> <CAG4wq-cXJtTzG2GO9KTL04b=prS+X67fRBJ=nriOO0G-24Rjzw@mail.gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374877-linux-kernel-netdev=dewy.ru From: hawk@kernel.org (Jesper Dangaard Brouer) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH bpf-next 00/15] xdp: add SKB core extensions to keep RX metadata until skb creation Date: Tue, 1 Dec 2026 10:09:04 +0100 Organization: Usenet Network Message-ID: <b3e67ffc-5610-4598-9291-ee0264983a4a@kernel.org> References: <cover.1794281983.git.tianyi@cloudflare.com> <DMST78XBB2RK.2BKP3O07GEWZQ@gmail.com> <CAG4wq-cXJtTzG2GO9KTL04b=prS+X67fRBJ=nriOO0G-24Rjzw@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: usenet.network; logging-data="1669083"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:bEr3alWgDcmf+1NUG1ShmBXCahY= sha256:ld7+4Nm7REPkOcWEgoAlUKRIfhUB0KDQSAd6Vchxi6Y= sha1:bVQDsZSgyVV2/YFMPuGmFbeTigk= sha256:1KH34XSUlt1Gff0mKNIzNGtdoktcdvBV69AC8lr66VY= Content-Language: en-US List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 69D681172E9; Tue, 1 Dec 2026 12:09:37 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id oFxQiePNx36t; Tue, 1 Dec 2026 12:09:33 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-374877-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id A5055117297; Tue, 1 Dec 2026 12:09:23 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 24BA526F59; Tue, 1 Dec 2026 09:09:21 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796116158; b=rS9mivDKmFf8PgtinLkduKFuu6KqDvHM/I0Boe51wvbRy/hriQAqhORIZikliHySEKqs ER89DIp0IHwV9AWofk7NOd5P4glN4VXT5qhYCUXxguBPFZQs0XpvknUWurIt4tz4ICaWN seBQnAjeGir/20La5Z+u5SFyX3VdZdKja0dOZCHUHtybs6hRypxeVkIJUrlJxqxMefQ10 hjXQnvstNSvuI5v31E76+uPMH5V0l4dSohv4XUE0mWJsmVUJVAw3HpPmbIs4wG5E/dsKP MlZtl7CAmLY6vXO5wf8OBV2+j0I4D51llHFmJPYLzsHUUFxfFfTjqGssuflch2rlLJg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796116158; h=X-Original-To:Received:Received:DKIM-Signature:Message-ID:Date: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:User-Agent: Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding; bh=fitoFKtcKOHFd4+ISQk35YyZpEp430ytCE+/Cena90w=; b=PknFTZhy2ux2GjDVGhGBsmPkyWsHnACN9GJJbVHMYevwziLXTwa2OpH6GA3kgLrBewcM QbTVaYQLHfSOGUuhtMMG6BjCcK8bRr5i0NDUgqDGmnscayR4ClzOIopVgGWysjMwzWtZh pnIjbZnpxnj2M7feiUQrxOqRkf5p0aJsa0WmEAg5Tgmla7A+Nm5vL1v1tklVjCI3Yfe7k VudYpdrMUQyhtUbEp6tJ82eOcSHKEjhbBFgMUIWRB0qztodxUi4yOzSmCMd+WOSFhTALg gWF1Cmz7s10pQknSxexodMM8Fsr4vRq1qfK8iU0L6x4EdK+/HIkXJf5vGv9fM/1tkmw== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=O8RLUlSX; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 51279606A336; Tue, 1 Dec 2026 09:09:18 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=O8RLUlSX X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796116157; b=LRLYJRTEYeW/e0a9ek/TEU/3XVFCzncKWv646tYqxSYb3cSYLy7G7P8oL0UvJzSkiBt4 Ws5Yje+iSGsbiJI6zz2L8718OjVlJFPRYx2zCyOOatQ8vFb1mz5v99x8LGycoj1NDH7/m fJe35Lys9l5qGJo6RVURkRbmJaNzJ0hmKmRH56J5X4ZKVA7DEkCfATIAQkoNyYbCpmcJi VtlaOst1ylPUyOIY5da80Knv/5SsXKtgsF0H0JGJ0NIqdEPhwEntieEzS0TTkuI/+g1O3 7JT5q6+CCzRIkv+L8t9E9aiAAkdOF+oa71IiX0XTRo3a4KdE/R3Z19Kaqac7h6mYh2g== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796116157; h=Received:DKIM-Signature:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding; bh=fitoFKtcKOHFd4+ISQk35YyZpEp430ytCE+/Cena90w=; b=GrJ3c6WzrPsJHl+KFMDnt4jp9zSLClkqUCghHg2UDXGixbqonMk/82gc0OK+ANFNULe1 mNQGGOO1uHkUhaUEkBanuAEndMxzhp4kj2VZfkIHTdxhOs2n9bma+NwEn+QzKAgqgikYz WYeaZ7eVAHG1PO23upAyegxGgC71UYo4pBmgk+w3FVGgn3JDnOb2fmEWkrgL3ZX8cjHLh aXHaHO166iFKvUjk9x8aWUPHRltRWdP9ApbnQCC9JOyFKKbu9nJ60pshB74k3RydY41pz kFwXaxpOsR0D5dcZOT+pGwbsuEafCRr5AEJ0JgWfi+rTEfWBdhavjORxVPMB6sPCvWg== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=O8RLUlSX; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6C325606A31A; Tue, 1 Dec 2026 09:09:17 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB4ED1F0089B; Tue, 1 Dec 2026 09:09:06 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796116157; bh=fitoFKtcKOHFd4+ISQk35YyZpEp430ytCE+/Cena90w=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=O8RLUlSXH+f3UZXbFrxNLwGoELDkQJJZqCtzEIwDIOwG386h6Fk1Vxeje7CkpTRU7 Wq/pix7ngppNcOgsVzWWQ7ydAdmPnOGNe83m+p15CrsMnSsnZ0Azzow4OA16MCnaNN zH4pHzW12GqvVH57gjkUkVGDb5bCzebiEV8scrQsmvQZrRx84+/05TE532w2NLBP/p z4ibp1ueo4UzJ16YHVRqVNQWa+eZHuvlfygC9tikZHB6d3XNP5rE4qA+R1NrlLRCxv J3dog99D+F+0AN/ZByncTbEVcibGbPzscu55sntA73hfLtK6t6zoqzlSttfFhWn2ox +DvsXK+tM+Eog== X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-User-Agent: Mozilla Thunderbird X-Cc: bpf@vger.kernel.org, netdev@vger.kernel.org, Daniel Borkmann <daniel@iogearbox.net>, Andrii Nakryiko <andrii@kernel.org>, Martin KaFai Lau <martin.lau@linux.dev>, Jakub Kicinski <kuba@kernel.org>, John Fastabend <john.fastabend@gmail.com>, Stanislav Fomichev <sdf@fomichev.me>, Lorenzo Bianconi <lorenzo@kernel.org>, Vladimir Vdovin <deliran@verdict.gg>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>, Andrew Lunn <andrew+netdev@lunn.ch>, Donald Hunter <donald.hunter@gmail.com>, Eduard Zingerman <eddyz87@gmail.com>, Kumar Kartikeya Dwivedi <memxor@gmail.com>, Song Liu <song@kernel.org>, Yonghong Song <yonghong.song@linux.dev>, Jiri Olsa <jolsa@kernel.org>, Emil Tsalapatis <emil@etsalapatis.com>, Ihor Solodrai <ihor.solodrai@linux.dev>, Tony Nguyen <anthony.l.nguyen@intel.com>, Przemek Kitszel <przemyslaw.kitszel@intel.com>, Maciej Fijalkowski <maciej.fijalkowski@intel.com>, Alexander Lobakin <aleksander.lobakin@intel.com>, Magnus Karlsson <magnus.karlsson@intel.com>, Tushar Vyavahare <tushar.vyavahare@intel.com>, Jason Xing <kerneljasonxing@gmail.com>, Nikolay Aleksandrov <razor@blackwall.org>, Madalin Bucur <madalin.bucur@nxp.com>, Ioana Ciornei <ioana.ciornei@nxp.com>, Jonathan Corbet <corbet@lwn.net>, Shuah Khan <skhan@linuxfoundation.org>, Shuah Khan <shuah@kernel.org>, Randy Dunlap <rdunlap@infradead.org>, Nathan Chancellor <nathan@kernel.org>, Nick Desaulniers <ndesaulniers@google.com>, Bill Wendling <morbo@google.com>, Justin Stitt <justinstitt@google.com>, Chris J Arges <carges@cloudflare.com>, Jakub Sitnicki <jakub@cloudflare.com>, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, intel-wired-lan@lists.osuosl.org, llvm@lists.linux.dev, kernel-team@cloudflare.com X-In-Reply-To: <CAG4wq-cXJtTzG2GO9KTL04b=prS+X67fRBJ=nriOO0G-24Rjzw@mail.gmail.com>