Article View: linux.kernel.netdev
Article #21892[PATCH RFC bpf-next 0/4] bpf: add bpf_sk_assign support on netkit egress
From: Nikolay Aleksandrov
Date: Tue, 24 Nov 2026 15:12
Date: Tue, 24 Nov 2026 15:12
83 lines
14343 bytes
14343 bytes
Hi,
This RFC narrows the earlier egress series [1] to netkit's transmit
path. NETKIT_PASS queues the assigned skb directly to the peer's
receive backlog. NETKIT_REDIRECT clears the assignment before forwarding.
General TC egress support would require changes across the networking
stack. Many transmit paths rely on skb->sk and skb->destructor for
send-side ownership and socket write-memory accounting, and would need
to handle an assigned socket reference in place of the transmit owner.
There is a new sk_assign_skb added to bpf_net_context that is used to
record the exact skb netkit is running BPF on, bpf_sk_assign uses that
identity to allow egress assignment for that skb. It is valid only when
the new kern_flags bit is set, that is used to avoid always initializing
it to NULL in bpf_net_ctx_set.
A nested tc egress program running on a clone still gets -EOPNOTSUPP.
This series builds on Daniel's work [2] to steer netkit traffic to a
transparent proxy in the receiving namespace. The receive backlog can
outlive the transmit path's RCU read-side section, so the skb takes its
own socket reference even for SOCK_RCU_FREE listeners.
The selftests exercise the new netkit sk assign for both IPv4/IPv6 and
TCP/UDP.
Feedback is most welcome, more importantly if the approach taken in
patch 03 is acceptable.
Changes since the original posting:
- Use a new approach to limit the egress sk assign only to netkit
- Reduce the number of selftests
- Drop some unnecessary fixes of pre-existing problems
Pre-existing problems found during reviews that will be dealt with
separately:
- Receive lookup could use a prefetched socket whose protocol, family
or network namespace did not match the packet
- GRO via gro_cells can merge an assigned skb after tunnel
decapsulation and discard its socket reference without calling the
destructor
- When a reuseport program rejects an assigned UDP socket, receive can
report an error pointer as rx_sk to the kfree_skb tracepoint
- A generic XDP program, an rx_handler or a classic mirred action on
the receiving device can forward the assigned skb to another network
namespace. Generic XDP can also drop the assignment when it copies
the skb, so the packet falls back to normal socket lookup
- nsim_forward_skb() queues the skb for napi_gro_receive() without
orphaning it. GRO can discard its socket reference when merging it
Thanks,
Nik
[1] https://lore.kernel.org/bpf/20261119142231.2612515-1-razor@blackwall.org/
[2] https://github.com/cilium/linux/commits/pr/bpf-tproxy
Nikolay Aleksandrov (4):
net: track references owned by prefetched socket assignments
bpf: preserve owned socket assignments on ingress redirects
bpf: support bpf_sk_assign in netkit tx path
selftests/bpf: test netkit socket assignment to a transparent proxy
drivers/net/netkit.c | 10 +
include/linux/filter.h | 4 +
include/net/inet6_hashtables.h | 10 +-
include/net/inet_hashtables.h | 10 +-
include/net/netkit.h | 15 ++
include/net/request_sock.h | 10 +-
include/net/sock.h | 4 +-
include/uapi/linux/bpf.h | 9 +-
net/core/filter.c | 50 ++++-
net/core/sock.c | 7 +
net/netfilter/nf_queue.c | 16 +-
tools/include/uapi/linux/bpf.h | 9 +-
.../bpf/prog_tests/sk_assign_netkit.c | 189 ++++++++++++++++++
.../selftests/bpf/progs/sk_assign_netkit.c | 95 +++++++++
14 files changed, 412 insertions(+), 26 deletions(-)
create mode 100644 tools/testing/selftests/bpf/prog_tests/sk_assign_netkit.c
create mode 100644 tools/testing/selftests/bpf/progs/sk_assign_netkit.c
--
2.47.3
Technical Details
Message-ID:
<20261124151244.1423343-1-razor@blackwall.org>Path:
mbox-mo1.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370499-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370499-linux-kernel-netdev=dewy.ru From: razor@blackwall.org (Nikolay Aleksandrov) Newsgroups: linux.kernel.netdev Subject: [PATCH RFC bpf-next 0/4] bpf: add bpf_sk_assign support on netkit egress Date: Tue, 24 Nov 2026 17:12:40 +0200 Organization: Usenet Network Message-ID: <20261124151244.1423343-1-razor@blackwall.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="4166876"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:bZ8HbQs2Cg0mxFCariAojEbpMo4= sha256:pMJuMVFleXWU7oX0AX26kRoPpoO3ePu71xfq7J71s7M= sha1:NIg2X5SH2IgajgDJC4NLPslBGpw= sha256:wDIK4jwGB+iPLuuAm9Q6Ku/wCi9KYFmxXEd1tmmKpjM= 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 26730125E1F; Tue, 24 Nov 2026 18:13:19 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.051 X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, 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=blackwall.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 S5-pN86zIab7; Tue, 24 Nov 2026 18:13:15 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-370499-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=blackwall.org X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id 847A6125E18; Tue, 24 Nov 2026 18:13:05 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id D85F628E4B; Tue, 24 Nov 2026 15:13:02 +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=1795533182; b=jyKoqIb6/zdF+HuDj+npJQYC20udm6bR9bizhcPDleFUJptMAPL6WTsDazC+0J0+Sd0q nbnMOAZvnas+gjMRLhEpZhQzBanZPcjkiowkYGvZRLgnurS1Wn/boEi/5NrcuVZ3+pXiW J5pkCkcztuJmBGMypQw8l8b/fT8hepQf3m8snKTocCgSuYTXDLkgMybds569GYlSnH2X3 9thWrfOXiiXRTWyPB7DCso4MsKvvQLFj7FERotFA0ob5QlVoN6lhh5GmvJWtsSidyhpdX 9qtberKVl9Kx4ANRXtIaN8zI/KDYg0hIOVTVJnNrypwzgVrRJCccodt4+PCDUZGTtsA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795533182; h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature: X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State: X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:Date:Message-ID: X-Mailer:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version: Content-Transfer-Encoding; bh=rwg2yD1zJeOjWk9k6blison6UKKrmu+SCF2d3nY+2Pc=; b=EHXAA9pxUZxP/WfEVRHwVGPPQEbUa3QOXGg9PXhSIW4UtCrsOhhhnGvUZmiVtEEr5nUB sD3frPUgxlrLM73OPh89ArDj8wL0oJ4rwpgFlN0+s4FKvFFUhGH1BQcW4K/QitiJJJa0h 5xCcHOo4VJgGkAitHS482W6dfpc50Pj2wr3cb0H/URsmQkRtb3aJQDcMo2ENEgdZ36nRx YDueFzl3/bAHEhnnDvITo9Sec+gUUBYm7W8tjEs4fp2w72P9jI5bQEA+eIgNwWmRduVjH Eq7sn4gI3Y3iF89XwZRZaiTHt0fUUZBL7/XKREaA6UZ+MzoYaqzSl9oBvYjo473TcNg== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=blackwall.org header.i=@blackwall.org header.a=rsa-sha256 header.s=google header.b=aqSip14k; dmarc=none header.from=blackwall.org; spf=none smtp.mailfrom=blackwall.org; 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 43725606A321; Tue, 24 Nov 2026 15:13:02 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=blackwall.org header.i=@blackwall.org header.a=rsa-sha256 header.s=google header.b=aqSip14k X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.45 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795533181; b=f03j4fgmpPV1YpothcLUI+tzIGY9qcF9CAznOebeZ754+1EJuk6t5gr8aF9dTum/PTiX QJBtPCmn5uf3eA4Lh6Z3nIlVlnpzqayXmZKfwG3+Lb5Bb7axTfNVUOTasAkcxsDyvch6j LzTQp0hMM13+7Q0o8ETTs0Cipz/IFPNIoSimTpYyE30zf/VYvabkFMfJzGIU9PjSmr1r6 CseHlTA7u4m0a3icvpPA7tcXv9rQXw7nzCf/dIm3+9W7ynbA1a4KIhRfishfmKO3kGL/8 HNfM9o85UOFypbX1vI1pWMYB/BV+K56fJhiFudQtCoiCWT50gmsEDsTKCcvFJF+ajeg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795533181; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=rwg2yD1zJeOjWk9k6blison6UKKrmu+SCF2d3nY+2Pc=; b=G6PLaAIwBECpI65rx6e91qIVmpfU0q4HdtSnjpajDjS6QL+gciFaeEmmaZcdCnRFmgvd Y5+T9PE8tx0E57cbyB3YHvmpXEyM+3nZ6KDsoqUeXxfQYG6gz1qKfQv5H0JrsJfiE+Vgm d6GrYA+eoHWqmkxVo7mDMt0UC4XNk1ahixbfHmB3+n2aNVstv/zMu226n7Eua7ZrvrdOy CcadgSu7JehQorBfy4F1AsWvEtvCDPRedbKRoGVjszqjyk88wHE2CPgNK6HTlGA9Wbe/M /ued8X02CZUGQu5Z6TfTBB7N8BXFMFbcSfSpA+vUF6bMDR0SLti6T7yzECKd5GUL23g== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=blackwall.org; spf=none smtp.mailfrom=blackwall.org; dkim=pass header.d=blackwall.org header.i=@blackwall.org header.a=rsa-sha256 header.s=google header.b=aqSip14k; arc=none smtp.remote-ip=209.85.128.45 X-Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 88EDB606A339 for <netdev@vger.kernel.org>; Tue, 24 Nov 2026 15:13:00 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 88EDB606A339 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=blackwall.org X-Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=blackwall.org X-Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-4bb6adaf0f1so40883625e9.0 for <netdev@vger.kernel.org>; Tue, 24 Nov 2026 07:13:00 -0800 (PST) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=blackwall.org; s=google; t=1795533179; x=1796137979; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=rwg2yD1zJeOjWk9k6blison6UKKrmu+SCF2d3nY+2Pc=; b=aqSip14kJuwOstw9v1SSzcUqfxbfcSSU1+YaNCeXU7kbwhBBGtPWSlwIMRuIbzfuaL ERWULgL2sqSxy9m2yB+GHEnsgz3v7oetNbCl6qWvpij49i+MgesFHx2us+4u8WbGCzbC 8MdAf1/yl+uFdGCt0rDcvBAJNnYIvfPq9/QUn56gdyJ1Tv+TJzVS41ZJrW03dFgMhQpH qwRObwBamonPdZl0dllqDtMgJjVNKthhu+GfWx0ANFoD8+gvJBtNaCRR2hq9nPvwV2OC J3pcAgmbg+0PA27wvo6+P2r8s7NL5AD8NHYpc0Rp6ak9nmEFCWtPJnJppLAf3dTMnWd/ rOZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795533179; x=1796137979; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=rwg2yD1zJeOjWk9k6blison6UKKrmu+SCF2d3nY+2Pc=; b=ayijIF+lwnb5gvUXlw+52HShOh5AobGIRO6GP29nvtjcJ084F7hg9dggBmk3QmC2Mt aBHcKGL8wnWLFKc/ktl1rzB4HxO/We6msaKVeYzdN3S0YR3rqc+DML4T27GZL4qvVaff M/LZiKXNfuKqkUdxHn5ep+4/UoCYdeyzOuFXC3CRXJMy0bKrCatWjB096tEjaHqAQodv +VfX4SL8l9+75e+51RR3x0X9R4DZaHptWdGSitGoi8+K9HearytA95E/Na6Y443659F5 yBvS2kiVMoVm9gD4I5jgcRYezseuqwzv/uznWM06XcRiY1xguWJGOLRPFLQrfH2+09PQ UX6Q== X-Forwarded-Encrypted: i=1; AL+hErEVvFY6TtQZ1kpr1zTXw7MlVQHcaUms0IGA3gB/83BKckwLN+GqB2TnewqbTcJZ3UP25jIisY0=@vger.kernel.org X-Gm-Message-State: APuU4Z+EUZajGcd31MJWaKrvbyT/cASXLD2T/kxSo2WOZOS5WojM1s10 B0jtcBE/yCY6RGBcsJt5r3dnYyHF0+IoJXS2M0LlAe+2AYWOmRxwNnerz3fb6EwNIHE= X-Gm-Gg: AZFdTZfyvrRSPJDsGWVVpWqyJOIdot6HB2bixCOVIlDgXGEdMit1ev5rlzthG9C/21u nI7DanaKKMTDSDtvVD5olPaAzHaW4SVVft7SAAK3dndDeIXPIJtKe/HOtI6E+pYLOyOhqhm66ho 5O9M/0a2JIaK9zpjU3EnNBapxxqegVaXq9oASiQeh9m4U3xSdrShRFq7bcp+Q62zUBaCAskJlPa QmstcjFMJaz61nQqqo3J7az7EcYEBURr1ZiEIzZbm7Rjp1tMFNBlTnW+46nT0MsD2EBxqNpD2XO GwinTFZ8A/A/HfzXAyitncHU/M6UByNPacW25leGqLO0lpRF4/J9CQmQXAgz3acSuJ1h4Z5oPAf CsKiSNwpWr8EX7FVW3V8A9KBwePKN/34tKSiVWKQ5gphKlsHy3ZC3a8SE1bPf/DdJbWi607FvAQ wLe1v/T4lPQsA0+XMzEq/rNrMCCoD6dndUORwpj+OeHmNKgAMFuLOl24ZdaH7zigKkzZ2G8929y m3NuJ0wLY6XDIPLzx6Ev9De29kc5ZH0sChS3tb5RBBrrmGqgOgVXHuAXZrlQ9v6Bd9Cyj2k5F0Z uRYORoQC6lDE+81ZL9dZbNaBqLYVgxAafWLuvurTOtb3fwhZjJw= X-Received: by 2002:a05:600c:a086:b0:4af:c210:5b3f with SMTP id 5b1f17b1804b1-4bb88817ef1mr320282735e9.24.1795533178500; Tue, 24 Nov 2026 07:12:58 -0800 (PST) X-Received: from localhost (78-154-14-127.ip.btc-net.bg. [78.154.14.127]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-4ab6bc8ce06sm27944396f8f.47.2026.11.24.07.12.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Nov 2026 07:12:58 -0800 (PST) X-Cc: Eric Dumazet <edumazet@kernel.org>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, netdev@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Stanislav Fomichev <sdf.kernel@gmail.com>, Nikolay Aleksandrov <razor@blackwall.org> X-Mailer: git-send-email 2.47.3 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