From: Nikolay Aleksandrov <razor@blackwall.org>
To: bpf@vger.kernel.org
Cc: Nikolay Aleksandrov <razor@blackwall.org>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Eduard Zingerman <eddyz87@gmail.com>,
Kumar Kartikeya Dwivedi <memxor@gmail.com>,
Martin KaFai Lau <martin.lau@linux.dev>,
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>,
John Fastabend <john.fastabend@gmail.com>,
Stanislav Fomichev <sdf@fomichev.me>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>, Joe Stringer <joe@wand.net.nz>,
Paul Chaignon <paul@isovalent.com>,
Alasdair McWilliam <alasdair.mcwilliam@isovalent.com>,
netdev@vger.kernel.org
Subject: [PATCH bpf-next 0/8] bpf: add bpf_sk_assign support on egress
Date: Thu, 19 Nov 2026 16:22:22 +0200 [thread overview]
Message-ID: <20261119142231.2612515-1-razor@blackwall.org> (raw)
Hi,
This patch-set is based on Daniel's [1] original set that adds support for
bpf_sk_assign on egress. It is useful for the TPROXY use case which needs
to assign a listening socket (e.g. Envoy) to an skb on egress, other
potential use cases are to attribute forwarded traffic to a specific
established socket for qdisc flow classification (fq, fq_codel) or cgroup
accounting. In order to support bpf_sk_assign on SOCK_RCU_FREE sockets, a
reference is taken and a specific destructor that unconditionally releases
it is installed (sock_pfree_ref). That destructor is used throughout to
recognize such skb. For more information please see the individual commit
messages.
There are a few limitations, also noted in the commit messages,
more importantly:
- software GSO splitting after assignment is unsupported
- decrypted egress skbs are unsupported
- loopback discards egress assignments
Maybe this can be applied to a feature branch on bpf-next and then pulled to
bpf-next/master and net-next/main so both trees would have the original
commits and not duplicates.
With the kind help of friendly LLMs there're 19 new selftests that exercise
various sk assign (16 egress and 3 ingress) scenarios such as:
- egress reuseport (4 tests)
- ingress redirects (2 tests)
- egress redirects and drops (4 tests)
- classic tc actions (3 tests)
- netkit proxy delivery (2 tests)
- netkit with NFQUEUE (4 tests)
Thank you,
Nik
[1] https://github.com/cilium/linux/commits/pr/bpf-tproxy/
CC: Alexei Starovoitov <ast@kernel.org>
CC: Daniel Borkmann <daniel@iogearbox.net>
CC: Andrii Nakryiko <andrii@kernel.org>
CC: Eduard Zingerman <eddyz87@gmail.com>
CC: Kumar Kartikeya Dwivedi <memxor@gmail.com>
CC: Martin KaFai Lau <martin.lau@linux.dev>
CC: Song Liu <song@kernel.org>
CC: Yonghong Song <yonghong.song@linux.dev>
CC: Jiri Olsa <jolsa@kernel.org>
CC: Emil Tsalapatis <emil@etsalapatis.com>
CC: Ihor Solodrai <ihor.solodrai@linux.dev>
CC: John Fastabend <john.fastabend@gmail.com>
CC: Stanislav Fomichev <sdf@fomichev.me>
CC: David S. Miller <davem@davemloft.net>
CC: Eric Dumazet <edumazet@kernel.org>
CC: Jakub Kicinski <kuba@kernel.org>
CC: Paolo Abeni <pabeni@redhat.com>
CC: Simon Horman <horms@kernel.org>
CC: Joe Stringer <joe@wand.net.nz>
CC: Paul Chaignon <paul@isovalent.com>
CC: Alasdair McWilliam <alasdair.mcwilliam@isovalent.com>
CC: netdev@vger.kernel.org
Daniel Borkmann (3):
bpf: Orphan prefetched sk on skb_do_redirect()
bpf: allow bpf_sk_assign on tc egress with refcounted sockets
bpf: support SOCK_RCU_FREE sockets in bpf_sk_assign on egress
Nikolay Aleksandrov (5):
net: track references owned by prefetched socket assignments
selftests/bpf: Delete assign_reuse namespace when opening it fails
selftests/bpf: Cover egress socket assignment with reuseport
selftests/bpf: Exercise netkit socket assignment to a host proxy
selftests/bpf: Check assigned socket lifetime across queues and drops
.../chelsio/inline_crypto/ch_ktls/chcr_ktls.c | 5 +-
include/net/inet6_hashtables.h | 10 +-
include/net/inet_hashtables.h | 10 +-
include/net/request_sock.h | 8 +-
include/net/sock.h | 4 +-
include/uapi/linux/bpf.h | 9 +-
net/core/filter.c | 22 +-
net/core/sock.c | 11 +
net/netfilter/nf_queue.c | 16 +-
net/sched/act_bpf.c | 4 +-
net/tls/tls_device_fallback.c | 5 +-
tools/include/uapi/linux/bpf.h | 9 +-
tools/testing/selftests/bpf/config | 5 +
tools/testing/selftests/bpf/netlink_helpers.c | 3 +-
.../selftests/bpf/prog_tests/assign_reuse.c | 625 +++++++++++++++++-
.../bpf/prog_tests/sk_assign_netkit.c | 586 ++++++++++++++++
.../selftests/bpf/progs/sk_assign_lifetime.c | 182 +++++
.../selftests/bpf/progs/sk_assign_netkit.c | 153 +++++
.../selftests/bpf/progs/test_assign_reuse.c | 174 ++++-
tools/testing/selftests/bpf/unpriv_helpers.c | 16 +
tools/testing/selftests/bpf/unpriv_helpers.h | 2 +
21 files changed, 1794 insertions(+), 65 deletions(-)
create mode 100644 tools/testing/selftests/bpf/prog_tests/sk_assign_netkit.c
create mode 100644 tools/testing/selftests/bpf/progs/sk_assign_lifetime.c
create mode 100644 tools/testing/selftests/bpf/progs/sk_assign_netkit.c
--
2.47.3
next reply other threads:[~2026-11-19 14:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 14:22 Nikolay Aleksandrov [this message]
2026-11-19 14:22 ` [PATCH bpf-next 1/8] bpf: Orphan prefetched sk on skb_do_redirect() Nikolay Aleksandrov
2026-11-19 14:22 ` [PATCH bpf-next 2/8] net: track references owned by prefetched socket assignments Nikolay Aleksandrov
2026-11-19 14:22 ` [PATCH bpf-next 3/8] bpf: allow bpf_sk_assign on tc egress with refcounted sockets Nikolay Aleksandrov
2026-11-19 15:19 ` bot+bpf-ci
2026-11-19 15:36 ` Nikolay Aleksandrov
2026-11-19 14:22 ` [PATCH bpf-next 4/8] bpf: support SOCK_RCU_FREE sockets in bpf_sk_assign on egress Nikolay Aleksandrov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261119142231.2612515-1-razor@blackwall.org \
--to=razor@blackwall.org \
--cc=alasdair.mcwilliam@isovalent.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=eddyz87@gmail.com \
--cc=edumazet@kernel.org \
--cc=emil@etsalapatis.com \
--cc=horms@kernel.org \
--cc=ihor.solodrai@linux.dev \
--cc=joe@wand.net.nz \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kuba@kernel.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=paul@isovalent.com \
--cc=sdf@fomichev.me \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox