netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next] bpf: show in bpftool map overview whether btf is available
@ 2018-07-18  9:19 Daniel Borkmann
  2018-07-18 16:35 ` Martin KaFai Lau
  2018-07-18 18:08 ` Jakub Kicinski
  0 siblings, 2 replies; 4+ messages in thread
From: Daniel Borkmann @ 2018-07-18  9:19 UTC (permalink / raw)
  To: alexei.starovoitov; +Cc: jakub.kicinski, netdev, Daniel Borkmann

For a quick overview in 'bpftool map' display 'btf' if it's
available for the dump for a specific map:

  # bpftool map list
  11: array  flags 0x0  btf
          key 4B  value 20B  max_entries 40  memlock 4096B

  # bpftool --json --pretty map list
  [{
          "id": 11,
          "type": "array",
          "flags": 0,
          "btf_available": true,
          "bytes_key": 4,
          "bytes_value": 20,
          "max_entries": 40,
          "bytes_memlock": 4096
      }
  ]

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
---
 tools/bpf/bpftool/map.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c
index 9c81918..2cc4741 100644
--- a/tools/bpf/bpftool/map.c
+++ b/tools/bpf/bpftool/map.c
@@ -490,6 +490,8 @@ static int show_map_close_json(int fd, struct bpf_map_info *info)
 
 	jsonw_name(json_wtr, "flags");
 	jsonw_printf(json_wtr, "%d", info->map_flags);
+	jsonw_name(json_wtr, "btf_available");
+	jsonw_bool(json_wtr, info->btf_key_type_id && info->btf_value_type_id);
 
 	print_dev_json(info->ifindex, info->netns_dev, info->netns_ino);
 
@@ -535,6 +537,8 @@ static int show_map_close_plain(int fd, struct bpf_map_info *info)
 		printf("name %s  ", info->name);
 
 	printf("flags 0x%x", info->map_flags);
+	if (info->btf_key_type_id && info->btf_value_type_id)
+		printf("  btf");
 	print_dev_plain(info->ifindex, info->netns_dev, info->netns_ino);
 	printf("\n");
 	printf("\tkey %uB  value %uB  max_entries %u",
-- 
2.9.5

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

* Re: [PATCH bpf-next] bpf: show in bpftool map overview whether btf is available
  2018-07-18  9:19 [PATCH bpf-next] bpf: show in bpftool map overview whether btf is available Daniel Borkmann
@ 2018-07-18 16:35 ` Martin KaFai Lau
  2018-07-18 18:08 ` Jakub Kicinski
  1 sibling, 0 replies; 4+ messages in thread
From: Martin KaFai Lau @ 2018-07-18 16:35 UTC (permalink / raw)
  To: Daniel Borkmann; +Cc: alexei.starovoitov, jakub.kicinski, netdev

On Wed, Jul 18, 2018 at 11:19:42AM +0200, Daniel Borkmann wrote:
> For a quick overview in 'bpftool map' display 'btf' if it's
> available for the dump for a specific map:
> 
>   # bpftool map list
>   11: array  flags 0x0  btf
>           key 4B  value 20B  max_entries 40  memlock 4096B
> 
>   # bpftool --json --pretty map list
>   [{
>           "id": 11,
>           "type": "array",
>           "flags": 0,
>           "btf_available": true,
>           "bytes_key": 4,
>           "bytes_value": 20,
>           "max_entries": 40,
>           "bytes_memlock": 4096
>       }
>   ]
> 
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Martin KaFai Lau <kafai@fb.com>

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

* Re: [PATCH bpf-next] bpf: show in bpftool map overview whether btf is available
  2018-07-18  9:19 [PATCH bpf-next] bpf: show in bpftool map overview whether btf is available Daniel Borkmann
  2018-07-18 16:35 ` Martin KaFai Lau
@ 2018-07-18 18:08 ` Jakub Kicinski
  2018-07-19 15:45   ` Daniel Borkmann
  1 sibling, 1 reply; 4+ messages in thread
From: Jakub Kicinski @ 2018-07-18 18:08 UTC (permalink / raw)
  To: Daniel Borkmann; +Cc: alexei.starovoitov, netdev

On Wed, 18 Jul 2018 11:19:42 +0200, Daniel Borkmann wrote:
> For a quick overview in 'bpftool map' display 'btf' if it's
> available for the dump for a specific map:
> 
>   # bpftool map list
>   11: array  flags 0x0  btf
>           key 4B  value 20B  max_entries 40  memlock 4096B
> 
>   # bpftool --json --pretty map list
>   [{
>           "id": 11,
>           "type": "array",
>           "flags": 0,
>           "btf_available": true,
>           "bytes_key": 4,
>           "bytes_value": 20,
>           "max_entries": 40,
>           "bytes_memlock": 4096
>       }
>   ]
> 
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>

Hmm.. would it make sense to provide the actual BTF IDs instead of just
yes/no?  At least in JSON?

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

* Re: [PATCH bpf-next] bpf: show in bpftool map overview whether btf is available
  2018-07-18 18:08 ` Jakub Kicinski
@ 2018-07-19 15:45   ` Daniel Borkmann
  0 siblings, 0 replies; 4+ messages in thread
From: Daniel Borkmann @ 2018-07-19 15:45 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: alexei.starovoitov, netdev

On 07/18/2018 08:08 PM, Jakub Kicinski wrote:
> On Wed, 18 Jul 2018 11:19:42 +0200, Daniel Borkmann wrote:
>> For a quick overview in 'bpftool map' display 'btf' if it's
>> available for the dump for a specific map:
>>
>>   # bpftool map list
>>   11: array  flags 0x0  btf
>>           key 4B  value 20B  max_entries 40  memlock 4096B
>>
>>   # bpftool --json --pretty map list
>>   [{
>>           "id": 11,
>>           "type": "array",
>>           "flags": 0,
>>           "btf_available": true,
>>           "bytes_key": 4,
>>           "bytes_value": 20,
>>           "max_entries": 40,
>>           "bytes_memlock": 4096
>>       }
>>   ]
>>
>> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
> 
> Hmm.. would it make sense to provide the actual BTF IDs instead of just
> yes/no?  At least in JSON?

Yeah that sounds reasonable to me. I think in that case it needs to be
BTF id as well as key and value id inside that BTF object to make some
sense out of it (BTF id alone would not be enough).

Probably makes sense to show the same information in plain text output
then.

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

end of thread, other threads:[~2018-07-19 16:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-18  9:19 [PATCH bpf-next] bpf: show in bpftool map overview whether btf is available Daniel Borkmann
2018-07-18 16:35 ` Martin KaFai Lau
2018-07-18 18:08 ` Jakub Kicinski
2018-07-19 15:45   ` Daniel Borkmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).