netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] bpf: add show_fdinfo handler for maps
@ 2015-11-19 10:56 Daniel Borkmann
  2015-11-19 17:42 ` Alexei Starovoitov
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Daniel Borkmann @ 2015-11-19 10:56 UTC (permalink / raw)
  To: davem; +Cc: alexei.starovoitov, netdev, Daniel Borkmann

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>
---
 kernel/bpf/syscall.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 0d3313d..6d1407b 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -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)
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2015-11-23 19:18 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-19 10:56 [PATCH net-next] bpf: add show_fdinfo handler for maps Daniel Borkmann
2015-11-19 17:42 ` Alexei Starovoitov
2015-11-19 18:19 ` Hannes Frederic Sowa
2015-11-19 18:32   ` Alexei Starovoitov
2015-11-19 20:12     ` Hannes Frederic Sowa
2015-11-20  3:30       ` Alexei Starovoitov
2015-11-20 10:30         ` Hannes Frederic Sowa
2015-11-21 23:18           ` Alexei Starovoitov
2015-11-23 16:11             ` Hannes Frederic Sowa
2015-11-23 18:03               ` Alexei Starovoitov
2015-11-23 19:09                 ` John Fastabend
2015-11-23 19:12                   ` Hannes Frederic Sowa
2015-11-23 19:18                     ` John Fastabend
2015-11-19 18:36   ` Daniel Borkmann
2015-11-19 18:45     ` Alexei Starovoitov
2015-11-20 16:04 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).