diff mbox series

bpf: bpftool: fix print error when show bpf map

Message ID 20220320060815.7716-1-laoar.shao@gmail.com (mailing list archive)
State Accepted
Commit 1824d8ea75f275a5e69e5f6bc0ffe122ea9b938c
Delegated to: BPF
Headers show
Series bpf: bpftool: fix print error when show bpf map | expand

Checks

Context Check Description
bpf/vmtest-bpf-next-PR fail PR summary
netdev/tree_selection success Not a local patch

Commit Message

Yafang Shao March 20, 2022, 6:08 a.m. UTC
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: 9330986c0300 ("bpf: Add bloom filter map implementation")
Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
Cc: Joanne Koong <joannekoong@fb.com>
---
 tools/bpf/bpftool/map.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org March 21, 2022, 3:20 p.m. UTC | #1
Hello:

This patch was applied to bpf/bpf-next.git (master)
by Daniel Borkmann <daniel@iogearbox.net>:

On Sun, 20 Mar 2022 06:08:14 +0000 you wrote:
> 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)
> 
> [...]

Here is the summary with links:
  - bpf: bpftool: fix print error when show bpf map
    https://git.kernel.org/bpf/bpf-next/c/1824d8ea75f2

You are awesome, thank you!
diff mbox series

Patch

diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c
index f91d9bf9054e..c26378f20831 100644
--- a/tools/bpf/bpftool/map.c
+++ b/tools/bpf/bpftool/map.c
@@ -620,17 +620,14 @@  static int show_map_close_plain(int fd, struct bpf_map_info *info)
 					    u32_as_hash_field(info->id))
 			printf("\n\tpinned %s", (char *)entry->value);
 	}
-	printf("\n");
 
 	if (frozen_str) {
 		frozen = atoi(frozen_str);
 		free(frozen_str);
 	}
 
-	if (!info->btf_id && !frozen)
-		return 0;
-
-	printf("\t");
+	if (info->btf_id || frozen)
+		printf("\n\t");
 
 	if (info->btf_id)
 		printf("btf_id %d", info->btf_id);