Re: [PATCH net-next v2 03/14] bpf: Make BPF skb extension survive packet scrubbing
From: "Daniel Zahka" <daniel.zahka@gmail.com>
Date: 2026-09-23 17:46:31
Also in:
bpf
On Thu Sep 10, 2026 at 10:02 AM EDT, Jakub Sitnicki wrote:
skb_scrub_packet() drops all skb extensions unconditionally via skb_ext_reset(). It runs on tunnel encap/decap (ip_tunnel_rcv, vxlan_rcv, etc.) and cross-netns forwarding (dev_forward_skb). This makes it impossible for a BPF program to pass metadata via bpf_skb_ext through a tunnel or across a netns boundary. The extension is always lost at the scrub point. Introduce skb_ext_scrub(), a selective variant of skb_ext_reset(). It deletes every extension except SKB_EXT_BPF. Scrubbing is safe when the extension slab is shared with clones: deleting an extension only clears the per-skb active_extensions bit, and the shared slab payload is released lazily by __skb_ext_put() once the last reference goes away. Replace the skb_ext_reset() call in skb_scrub_packet() with skb_ext_scrub() and also switch udp_try_make_stateless() to skb_ext_scrub() as well, so the BPF metadata survives queueing onto a UDP socket receive queue and stays readable there (e.g. for a sockmap verdict program). Only mark the skb stateless when no extension survives the scrub. Otherwise skb_consume_udp() would take the __consume_stateless_skb() fast path, which skips skb_release_head_state(), and leak the extension slab. Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com> ---
Hello Jakub, What are your current plans for this series? This commit solves the same problem I have with wanting to preserve the PSP skb extension across netns forwarding. Daniel