Skip to content

Commit 4316b40

Browse files
borkmannAlexei Starovoitov
authored andcommitted
bpf: show prog and map id in fdinfo
Its trivial and straight forward to expose it for scripts that can then use it along with bpftool in order to inspect an individual application's used maps and progs. Right now we dump some basic information in the fdinfo file but with the help of the map/prog id full introspection becomes possible now. Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Song Liu <songliubraving@fb.com> Acked-by: Jesper Dangaard Brouer <brouer@redhat.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
1 parent 3fe2867 commit 4316b40

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

kernel/bpf/syscall.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,13 +327,15 @@ static void bpf_map_show_fdinfo(struct seq_file *m, struct file *filp)
327327
"value_size:\t%u\n"
328328
"max_entries:\t%u\n"
329329
"map_flags:\t%#x\n"
330-
"memlock:\t%llu\n",
330+
"memlock:\t%llu\n"
331+
"map_id:\t%u\n",
331332
map->map_type,
332333
map->key_size,
333334
map->value_size,
334335
map->max_entries,
335336
map->map_flags,
336-
map->pages * 1ULL << PAGE_SHIFT);
337+
map->pages * 1ULL << PAGE_SHIFT,
338+
map->id);
337339

338340
if (owner_prog_type) {
339341
seq_printf(m, "owner_prog_type:\t%u\n",
@@ -1070,11 +1072,13 @@ static void bpf_prog_show_fdinfo(struct seq_file *m, struct file *filp)
10701072
"prog_type:\t%u\n"
10711073
"prog_jited:\t%u\n"
10721074
"prog_tag:\t%s\n"
1073-
"memlock:\t%llu\n",
1075+
"memlock:\t%llu\n"
1076+
"prog_id:\t%u\n",
10741077
prog->type,
10751078
prog->jited,
10761079
prog_tag,
1077-
prog->pages * 1ULL << PAGE_SHIFT);
1080+
prog->pages * 1ULL << PAGE_SHIFT,
1081+
prog->aux->id);
10781082
}
10791083
#endif
10801084

0 commit comments

Comments
 (0)