]> git.ipfire.org Git - thirdparty/systemd.git/commit
bpf-util: rename from bpf-dlopen, unify version-specific symbol handling
authorDaan De Meyer <daan@amutable.com>
Thu, 14 May 2026 17:13:06 +0000 (17:13 +0000)
committerDaan De Meyer <daan@amutable.com>
Mon, 18 May 2026 21:17:38 +0000 (21:17 +0000)
commit7d822ca8afc52f9dd9e32b83b275bf9f1abaa838
treef0f37c0e466945b6dec69f2bba33ea8c5ee35b55
parentaa0f03eb0334dc1b8dc7a3d122be7e004dc71a8e
bpf-util: rename from bpf-dlopen, unify version-specific symbol handling

Renames src/shared/bpf-dlopen.{c,h} to src/shared/bpf-util.{c,h} and
folds the former src/shared/bpf-compat.h (struct forward decl and
compat_bpf_map_create() helper) into the new header.

Aligns dlopen_bpf() with the standard wrapper pattern: drops the
manual dlopen_safe()/dlsym_many_or_warn()/TAKE_PTR(dl) plumbing and
the bespoke 'cached' int in favor of dlopen_many_sym_or_warn() inside
a FOREACH_STRING() soname-fallback loop.

Unifies declaration of the version-specific symbols (bpf_create_map,
bpf_map_create, bpf_object__next_map, bpf_token_create) into a single
DISABLE_WARNING_REDUNDANT_DECLS block in the header, and alphabetically
merges the DLSYM_PROTOTYPE list. DLSYM_OPTIONAL is used to load each
one — call sites already handle NULL (compat_bpf_map_create() and the
sym_bpf_object__next_map guard in userns-restrict.c). bpf_token_create
additionally defaults to a missing_bpf_token_create() stub returning
-ENOSYS, so callers can branch on the errno instead of NULL-checking
the pointer.

Updates test-bpf-token to match: drops the compile-time
LIBBPF_MAJOR_VERSION ≥ 1.5 gate and the direct <bpf/bpf.h> include in
favor of dlopen_bpf() + sym_bpf_token_create(), and treats -ENOSYS as
the test-skip path (covering both 'libbpf too old' and 'kernel lacks
BPF_TOKEN_CREATE support').
21 files changed:
src/bpf/bpf-skel-wrapper.h.in
src/bpf/meson.build
src/core/bpf-bind-iface.c
src/core/bpf-restrict-fs.c
src/core/bpf-restrict-fsaccess.c
src/core/bpf-restrict-ifaces.c
src/core/bpf-socket-bind.c
src/core/exec-invoke.c
src/network/networkd-sysctl.c
src/nsresourced/nsresourced-manager.c
src/nsresourced/userns-restrict.c
src/shared/bpf-compat.h [deleted file]
src/shared/bpf-dlopen.c [deleted file]
src/shared/bpf-link.c
src/shared/bpf-util.c [new file with mode: 0644]
src/shared/bpf-util.h [moved from src/shared/bpf-dlopen.h with 52% similarity]
src/shared/meson.build
src/test/meson.build
src/test/test-bpf-restrict-fsaccess.c
src/test/test-bpf-token.c
src/test/test-dlopen-so.c