diff options
author | Wang Nan <wangnan0@huawei.com> | 2016-11-26 02:03:27 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-11-29 10:10:19 -0500 |
commit | 5a6acad17d2e81765dd4c2fce7346a6f045eab25 (patch) | |
tree | c5ee94f9aec5b8ac2d1b09e7e1b8b28f927a1204 /tools/lib/bpf/libbpf.h | |
parent | 10931d2413478239bdceac5546cce85d7a497a4e (diff) |
tools lib bpf: Retrive bpf_map through offset of bpf_map_def
Add a new API to libbpf, caller is able to get bpf_map through the
offset of bpf_map_def to 'maps' section.
The API will be used to help jitted perf hook code find fd of a map.
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Joe Stringer <joe@ovn.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/20161126070354.141764-4-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/lib/bpf/libbpf.h')
-rw-r--r-- | tools/lib/bpf/libbpf.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h index 0c0b0127e03e..a5a8b86a06fe 100644 --- a/tools/lib/bpf/libbpf.h +++ b/tools/lib/bpf/libbpf.h | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <stdio.h> | 24 | #include <stdio.h> |
25 | #include <stdbool.h> | 25 | #include <stdbool.h> |
26 | #include <linux/err.h> | 26 | #include <linux/err.h> |
27 | #include <sys/types.h> // for size_t | ||
27 | 28 | ||
28 | enum libbpf_errno { | 29 | enum libbpf_errno { |
29 | __LIBBPF_ERRNO__START = 4000, | 30 | __LIBBPF_ERRNO__START = 4000, |
@@ -200,6 +201,13 @@ struct bpf_map; | |||
200 | struct bpf_map * | 201 | struct bpf_map * |
201 | bpf_object__find_map_by_name(struct bpf_object *obj, const char *name); | 202 | bpf_object__find_map_by_name(struct bpf_object *obj, const char *name); |
202 | 203 | ||
204 | /* | ||
205 | * Get bpf_map through the offset of corresponding struct bpf_map_def | ||
206 | * in the bpf object file. | ||
207 | */ | ||
208 | struct bpf_map * | ||
209 | bpf_object__find_map_by_offset(struct bpf_object *obj, size_t offset); | ||
210 | |||
203 | struct bpf_map * | 211 | struct bpf_map * |
204 | bpf_map__next(struct bpf_map *map, struct bpf_object *obj); | 212 | bpf_map__next(struct bpf_map *map, struct bpf_object *obj); |
205 | #define bpf_map__for_each(pos, obj) \ | 213 | #define bpf_map__for_each(pos, obj) \ |