linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next] bpf: print a little more info about maps via cat /sys/fs/bpf/pinned_name
@ 2022-05-21  7:57 Maciej Żenczykowski
  2022-05-23 19:32 ` Alexei Starovoitov
  0 siblings, 1 reply; 6+ messages in thread
From: Maciej Żenczykowski @ 2022-05-21  7:57 UTC (permalink / raw)
  To: Maciej Żenczykowski, Alexei Starovoitov, Daniel Borkmann
  Cc: Linux Network Development Mailing List,
	Linux Kernel Mailing List, BPF Mailing List, David S . Miller

From: Maciej Żenczykowski <maze@google.com>

While this information can be fetched via bpftool,
the cli tool itself isn't always available on more limited systems.

From the information printed particularly the 'id' is useful since
when combined with /proc/pid/fd/X and /proc/pid/fdinfo/X it allows
tracking down which bpf maps a process has open (which can be
useful for tracking down fd leaks).

Signed-off-by: Maciej Żenczykowski <maze@google.com>
---
 kernel/bpf/inode.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c
index 4f841e16779e..784266e258fe 100644
--- a/kernel/bpf/inode.c
+++ b/kernel/bpf/inode.c
@@ -257,6 +257,9 @@ static int map_seq_show(struct seq_file *m, void *v)
 	if (unlikely(v == SEQ_START_TOKEN)) {
 		seq_puts(m, "# WARNING!! The output is for debug purpose only\n");
 		seq_puts(m, "# WARNING!! The output format will change\n");
+		seq_printf(m, "# type: %d, key_size: %d, value_size: %d, max_entries: %d, id: %d\n",
+			   map->map_type, map->key_size, map->value_size, map->max_entries,
+			   map->id);
 	} else {
 		map->ops->map_seq_show_elem(map, key, m);
 	}
-- 
2.36.1.124.g0e6072fb45-goog


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

end of thread, other threads:[~2022-05-25 16:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-21  7:57 [PATCH bpf-next] bpf: print a little more info about maps via cat /sys/fs/bpf/pinned_name Maciej Żenczykowski
2022-05-23 19:32 ` Alexei Starovoitov
2022-05-23 20:14   ` Maciej Żenczykowski
2022-05-23 20:21     ` Alexei Starovoitov
2022-05-25 16:14       ` Maciej Żenczykowski
2022-05-25 16:32         ` Alexei Starovoitov

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).