BPF List
 help / color / mirror / Atom feed
* [PATCH] bpf: bpftool: fix print error when show bpf map
@ 2022-03-20  6:08 Yafang Shao
  2022-03-20  6:08 ` [PATCH] bpf: selftests: cleanup RLIMIT_MEMLOCK Yafang Shao
  2022-03-21 15:20 ` [PATCH] bpf: bpftool: fix print error when show bpf map patchwork-bot+netdevbpf
  0 siblings, 2 replies; 8+ messages in thread
From: Yafang Shao @ 2022-03-20  6:08 UTC (permalink / raw)
  To: ast, daniel, andrii, kafai, songliubraving, yhs, john.fastabend,
	kpsingh
  Cc: netdev, bpf, Yafang Shao, Joanne Koong

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(-)

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);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-03-22 17:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-20  6:08 [PATCH] bpf: bpftool: fix print error when show bpf map Yafang Shao
2022-03-20  6:08 ` [PATCH] bpf: selftests: cleanup RLIMIT_MEMLOCK Yafang Shao
2022-03-20 16:58   ` Roman Gushchin
2022-03-22  0:13     ` Andrii Nakryiko
2022-03-22  2:15       ` Roman Gushchin
2022-03-22 17:24         ` Andrii Nakryiko
2022-03-22 16:13       ` Yafang Shao
2022-03-21 15:20 ` [PATCH] bpf: bpftool: fix print error when show bpf map patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox