diff options
author | Daniel Borkmann <daniel@iogearbox.net> | 2015-11-19 05:56:22 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-11-20 11:04:15 -0500 |
commit | f99bf205dab026ef434520198af2fcb7dae0efdb (patch) | |
tree | 8cb3f0004875ebb38f404b1297bcc79e2ba6400e /kernel/bpf/syscall.c | |
parent | 7b5dc0dd59a8e5cf837c941ab10a565dcca76603 (diff) |
bpf: add show_fdinfo handler for maps
Add a handler for show_fdinfo() to be used by the anon-inodes
backend for eBPF maps, and dump the map specification there. Not
only useful for admins, but also it provides a minimal way to
compare specs from ELF vs pinned object.
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'kernel/bpf/syscall.c')
-rw-r--r-- | kernel/bpf/syscall.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index 0d3313d02a7e..6d1407bc1531 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c | |||
@@ -93,6 +93,23 @@ void bpf_map_put(struct bpf_map *map) | |||
93 | } | 93 | } |
94 | } | 94 | } |
95 | 95 | ||
96 | #ifdef CONFIG_PROC_FS | ||
97 | static void bpf_map_show_fdinfo(struct seq_file *m, struct file *filp) | ||
98 | { | ||
99 | const struct bpf_map *map = filp->private_data; | ||
100 | |||
101 | seq_printf(m, | ||
102 | "map_type:\t%u\n" | ||
103 | "key_size:\t%u\n" | ||
104 | "value_size:\t%u\n" | ||
105 | "max_entries:\t%u\n", | ||
106 | map->map_type, | ||
107 | map->key_size, | ||
108 | map->value_size, | ||
109 | map->max_entries); | ||
110 | } | ||
111 | #endif | ||
112 | |||
96 | static int bpf_map_release(struct inode *inode, struct file *filp) | 113 | static int bpf_map_release(struct inode *inode, struct file *filp) |
97 | { | 114 | { |
98 | struct bpf_map *map = filp->private_data; | 115 | struct bpf_map *map = filp->private_data; |
@@ -108,7 +125,10 @@ static int bpf_map_release(struct inode *inode, struct file *filp) | |||
108 | } | 125 | } |
109 | 126 | ||
110 | static const struct file_operations bpf_map_fops = { | 127 | static const struct file_operations bpf_map_fops = { |
111 | .release = bpf_map_release, | 128 | #ifdef CONFIG_PROC_FS |
129 | .show_fdinfo = bpf_map_show_fdinfo, | ||
130 | #endif | ||
131 | .release = bpf_map_release, | ||
112 | }; | 132 | }; |
113 | 133 | ||
114 | int bpf_map_new_fd(struct bpf_map *map) | 134 | int bpf_map_new_fd(struct bpf_map *map) |