提交 f99bf205 编写于 作者: D Daniel Borkmann 提交者: David S. Miller

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: NDaniel Borkmann <daniel@iogearbox.net>
Acked-by: NAlexei Starovoitov <ast@kernel.org>
Acked-by: NHannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 7b5dc0dd
......@@ -93,6 +93,23 @@ void bpf_map_put(struct bpf_map *map)
}
}
#ifdef CONFIG_PROC_FS
static void bpf_map_show_fdinfo(struct seq_file *m, struct file *filp)
{
const struct bpf_map *map = filp->private_data;
seq_printf(m,
"map_type:\t%u\n"
"key_size:\t%u\n"
"value_size:\t%u\n"
"max_entries:\t%u\n",
map->map_type,
map->key_size,
map->value_size,
map->max_entries);
}
#endif
static int bpf_map_release(struct inode *inode, struct file *filp)
{
struct bpf_map *map = filp->private_data;
......@@ -108,7 +125,10 @@ static int bpf_map_release(struct inode *inode, struct file *filp)
}
static const struct file_operations bpf_map_fops = {
.release = bpf_map_release,
#ifdef CONFIG_PROC_FS
.show_fdinfo = bpf_map_show_fdinfo,
#endif
.release = bpf_map_release,
};
int bpf_map_new_fd(struct bpf_map *map)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册