mbox series

[v2,bpf-next,0/3] libbpf: support custom SEC() handlers

Message ID 20220205013342.1110746-1-andrii@kernel.org (mailing list archive)
Headers show
Series libbpf: support custom SEC() handlers | expand

Message

Andrii Nakryiko Feb. 5, 2022, 1:33 a.m. UTC
Add ability for user applications and libraries to register custom BPF program
SEC() handlers. See patch #2 for examples where this is useful.

Patch #1 does some preliminary refactoring to allow exponsing program
init, preload, and attach callbacks as public API. It also establishes
a protocol to allow optional auto-attach behavior. This will also help the
case of sometimes auto-attachable uprobes.

Cc: Alan Maguire <alan.maguire@oracle.com>

Andrii Nakryiko (3):
  libbpf: allow BPF program auto-attach handlers to bail out
  libbpf: support custom SEC() handlers
  selftests/bpf: add custom SEC() handling selftest

 tools/lib/bpf/libbpf.c                        | 299 ++++++++++++------
 tools/lib/bpf/libbpf.h                        |  81 +++++
 tools/lib/bpf/libbpf.map                      |   2 +
 .../bpf/prog_tests/custom_sec_handlers.c      | 136 ++++++++
 .../bpf/progs/test_custom_sec_handlers.c      |  51 +++
 5 files changed, 480 insertions(+), 89 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/custom_sec_handlers.c
 create mode 100644 tools/testing/selftests/bpf/progs/test_custom_sec_handlers.c