aboutsummaryrefslogtreecommitdiffstats
path: root/tools/lib/bpf/libbpf.h
diff options
context:
space:
mode:
authorMaciej Fijalkowski <[email protected]>2019-02-01 21:42:23 +0000
committerDaniel Borkmann <[email protected]>2019-02-01 22:37:50 +0000
commitf3cea32d56e96c510af454616104e3979f7626dd (patch)
treec533d2064965a7f1071d14b53105e591cbb24867 /tools/lib/bpf/libbpf.h
parentbpf: powerpc64: add JIT support for bpf line info (diff)
downloadkernel-f3cea32d56e96c510af454616104e3979f7626dd.tar.gz
kernel-f3cea32d56e96c510af454616104e3979f7626dd.zip
libbpf: Add a helper for retrieving a map fd for a given name
XDP samples are mostly cooperating with eBPF maps through their file descriptors. In case of a eBPF program that contains multiple maps it might be tiresome to iterate through them and call bpf_map__fd for each one. Add a helper mostly based on bpf_object__find_map_by_name, but instead of returning the struct bpf_map pointer, return map fd. Suggested-by: Jakub Kicinski <[email protected]> Signed-off-by: Maciej Fijalkowski <[email protected]> Reviewed-by: Jakub Kicinski <[email protected]> Acked-by: John Fastabend <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]>
Diffstat (limited to 'tools/lib/bpf/libbpf.h')
-rw-r--r--tools/lib/bpf/libbpf.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
index 62ae6cb93da1..931be6f3408c 100644
--- a/tools/lib/bpf/libbpf.h
+++ b/tools/lib/bpf/libbpf.h
@@ -264,6 +264,9 @@ struct bpf_map;
LIBBPF_API struct bpf_map *
bpf_object__find_map_by_name(struct bpf_object *obj, const char *name);
+LIBBPF_API int
+bpf_object__find_map_fd_by_name(struct bpf_object *obj, const char *name);
+
/*
* Get bpf_map through the offset of corresponding struct bpf_map_def
* in the BPF object file.