From: Daniel Borkmann <daniel@iogearbox.net>
To: ast@kernel.org
Cc: andrii@kernel.org, martin.lau@linux.dev, razor@blackwall.org,
sdf@google.com, john.fastabend@gmail.com, kuba@kernel.org,
dxu@dxuuu.xyz, joe@cilium.io, toke@kernel.org,
davem@davemloft.net, bpf@vger.kernel.org, netdev@vger.kernel.org,
Daniel Borkmann <daniel@iogearbox.net>
Subject: [PATCH bpf-next v4 0/8] BPF link support for tc BPF programs
Date: Mon, 10 Jul 2023 22:12:10 +0200 [thread overview]
Message-ID: <20230710201218.19460-1-daniel@iogearbox.net> (raw)
This series adds BPF link support for tc BPF programs. We initially
presented the motivation, related work and design at last year's LPC
conference in the networking & BPF track [0], and a recent update on
our progress of the rework during this year's LSF/MM/BPF summit [1].
The main changes are in first two patches and the last two have an
extensive batch of test cases we developed along with it, please see
individual patches for details. We tested this series with tc-testing
selftest suite as well as BPF CI/selftests. Thanks!
v3 -> v4:
- Fix bpftool output to display tcx/{ingress,egress} (Stan)
- Documentation around API, BPF_MPROG_* return codes and locking
expectations (Stan, Alexei)
- Change _after and _before to have the same semantics for return
value (Alexei)
- Rework mprog initialization and move allocation/free one layer
up into tcx to simplify the code (Stan)
- Add comment on synchronize_rcu and parent->ref (Stan)
- Add comment on bpf_mprog_pos_() helpers wrt target position (Stan)
v2 -> v3:
- Removal of BPF_F_FIRST/BPF_F_LAST from control UAPI (Toke, Stan)
- Along with that full rework of bpf_mprog internals to simplify
dependency management, looks much nicer now imho
- Just single bpf_mprog_cp instead of two (Andrii)
- atomic64_t for revision counter (Andrii)
- Evaluate target position and reject on conflicts (Andrii)
- Keep track of actual count in bpf_mprob_bundle (Andrii)
- Make combo of REPLACE and BEFORE/AFTER work (Andrii)
- Moved miniq as first struct member (Jamal)
- Rework tcx_link_attach with regards to rtnl (Jakub, Andrii)
- Moved wrappers after bpf_prog_detach_ops (Andrii)
- Removed union for relative_fd and friends for opts and link in
libbpf (Andrii)
- Add doc comments to attach/detach/query libbpf APIs (Andrii)
- Dropped SEC_ATTACHABLE_OPT (Andrii)
- Add an OPTS_ZEROED check to bpf_link_create (Andrii)
- Keep opts as the last argument in bpf_program_attach_fd (Andrii)
- Rework bpf_program_attach_fd (Andrii)
- Remove OPTS_GET before we checked OPTS_VALID in
bpf_program__attach_tcx (Andrii)
- Add `size_t :0;` to prevent compiler from leaving garbage (Andrii)
- Add helper macro to clear opts structs which I found useful
when writing tests
- Rework of both opts and link test cases to accommodate for changes
v1 -> v2:
- Rework of almost entire series to remove prio from UAPI and switch
to better control directives BPF_F_FIRST/BPF_F_LAST/BPF_F_BEFORE/
BPF_F_AFTER (Alexei, Toke, Stan, Andrii)
- Addition of big test suite to cover all corner cases
[0] https://lpc.events/event/16/contributions/1353/
[1] http://vger.kernel.org/bpfconf2023_material/tcx_meta_netdev_borkmann.pdf
Daniel Borkmann (8):
bpf: Add generic attach/detach/query API for multi-progs
bpf: Add fd-based tcx multi-prog infra with link support
libbpf: Add opts-based attach/detach/query API for tcx
libbpf: Add link-based API for tcx
libbpf: Add helper macro to clear opts structs
bpftool: Extend net dump with tcx progs
selftests/bpf: Add mprog API tests for BPF tcx opts
selftests/bpf: Add mprog API tests for BPF tcx links
MAINTAINERS | 5 +-
include/linux/bpf_mprog.h | 352 +++
include/linux/netdevice.h | 15 +-
include/linux/skbuff.h | 4 +-
include/net/sch_generic.h | 2 +-
include/net/tcx.h | 199 ++
include/uapi/linux/bpf.h | 70 +-
kernel/bpf/Kconfig | 1 +
kernel/bpf/Makefile | 3 +-
kernel/bpf/mprog.c | 427 ++++
kernel/bpf/syscall.c | 83 +-
kernel/bpf/tcx.c | 351 +++
net/Kconfig | 5 +
net/core/dev.c | 267 +-
net/core/filter.c | 4 +-
net/sched/Kconfig | 4 +-
net/sched/sch_ingress.c | 61 +-
tools/bpf/bpftool/net.c | 86 +-
tools/include/uapi/linux/bpf.h | 70 +-
tools/lib/bpf/bpf.c | 124 +-
tools/lib/bpf/bpf.h | 97 +-
tools/lib/bpf/libbpf.c | 74 +-
tools/lib/bpf/libbpf.h | 16 +
tools/lib/bpf/libbpf.map | 2 +
tools/lib/bpf/libbpf_common.h | 11 +
.../selftests/bpf/prog_tests/tc_helpers.h | 72 +
.../selftests/bpf/prog_tests/tc_links.c | 1604 ++++++++++++
.../selftests/bpf/prog_tests/tc_opts.c | 2182 +++++++++++++++++
.../selftests/bpf/progs/test_tc_link.c | 40 +
29 files changed, 6002 insertions(+), 229 deletions(-)
create mode 100644 include/linux/bpf_mprog.h
create mode 100644 include/net/tcx.h
create mode 100644 kernel/bpf/mprog.c
create mode 100644 kernel/bpf/tcx.c
create mode 100644 tools/testing/selftests/bpf/prog_tests/tc_helpers.h
create mode 100644 tools/testing/selftests/bpf/prog_tests/tc_links.c
create mode 100644 tools/testing/selftests/bpf/prog_tests/tc_opts.c
create mode 100644 tools/testing/selftests/bpf/progs/test_tc_link.c
--
2.34.1
next reply other threads:[~2023-07-10 20:12 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-10 20:12 Daniel Borkmann [this message]
2023-07-10 20:12 ` [PATCH bpf-next v4 1/8] bpf: Add generic attach/detach/query API for multi-progs Daniel Borkmann
2023-07-11 0:23 ` Alexei Starovoitov
2023-07-11 18:51 ` Andrii Nakryiko
2023-07-14 16:06 ` Daniel Borkmann
2023-07-11 18:48 ` Andrii Nakryiko
2023-07-14 16:00 ` Daniel Borkmann
2023-07-10 20:12 ` [PATCH bpf-next v4 2/8] bpf: Add fd-based tcx multi-prog infra with link support Daniel Borkmann
2023-07-10 20:12 ` [PATCH bpf-next v4 3/8] libbpf: Add opts-based attach/detach/query API for tcx Daniel Borkmann
2023-07-11 4:00 ` Andrii Nakryiko
2023-07-11 14:03 ` Daniel Borkmann
2023-07-10 20:12 ` [PATCH bpf-next v4 4/8] libbpf: Add link-based " Daniel Borkmann
2023-07-11 4:00 ` Andrii Nakryiko
2023-07-11 14:08 ` Daniel Borkmann
2023-07-10 20:12 ` [PATCH bpf-next v4 5/8] libbpf: Add helper macro to clear opts structs Daniel Borkmann
2023-07-11 4:02 ` Andrii Nakryiko
2023-07-11 9:42 ` Daniel Borkmann
2023-07-10 20:12 ` [PATCH bpf-next v4 6/8] bpftool: Extend net dump with tcx progs Daniel Borkmann
2023-07-11 14:19 ` Quentin Monnet
2023-07-11 16:46 ` Daniel Borkmann
2023-07-10 20:12 ` [PATCH bpf-next v4 7/8] selftests/bpf: Add mprog API tests for BPF tcx opts Daniel Borkmann
2023-07-10 20:12 ` [PATCH bpf-next v4 8/8] selftests/bpf: Add mprog API tests for BPF tcx links Daniel Borkmann
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=20230710201218.19460-1-daniel@iogearbox.net \
--to=daniel@iogearbox.net \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=davem@davemloft.net \
--cc=dxu@dxuuu.xyz \
--cc=joe@cilium.io \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=martin.lau@linux.dev \
--cc=netdev@vger.kernel.org \
--cc=razor@blackwall.org \
--cc=sdf@google.com \
--cc=toke@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).