Skip to content

BPF link support for tc BPF programs

Daniel Borkmann bpf netdev 6 versions – Applied

Status from this message: This series was applied to bpf/bpf-next.git (master)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 Latest8 patches 4 repliesApplied 8/8
  2. v58 patches 4 repliesSuperseded
  3. v48 patches 13 repliesSuperseded
Earlier versions · 3
VersionPostedPatchesRepliesStatus
v38 patches18 repliesSuperseded
v27 patches41 repliesSuperseded
v110 patches51 repliesSuperseded

Changes in v6 from the cover letter

- Remove export symbol on tcx_inc/dec (Jakub)
- Treat fd==0 as invalid (Stan, Alexei)

Patches in v6 All 8 applied

#Subject and filesSizeRepliesApplied
1/8bpf: Add generic attach/detach/query API for multi-progsMAINTAINERS include/linux/bpf_mprog.h include/uapi/linux/bpf.h +3 more+821 -170 repliesApplied
2/8bpf: Add fd-based tcx multi-prog infra with link supportMAINTAINERS include/linux/bpf_mprog.h include/linux/netdevice.h +14 more+935 -1444 repliesApplied
3/8libbpf: Add opts-based attach/detach/query API for tcxtools/lib/bpf/bpf.c tools/lib/bpf/bpf.h tools/lib/bpf/libbpf.c +1 more+159 -530 repliesApplied
4/8libbpf: Add link-based API for tcxtools/lib/bpf/bpf.c tools/lib/bpf/bpf.h tools/lib/bpf/libbpf.c +2 more+88 -110 repliesApplied
5/8libbpf: Add helper macro to clear opts structstools/lib/bpf/libbpf_common.h+16 -00 repliesApplied
6/8bpftool: Extend net dump with tcx progstools/bpf/bpftool/Documentation/bpftool-net.rst tools/bpf/bpftool/net.c tools/bpf/bpftool/netlink_dumper.h+116 -160 repliesApplied
7/8selftests/bpf: Add mprog API tests for BPF tcx optstools/testing/selftests/bpf/prog_tests/tc_helpers.h tools/testing/selftests/bpf/prog_tests/tc_opts.c tools/testing/selftests/bpf/progs/test_tc_link.c+2351 -00 repliesApplied
8/8selftests/bpf: Add mprog API tests for BPF tcx linkstools/testing/selftests/bpf/prog_tests/tc_links.c+1583 -00 repliesApplied

Reviews trailers per patch

4 of 8 patches have a Reviewed-by or Acked-by.

PatchJakub KicinskiAndrii NakryikoQuentin Monnet
1/8
2/8A-b
3/8A-b
4/8A-b
5/8
6/8R-b
7/8
8/8

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v6 thread

Cover letter [PATCH bpf-next v6 0/8] BPF link support for tc BPF programs

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!

v5 -> v6:
- Remove export symbol on tcx_inc/dec (Jakub)
- Treat fd==0 as invalid (Stan, Alexei)
v4 -> v5:
- Updated bpftool docs and usage of bpftool net (Quentin)
- Consistent dump "prog id"/"link id" -> "prog_id"/"link_id" (Quentin)
- Reworked bpftool flag output handling (Quentin)
- LIBBPF_OPTS_RESET() macro with varargs for reinit (Andrii)
- libbpf opts/link bail out on relative_fd && relative_id (Andrii)
- libbpf improvements for assigning attr.relative_{id,fd} (Andrii)
- libbpf sorting in libbpf.map (Andrii)
- libbpf move ifindex to bpf_program__attach_tcx param (Andrii)
- libbpf move BPF_F_ID flag handling to bpf_link_create (Andrii)
- bpf_program_attach_fd with tcx instead of tc (Andrii)
- Reworking kernel-internal bpf_mprog API (Alexei, Andrii)
- Change "object" notation to "id_or_fd" (Andrii)
- Remove on stack cpp[BPF_MPROG_MAX] and switch to memmove (Andrii)
- Simplify bpf_mprog_{insert,delete} and add comment on internals
- Get rid of BPF_MPROG_* return codes (Alexei, Andrii)
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                     |  327 +++
 include/linux/netdevice.h                     |   15 +-
 include/linux/skbuff.h                        |    4 +-
 include/net/sch_generic.h                     |    2 +-
 include/net/tcx.h                             |  206 ++
 include/uapi/linux/bpf.h                      |   70 +-
 kernel/bpf/Kconfig                            |    1 +
 kernel/bpf/Makefile                           |    3 +-
 kernel/bpf/mprog.c                            |  445 ++++
 kernel/bpf/syscall.c                          |   82 +-
 kernel/bpf/tcx.c                              |  348 +++
 net/Kconfig                                   |    5 +
 net/core/dev.c                                |  265 +-
 net/core/filter.c                             |    4 +-
 net/sched/Kconfig                             |    4 +-
 net/sched/sch_ingress.c                       |   61 +-
 .../bpf/bpftool/Documentation/bpftool-net.rst |   26 +-
 tools/bpf/bpftool/net.c                       |   98 +-
 tools/bpf/bpftool/netlink_dumper.h            |    8 +
 tools/include/uapi/linux/bpf.h                |   70 +-
 tools/lib/bpf/bpf.c                           |  127 +-
 tools/lib/bpf/bpf.h                           |   97 +-
 tools/lib/bpf/libbpf.c                        |   70 +-
 tools/lib/bpf/libbpf.h                        |   15 +
 tools/lib/bpf/libbpf.map                      |    2 +
 tools/lib/bpf/libbpf_common.h                 |   16 +
 .../selftests/bpf/prog_tests/tc_helpers.h     |   72 +
 .../selftests/bpf/prog_tests/tc_links.c       | 1583 ++++++++++++
 .../selftests/bpf/prog_tests/tc_opts.c        | 2239 +++++++++++++++++
 .../selftests/bpf/progs/test_tc_link.c        |   40 +
 31 files changed, 6069 insertions(+), 241 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
Signature · 1 line
2.34.1