This patchset introduces the bpf_prog ID and a new bpf cmd to iterate all bpf_prog in the system.
It is still incomplete. The idea can be extended to bpf_map. Martin KaFai Lau (2): bpf: Introduce bpf_prog ID bpf: Test for bpf_prog ID and BPF_PROG_GET_NEXT_ID include/linux/filter.h | 1 + include/uapi/linux/bpf.h | 6 ++ kernel/bpf/syscall.c | 47 ++++++++++++++- tools/include/uapi/linux/bpf.h | 6 ++ tools/lib/bpf/bpf.c | 11 ++++ tools/lib/bpf/bpf.h | 1 + tools/testing/selftests/bpf/Makefile | 2 +- tools/testing/selftests/bpf/test_prog_id.c | 93 ++++++++++++++++++++++++++++++ 8 files changed, 165 insertions(+), 2 deletions(-) create mode 100644 tools/testing/selftests/bpf/test_prog_id.c -- 2.9.3