BPF List
 help / color / mirror / Atom feed
From: "Maciej Żenczykowski" <zenczykowski@gmail.com>
To: "Maciej Żenczykowski" <maze@google.com>,
	"Alexei Starovoitov" <ast@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>
Cc: Linux Network Development Mailing List <netdev@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	BPF Mailing List <bpf@vger.kernel.org>,
	"David S . Miller" <davem@davemloft.net>
Subject: [PATCH bpf-next] bpf: print a little more info about maps via cat /sys/fs/bpf/pinned_name
Date: Sat, 21 May 2022 00:57:36 -0700	[thread overview]
Message-ID: <20220521075736.1225397-1-zenczykowski@gmail.com> (raw)

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


             reply	other threads:[~2022-05-21  7:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-21  7:57 Maciej Żenczykowski [this message]
2022-05-23 19:32 ` [PATCH bpf-next] bpf: print a little more info about maps via cat /sys/fs/bpf/pinned_name 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220521075736.1225397-1-zenczykowski@gmail.com \
    --to=zenczykowski@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maze@google.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox