Skip to content

Commit d1b7725

Browse files
pbholeAlexei Starovoitov
authored andcommitted
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>
1 parent d459b59 commit d1b7725

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎tools/bpf/bpftool/map.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,9 @@ static int show_map_close_json(int fd, struct bpf_map_info *info)
531531
}
532532
close(fd);
533533

534+
if (info->btf_id)
535+
jsonw_int_field(json_wtr, "btf_id", info->btf_id);
536+
534537
if (!hash_empty(map_table.table)) {
535538
struct pinned_obj *obj;
536539

@@ -606,6 +609,9 @@ static int show_map_close_plain(int fd, struct bpf_map_info *info)
606609
}
607610
}
608611

612+
if (info->btf_id)
613+
printf("\n\tbtf_id %d", info->btf_id);
614+
609615
printf("\n");
610616
return 0;
611617
}

0 commit comments

Comments
 (0)