diff options
author | Jesper Dangaard Brouer | 2017-05-02 07:32:06 -0500 |
---|---|---|
committer | David S. Miller | 2017-05-03 08:30:24 -0500 |
commit | 9178b4c17d1b8b21738771d53d999c990e69f538 (patch) | |
tree | 31ee4d76035341b8cbab10e224651afb7cc4f53f /samples | |
parent | 6979bcc731f9680824a85a9efc43f36d01cec1b2 (diff) | |
download | kernel-9178b4c17d1b8b21738771d53d999c990e69f538.tar.gz kernel-9178b4c17d1b8b21738771d53d999c990e69f538.tar.xz kernel-9178b4c17d1b8b21738771d53d999c990e69f538.zip |
samples/bpf: export map_data[] for more info on maps
Giving *_user.c side tools access to map_data[] provides easier
access to information on the maps being loaded. Still provide
the guarantee that the order maps are being defined in inside the
_kern.c file corresponds with the order in the array. Now user
tools are not blind, but can inspect and verify the maps that got
loaded from the ELF binary.
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'samples')
-rw-r--r-- | samples/bpf/bpf_load.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/samples/bpf/bpf_load.h b/samples/bpf/bpf_load.h index 4d4fd4678a64..ca0563d04744 100644 --- a/samples/bpf/bpf_load.h +++ b/samples/bpf/bpf_load.h | |||
@@ -24,12 +24,18 @@ struct bpf_map_data { | |||
24 | 24 | ||
25 | typedef void (*fixup_map_cb)(struct bpf_map_data *map, int idx); | 25 | typedef void (*fixup_map_cb)(struct bpf_map_data *map, int idx); |
26 | 26 | ||
27 | extern int map_fd[MAX_MAPS]; | ||
28 | extern int prog_fd[MAX_PROGS]; | 27 | extern int prog_fd[MAX_PROGS]; |
29 | extern int event_fd[MAX_PROGS]; | 28 | extern int event_fd[MAX_PROGS]; |
30 | extern char bpf_log_buf[BPF_LOG_BUF_SIZE]; | 29 | extern char bpf_log_buf[BPF_LOG_BUF_SIZE]; |
31 | extern int prog_cnt; | 30 | extern int prog_cnt; |
32 | 31 | ||
32 | /* There is a one-to-one mapping between map_fd[] and map_data[]. | ||
33 | * The map_data[] just contains more rich info on the given map. | ||
34 | */ | ||
35 | extern int map_fd[MAX_MAPS]; | ||
36 | extern struct bpf_map_data map_data[MAX_MAPS]; | ||
37 | extern int map_data_count; | ||
38 | |||
33 | /* parses elf file compiled by llvm .c->.o | 39 | /* parses elf file compiled by llvm .c->.o |
34 | * . parses 'maps' section and creates maps via BPF syscall | 40 | * . parses 'maps' section and creates maps via BPF syscall |
35 | * . parses 'license' section and passes it to syscall | 41 | * . parses 'license' section and passes it to syscall |