]> git.baikalelectronics.ru Git - kernel.git/commit
tools/bpf: bpftool: support prog array map and map of maps
authorYonghong Song <yhs@fb.com>
Fri, 7 Sep 2018 00:26:05 +0000 (17:26 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 11 Sep 2018 21:17:24 +0000 (14:17 -0700)
commit96b0686dcdb50979a0e34d73a6e20936732d37cf
treeb913be301cd2a317da5ed40d032c3716c3cf3629
parent393cbd9f7ac09191b08cedf2a02b1ff29fc6450d
tools/bpf: bpftool: support prog array map and map of maps

Currently, prog array map and map of maps are not supported
in bpftool. This patch added the support.
Different from other map types, for prog array map and
map of maps, the key returned bpf_get_next_key() may not
point to a valid value. So for these two map types,
no error will be printed out when such a scenario happens.

The following is the plain and json dump if btf is not available:
  $ ./bpftool map dump id 10
    key: 08 00 00 00  value: 5c 01 00 00
    Found 1 element
  $ ./bpftool -jp map dump id 10
    [{
        "key": ["0x08","0x00","0x00","0x00"
        ],
        "value": ["0x5c","0x01","0x00","0x00"
        ]
    }]

If the BTF is available, the dump looks below:
  $ ./bpftool map dump id 2
    [{
            "key": 0,
            "value": 7
        }
    ]
  $ ./bpftool -jp map dump id 2
    [{
        "key": ["0x00","0x00","0x00","0x00"
        ],
        "value": ["0x07","0x00","0x00","0x00"
        ],
        "formatted": {
            "key": 0,
            "value": 7
        }
    }]

Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/bpf/bpftool/map.c