On 8/9/18 12:42 PM, Daniel Borkmann wrote:
Commit a26ca7c982cb ("bpf: btf: Add pretty print support to
the basic arraymap") enabled support for BTF and dumping via
BPF fs for arraymap. However, both can be decoupled from each
other such that all BPF maps can be supported for attaching
BTF key/value information, while not all maps necessarily
need to dump via map_seq_show_elem() callback.

The check in array_map_check_btf() can be generalized as
ultimatively the key and value size is the only contraint
that needs to match for the map. The fact that the key needs
to be of type int is optional; it could be any data type as
long as it matches the 4 byte key size, just like hash table
key or others could be of any data type as well.

Minimal example of a hash table dump which then works out
of the box for bpftool:

   # bpftool map dump id 19
   [{
           "key": {
               "": {
                   "vip": 0,
                   "vipv6": []
               },
               "port": 0,
               "family": 0,
               "proto": 0
           },
           "value": {
               "flags": 0,
               "vip_num": 0
           }
       }
   ]

Signed-off-by: Daniel Borkmann <dan...@iogearbox.net>
Cc: Yonghong Song <y...@fb.com>

LGTM. Thanks!
Acked-by: Yonghong Song <y...@fb.com>

Reply via email to