Skip to content

RFC bpf_link observability APIs

Andrii Nakryiko bpf netdev oe-kbuild-all 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest8 patches 15 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8bpf: refactor bpf_link update handlinginclude/linux/bpf-cgroup.h include/linux/bpf.h kernel/bpf/cgroup.c +2 more+34 -490 replies
2/8bpf: allow bpf_link pinning as read-only and enforce LINK_UPDATEinclude/linux/bpf.h kernel/bpf/inode.c kernel/bpf/syscall.c+44 -180 replies
3/8bpf: allocate ID for bpf_linkinclude/linux/bpf.h include/uapi/linux/bpf.h kernel/bpf/cgroup.c +1 more+116 -560 replies
4/8bpf: support GET_FD_BY_ID and GET_NEXT_ID for bpf_linkinclude/uapi/linux/bpf.h kernel/bpf/syscall.c+58 -09 replies
5/8bpf: 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+266 -242 replies
6/8libbpf: 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
7/8bpftool: expose attach_type-to-string array to non-cgroup codetools/bpf/bpftool/cgroup.c tools/bpf/bpftool/main.h+35 -250 replies
8/8bpftool: add bpf_link show and pin supporttools/bpf/bpftool/link.c tools/bpf/bpftool/main.c tools/bpf/bpftool/main.h+410 -02 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH bpf-next 0/8] 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;
  - makes LINK_UPDATE operation allowed only for writable bpf_links and allows
    to pin bpf_link as read-only file;
  - 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.

This RFC series is missing selftests and only limited amount of manual testing was performed. But kernel implementation is hopefully in a good shape and won't change much (unless some big issues are identified with the current approach). It would be great to get feedback on approach and implementation, before I invest more time in writing tests.

Andrii Nakryiko (8):
bpf: refactor bpf_link update handling
bpf: allow bpf_link pinning as read-only and enforce LINK_UPDATE
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
bpftool: expose attach_type-to-string array to non-cgroup code
bpftool: add bpf_link show and pin support

 include/linux/bpf-cgroup.h     |  14 --
 include/linux/bpf.h            |  34 ++-
 include/linux/bpf_types.h      |   6 +
 include/uapi/linux/bpf.h       |  31 +++
 kernel/bpf/btf.c               |   2 +
 kernel/bpf/cgroup.c            |  89 +++++++-
 kernel/bpf/inode.c             |  30 ++-
 kernel/bpf/syscall.c           | 387 +++++++++++++++++++++++++------
 kernel/bpf/verifier.c          |   2 +
 kernel/cgroup/cgroup.c         |  27 ---
 tools/bpf/bpftool/cgroup.c     |  28 +--
 tools/bpf/bpftool/link.c       | 403 +++++++++++++++++++++++++++++++++
 tools/bpf/bpftool/main.c       |   2 +
 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 +
 18 files changed, 983 insertions(+), 169 deletions(-)
 create mode 100644 tools/bpf/bpftool/link.c
Signature · 1 line
2.24.1