Commit 1824d8ea authored by Yafang Shao's avatar Yafang Shao Committed by Daniel Borkmann

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 don't
depend 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: 9330986c ("bpf: Add bloom filter map implementation")
Signed-off-by: default avatarYafang Shao <laoar.shao@gmail.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20220320060815.7716-1-laoar.shao@gmail.com
parent f7098690
...@@ -620,17 +620,14 @@ static int show_map_close_plain(int fd, struct bpf_map_info *info) ...@@ -620,17 +620,14 @@ static int show_map_close_plain(int fd, struct bpf_map_info *info)
u32_as_hash_field(info->id)) u32_as_hash_field(info->id))
printf("\n\tpinned %s", (char *)entry->value); printf("\n\tpinned %s", (char *)entry->value);
} }
printf("\n");
if (frozen_str) { if (frozen_str) {
frozen = atoi(frozen_str); frozen = atoi(frozen_str);
free(frozen_str); free(frozen_str);
} }
if (!info->btf_id && !frozen) if (info->btf_id || frozen)
return 0; printf("\n\t");
printf("\t");
if (info->btf_id) if (info->btf_id)
printf("btf_id %d", info->btf_id); printf("btf_id %d", info->btf_id);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment