Skip to content

Add new-style bpf_object__open APIs

Andrii Nakryiko bpf netdev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 7 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2libbpf: stop enforcing kern_version, populate it for userstools/lib/bpf/libbpf.c tools/lib/bpf/libbpf.h tools/testing/selftests/bpf/progs/test_attach_probe.c +3 more+22 -637 replies
2/2libbpf: add bpf_object__open_{file,mem} w/ extensible optstools/lib/bpf/libbpf.c tools/lib/bpf/libbpf.h tools/lib/bpf/libbpf.map +1 more+110 -100 replies

Reviews trailers per patch

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

Read the v1 thread

Cover letter [PATCH bpf-next 0/2] Add new-style bpf_object__open APIs

Add bpf_object__open_file() and bpf_object__open_mem() APIs that use a new approach to providing future-proof non-ABI-breaking API changes. It relies on APIs accepting optional self-describing "opts" struct, containing its own size, filled out and provided by potentially outdated (as well as newer-than-libbpf) user application. A set of internal helper macros (OPTS_VALID, OPTS_HAS, and OPTS_GET) streamline and simplify a graceful handling forward and backward compatibility for user applications dynamically linked against different versions of libbpf shared library.

Users of libbpf are provided with convenience macro LIBBPF_OPTS that takes care of populating correct structure size and zero-initializes options struct, which helps avoid obscure issues of unitialized padding. Uninitialized padding in a struct might turn into garbage-populated new fields understood by future versions of libbpf.

Andrii Nakryiko (2):
libbpf: stop enforcing kern_version, populate it for users
libbpf: add bpf_object__open_{file,mem} w/ extensible opts

 tools/lib/bpf/libbpf.c                        | 128 +++++++++---------
 tools/lib/bpf/libbpf.h                        |  37 ++++-
 tools/lib/bpf/libbpf.map                      |   3 +
 tools/lib/bpf/libbpf_internal.h               |  31 +++++
 .../selftests/bpf/progs/test_attach_probe.c   |   1 -
 .../bpf/progs/test_get_stack_rawtp.c          |   1 -
 .../selftests/bpf/progs/test_perf_buffer.c    |   1 -
 .../selftests/bpf/progs/test_stacktrace_map.c |   1 -
 8 files changed, 131 insertions(+), 72 deletions(-)
Signature · 1 line
2.17.1