diff options
author | Quentin Monnet <quentin.monnet@netronome.com> | 2019-08-20 05:31:53 -0400 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2019-08-20 12:51:06 -0400 |
commit | 09d7c2e32b6e06d58fe7a5aa38847f4719ab4cc7 (patch) | |
tree | 468ec4aa0449a0e88497e2ab306f567dda65f0bf | |
parent | a6e130c4203bcc73450a00f647d99bd75ded95cb (diff) |
libbpf: add bpf_btf_get_next_id() to cycle through BTF objects
Add an API function taking a BTF object id and providing the id of the
next BTF object in the kernel. This can be used to list all BTF objects
loaded on the system.
v2:
- Rebase on top of Andrii's changes regarding libbpf versioning.
Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com>
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
-rw-r--r-- | tools/lib/bpf/bpf.c | 5 | ||||
-rw-r--r-- | tools/lib/bpf/bpf.h | 1 | ||||
-rw-r--r-- | tools/lib/bpf/libbpf.map | 2 |
3 files changed, 8 insertions, 0 deletions
diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c index 1439e99c9be5..cbb933532981 100644 --- a/tools/lib/bpf/bpf.c +++ b/tools/lib/bpf/bpf.c | |||
@@ -593,6 +593,11 @@ int bpf_map_get_next_id(__u32 start_id, __u32 *next_id) | |||
593 | return bpf_obj_get_next_id(start_id, next_id, BPF_MAP_GET_NEXT_ID); | 593 | return bpf_obj_get_next_id(start_id, next_id, BPF_MAP_GET_NEXT_ID); |
594 | } | 594 | } |
595 | 595 | ||
596 | int bpf_btf_get_next_id(__u32 start_id, __u32 *next_id) | ||
597 | { | ||
598 | return bpf_obj_get_next_id(start_id, next_id, BPF_BTF_GET_NEXT_ID); | ||
599 | } | ||
600 | |||
596 | int bpf_prog_get_fd_by_id(__u32 id) | 601 | int bpf_prog_get_fd_by_id(__u32 id) |
597 | { | 602 | { |
598 | union bpf_attr attr; | 603 | union bpf_attr attr; |
diff --git a/tools/lib/bpf/bpf.h b/tools/lib/bpf/bpf.h index ff42ca043dc8..0db01334740f 100644 --- a/tools/lib/bpf/bpf.h +++ b/tools/lib/bpf/bpf.h | |||
@@ -156,6 +156,7 @@ LIBBPF_API int bpf_prog_test_run(int prog_fd, int repeat, void *data, | |||
156 | __u32 *retval, __u32 *duration); | 156 | __u32 *retval, __u32 *duration); |
157 | LIBBPF_API int bpf_prog_get_next_id(__u32 start_id, __u32 *next_id); | 157 | LIBBPF_API int bpf_prog_get_next_id(__u32 start_id, __u32 *next_id); |
158 | LIBBPF_API int bpf_map_get_next_id(__u32 start_id, __u32 *next_id); | 158 | LIBBPF_API int bpf_map_get_next_id(__u32 start_id, __u32 *next_id); |
159 | LIBBPF_API int bpf_btf_get_next_id(__u32 start_id, __u32 *next_id); | ||
159 | LIBBPF_API int bpf_prog_get_fd_by_id(__u32 id); | 160 | LIBBPF_API int bpf_prog_get_fd_by_id(__u32 id); |
160 | LIBBPF_API int bpf_map_get_fd_by_id(__u32 id); | 161 | LIBBPF_API int bpf_map_get_fd_by_id(__u32 id); |
161 | LIBBPF_API int bpf_btf_get_fd_by_id(__u32 id); | 162 | LIBBPF_API int bpf_btf_get_fd_by_id(__u32 id); |
diff --git a/tools/lib/bpf/libbpf.map b/tools/lib/bpf/libbpf.map index 4e72df8e98ba..664ce8e7a60e 100644 --- a/tools/lib/bpf/libbpf.map +++ b/tools/lib/bpf/libbpf.map | |||
@@ -186,4 +186,6 @@ LIBBPF_0.0.4 { | |||
186 | } LIBBPF_0.0.3; | 186 | } LIBBPF_0.0.3; |
187 | 187 | ||
188 | LIBBPF_0.0.5 { | 188 | LIBBPF_0.0.5 { |
189 | global: | ||
190 | bpf_btf_get_next_id; | ||
189 | } LIBBPF_0.0.4; | 191 | } LIBBPF_0.0.4; |