diff options
author | Martin KaFai Lau <kafai@fb.com> | 2018-04-18 18:56:05 -0400 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2018-04-19 15:46:25 -0400 |
commit | 8a138aed4a807ceb143882fb23a423d524dcdb35 (patch) | |
tree | 27dcccc69aefb72be5e5bb615847173c0eb290d7 /tools/lib/bpf/bpf.h | |
parent | 3bd86a8409fc5a87ea415087b0c30ab42818e7c8 (diff) |
bpf: btf: Add BTF support to libbpf
If the ".BTF" elf section exists, libbpf will try to create
a btf_fd (through BPF_BTF_LOAD). If that fails, it will still
continue loading the bpf prog/map without the BTF.
If the bpf_object has a BTF loaded, it will create a map with the btf_fd.
libbpf will try to figure out the btf_key_id and btf_value_id of a map by
finding the BTF type with name "<map_name>_key" and "<map_name>_value".
If they cannot be found, it will continue without using the BTF.
Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Acked-by: Alexei Starovoitov <ast@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'tools/lib/bpf/bpf.h')
-rw-r--r-- | tools/lib/bpf/bpf.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tools/lib/bpf/bpf.h b/tools/lib/bpf/bpf.h index 39f6a0d64a3b..01bda076310f 100644 --- a/tools/lib/bpf/bpf.h +++ b/tools/lib/bpf/bpf.h | |||
@@ -26,6 +26,20 @@ | |||
26 | #include <linux/bpf.h> | 26 | #include <linux/bpf.h> |
27 | #include <stddef.h> | 27 | #include <stddef.h> |
28 | 28 | ||
29 | struct bpf_create_map_attr { | ||
30 | const char *name; | ||
31 | enum bpf_map_type map_type; | ||
32 | __u32 map_flags; | ||
33 | __u32 key_size; | ||
34 | __u32 value_size; | ||
35 | __u32 max_entries; | ||
36 | __u32 numa_node; | ||
37 | __u32 btf_fd; | ||
38 | __u32 btf_key_id; | ||
39 | __u32 btf_value_id; | ||
40 | }; | ||
41 | |||
42 | int bpf_create_map_xattr(const struct bpf_create_map_attr *create_attr); | ||
29 | int bpf_create_map_node(enum bpf_map_type map_type, const char *name, | 43 | int bpf_create_map_node(enum bpf_map_type map_type, const char *name, |
30 | int key_size, int value_size, int max_entries, | 44 | int key_size, int value_size, int max_entries, |
31 | __u32 map_flags, int node); | 45 | __u32 map_flags, int node); |
@@ -87,4 +101,6 @@ int bpf_obj_get_info_by_fd(int prog_fd, void *info, __u32 *info_len); | |||
87 | int bpf_prog_query(int target_fd, enum bpf_attach_type type, __u32 query_flags, | 101 | int bpf_prog_query(int target_fd, enum bpf_attach_type type, __u32 query_flags, |
88 | __u32 *attach_flags, __u32 *prog_ids, __u32 *prog_cnt); | 102 | __u32 *attach_flags, __u32 *prog_ids, __u32 *prog_cnt); |
89 | int bpf_raw_tracepoint_open(const char *name, int prog_fd); | 103 | int bpf_raw_tracepoint_open(const char *name, int prog_fd); |
104 | int bpf_load_btf(void *btf, __u32 btf_size, char *log_buf, __u32 log_buf_size, | ||
105 | bool do_log); | ||
90 | #endif | 106 | #endif |