Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools/bpftool: show btf_id in map listing

Let's print btf id of map similar to the way we are printing it
for programs.

Sample output:
user@test# bpftool map -f
61: lpm_trie flags 0x1
key 20B value 8B max_entries 1 memlock 4096B
133: array name test_btf_id flags 0x0
key 4B value 4B max_entries 4 memlock 4096B
pinned /sys/fs/bpf/test100
btf_id 174
170: array name test_btf_id flags 0x0
key 4B value 4B max_entries 4 memlock 4096B
btf_id 240

Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Acked-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

authored by

Prashant Bhole and committed by
Alexei Starovoitov
d1b7725d d459b59e

+6
+6
tools/bpf/bpftool/map.c
··· 531 531 } 532 532 close(fd); 533 533 534 + if (info->btf_id) 535 + jsonw_int_field(json_wtr, "btf_id", info->btf_id); 536 + 534 537 if (!hash_empty(map_table.table)) { 535 538 struct pinned_obj *obj; 536 539 ··· 608 605 printf("\n\tpinned %s", obj->path); 609 606 } 610 607 } 608 + 609 + if (info->btf_id) 610 + printf("\n\tbtf_id %d", info->btf_id); 611 611 612 612 printf("\n"); 613 613 return 0;