Skip to content

Provide bpf_for() and bpf_for_each() by libbpf

Andrii Nakryiko bpf 1 version Applied

Status from this message: This series was applied to bpf/bpf-next.git (master)

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest6 patches 4 repliesApplied 6/6

Patches in v1 All 6 applied

#Subject and filesSizeRepliesApplied
1/6libbpf: misc internal libbpf clean ups around log fixuptools/lib/bpf/libbpf.c+14 -120 repliesApplied
2/6libbpf: report vmlinux vs module name when dealing with ksymstools/lib/bpf/libbpf.c+5 -40 repliesApplied
3/6libbpf: improve handling of unresolved kfuncstools/lib/bpf/libbpf.c+69 -34 repliesApplied
4/6selftests/bpf: add missing __weak kfunc log fixup testtools/testing/selftests/bpf/prog_tests/log_fixup.c tools/testing/selftests/bpf/progs/test_log_fixup.c+41 -00 repliesApplied
5/6libbpf: move bpf_for(), bpf_for_each(), and bpf_repeat() into bpf_helpers.htools/lib/bpf/bpf_helpers.h tools/testing/selftests/bpf/progs/bpf_misc.h+103 -1030 repliesApplied
6/6libbpf: mark bpf_iter_num_{new,next,destroy} as __weaktools/lib/bpf/bpf_helpers.h+3 -30 repliesApplied

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/6] Provide bpf_for() and bpf_for_each() by libbpf

This patch set moves bpf_for(), bpf_for_each(), and bpf_repeat() macros from selftests-internal bpf_misc.h header to libbpf-provided bpf_helpers.h header. To do this in a way to allow users to feature-detect and guard such bpf_for()/bpf_for_each() uses on old kernels we also extend libbpf to improve unresolved kfunc calls handling and reporting. This lets us mark bpf_iter_num_{new,next,destroy}() declarations as __weak, and thus not fail program loading outright if such kfuncs are missing on the host kernel.

Patches #1 and #2 do some simple clean ups and logging improvements. Patch #3 adds kfunc call poisoning and log fixup logic and is the hear of this patch set, effectively. Patch #4 adds selftest for this logic. Patches #4 and #5 move bpf_for()/bpf_for_each()/bpf_repeat() into bpf_helpers.h header and mark kfuncs as __weak to allow users to feature-detect and guard their uses.

Andrii Nakryiko (6):
libbpf: misc internal libbpf clean ups around log fixup
libbpf: report vmlinux vs module name when dealing with ksyms
libbpf: improve handling of unresolved kfuncs selftests/bpf: add missing __weak kfunc log fixup test
libbpf: move bpf_for(), bpf_for_each(), and bpf_repeat() into
bpf_helpers.h
libbpf: mark bpf_iter_num_{new,next,destroy} as __weak

 tools/lib/bpf/bpf_helpers.h                   | 103 +++++++++++++++++
 tools/lib/bpf/libbpf.c                        | 107 ++++++++++++++----
 .../selftests/bpf/prog_tests/log_fixup.c      |  31 +++++
 tools/testing/selftests/bpf/progs/bpf_misc.h  | 103 -----------------
 .../selftests/bpf/progs/test_log_fixup.c      |  10 ++
 5 files changed, 232 insertions(+), 122 deletions(-)
Signature · 1 line
2.34.1