Skip to content

bpf_link observability APIs

Andrii Nakryiko bpf netdev 3 versions – Applied

Status from this message: Applied, Thanks

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest10 patches 1 replyApplied
  2. v210 patches 13 repliesSuperseded
  3. v110 patches 13 repliesSuperseded

Changes in v3 from the cover letter

- improve spin locking around bpf_link ID (Alexei);
- simplify bpf_link_info handling and fix compilation error on sh arch;

Patches in v3 Applied

#Subject and filesSizeRepliesApplied
1/10bpf: refactor bpf_link update handlinginclude/linux/bpf-cgroup.h include/linux/bpf.h kernel/bpf/cgroup.c +2 more+34 -490 replies
2/10bpf: allocate ID for bpf_linkinclude/linux/bpf.h include/uapi/linux/bpf.h kernel/bpf/cgroup.c +1 more+118 -570 replies
3/10bpf: support GET_FD_BY_ID and GET_NEXT_ID for bpf_linkinclude/uapi/linux/bpf.h kernel/bpf/syscall.c+51 -00 replies
4/10bpf: add support for BPF_OBJ_GET_INFO_BY_FD for bpf_linkinclude/linux/bpf-cgroup.h include/linux/bpf.h include/linux/bpf_types.h +6 more+253 -240 replies
5/10libbpf: add low-level APIs for new bpf_link commandstools/lib/bpf/bpf.c tools/lib/bpf/bpf.h tools/lib/bpf/libbpf.map+26 -30 replies
6/10selftests/bpf: test bpf_link's get_next_id, get_fd_by_id, and get_obj_infotools/testing/selftests/bpf/prog_tests/bpf_obj_id.c tools/testing/selftests/bpf/progs/test_obj_id.c+104 -200 replies
7/10bpftool: expose attach_type-to-string array to non-cgroup codetools/bpf/bpftool/cgroup.c tools/bpf/bpftool/main.h+47 -330 replies
8/10bpftool: add bpf_link show and pin supporttools/bpf/bpftool/common.c tools/bpf/bpftool/link.c tools/bpf/bpftool/main.c +1 more+345 -10 replies
9/10bpftool: add bpftool-link manpagetools/bpf/bpftool/Documentation/bpftool-link.rst+118 -00 replies
10/10bpftool: add link bash completionstools/bpf/bpftool/bash-completion/bpftool+39 -00 replies

Reviews trailers per patch

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

PatchQuentin Monnet
1/10
2/10
3/10
4/10
5/10
6/10
7/10R-b
8/10R-b
9/10R-b
10/10R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 bpf-next 00/10] bpf_link observability APIs

This patch series adds various observability APIs to bpf_link:
- each bpf_link now gets ID, similar to bpf_map and bpf_prog, by which user-space can iterate over all existing bpf_links and create limited FD from ID;
- allows to get extra object information with bpf_link general and

    type-specific information;
  - implements `bpf link show` command which lists all active bpf_links in the
    system;

- implements bpf link pin allowing to pin bpf_link by ID or from other pinned path.

v2->v3:
- improve spin locking around bpf_link ID (Alexei);
- simplify bpf_link_info handling and fix compilation error on sh arch;
v1->v2:
- simplified bpftool link show implementation (Quentin);
- fixed formatting of bpftool-link.rst (Quentin);
- fixed attach type printing logic (Quentin);
rfc->v1:
- dropped read-only bpf_links (Alexei);
- fixed bug in bpf_link_cleanup() not removing ID;
- fixed bpftool link pinning search logic;
- added bash-completion and man page.

Andrii Nakryiko (10):
bpf: refactor bpf_link update handling
bpf: allocate ID for bpf_link
bpf: support GET_FD_BY_ID and GET_NEXT_ID for bpf_link
bpf: add support for BPF_OBJ_GET_INFO_BY_FD for bpf_link
libbpf: add low-level APIs for new bpf_link commands selftests/bpf: test bpf_link's get_next_id, get_fd_by_id, and
get_obj_info
bpftool: expose attach_type-to-string array to non-cgroup code
bpftool: add bpf_link show and pin support
bpftool: add bpftool-link manpage
bpftool: add link bash completions

 include/linux/bpf-cgroup.h                    |  14 -
 include/linux/bpf.h                           |  26 +-
 include/linux/bpf_types.h                     |   6 +
 include/uapi/linux/bpf.h                      |  31 ++
 kernel/bpf/btf.c                              |   2 +
 kernel/bpf/cgroup.c                           |  87 ++++-
 kernel/bpf/syscall.c                          | 354 ++++++++++++++----
 kernel/bpf/verifier.c                         |   2 +
 kernel/cgroup/cgroup.c                        |  27 --
 .../bpftool/Documentation/bpftool-link.rst    | 118 ++++++
 tools/bpf/bpftool/bash-completion/bpftool     |  39 ++
 tools/bpf/bpftool/cgroup.c                    |  48 +--
 tools/bpf/bpftool/common.c                    |   2 +
 tools/bpf/bpftool/link.c                      | 333 ++++++++++++++++
 tools/bpf/bpftool/main.c                      |   6 +-
 tools/bpf/bpftool/main.h                      |  37 ++
 tools/include/uapi/linux/bpf.h                |  31 ++
 tools/lib/bpf/bpf.c                           |  19 +-
 tools/lib/bpf/bpf.h                           |   4 +-
 tools/lib/bpf/libbpf.map                      |   6 +
 .../selftests/bpf/prog_tests/bpf_obj_id.c     | 110 +++++-
 .../testing/selftests/bpf/progs/test_obj_id.c |  14 +-
 22 files changed, 1132 insertions(+), 184 deletions(-)
 create mode 100644 tools/bpf/bpftool/Documentation/bpftool-link.rst
 create mode 100644 tools/bpf/bpftool/link.c
Signature · 1 line
2.24.1