Skip to content

Commit af7771a

Browse files
laoarNobody
authored and
Nobody
committed
bpf: bpftool: fix print error when show bpf map
If there is no btf_id or frozen, it will not show the pids, but the pids doesn't depends on any one of them. Below is the result after this change, $ ./bpftool map show 2: lpm_trie flags 0x1 key 8B value 8B max_entries 1 memlock 4096B pids systemd(1) 3: lpm_trie flags 0x1 key 20B value 8B max_entries 1 memlock 4096B pids systemd(1) While before this change, the 'pids systemd(1)' can't be displayed. Fixes: 9330986 ("bpf: Add bloom filter map implementation") Signed-off-by: Yafang Shao <[email protected]> Cc: Joanne Koong <[email protected]>
1 parent 318a892 commit af7771a

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

tools/bpf/bpftool/map.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -620,17 +620,14 @@ static int show_map_close_plain(int fd, struct bpf_map_info *info)
620620
u32_as_hash_field(info->id))
621621
printf("\n\tpinned %s", (char *)entry->value);
622622
}
623-
printf("\n");
624623

625624
if (frozen_str) {
626625
frozen = atoi(frozen_str);
627626
free(frozen_str);
628627
}
629628

630-
if (!info->btf_id && !frozen)
631-
return 0;
632-
633-
printf("\t");
629+
if (info->btf_id || frozen)
630+
printf("\n\t");
634631

635632
if (info->btf_id)
636633
printf("btf_id %d", info->btf_id);

0 commit comments

Comments
 (0)