]> git.baikalelectronics.ru Git - kernel.git/commit
bpftool: Improve handling of ENOENT on map dumps
authorDavid Ahern <dsahern@gmail.com>
Thu, 8 Nov 2018 21:00:07 +0000 (13:00 -0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 9 Nov 2018 09:03:59 +0000 (10:03 +0100)
commit47eb0029a48022fcb764ab8fbff66c6f9ac7d9c8
tree39da7a18141381033f339f182a7255814a161497
parentaeeeb9fc99da22a89d1d8b76ce5b569998ccf656
bpftool: Improve handling of ENOENT on map dumps

bpftool output is not user friendly when dumping a map with only a few
populated entries:

    $ bpftool map
    1: devmap  name tx_devmap  flags 0x0
            key 4B  value 4B  max_entries 64  memlock 4096B
    2: array  name tx_idxmap  flags 0x0
            key 4B  value 4B  max_entries 64  memlock 4096B

    $ bpftool map dump id 1
    key:
    00 00 00 00
    value:
    No such file or directory
    key:
    01 00 00 00
    value:
    No such file or directory
    key:
    02 00 00 00
    value:
    No such file or directory
    key: 03 00 00 00  value: 03 00 00 00

Handle ENOENT by keeping the line format sane and dumping
"<no entry>" for the value

    $ bpftool map dump id 1
    key: 00 00 00 00  value: <no entry>
    key: 01 00 00 00  value: <no entry>
    key: 02 00 00 00  value: <no entry>
    key: 03 00 00 00  value: 03 00 00 00
    ...

Signed-off-by: David Ahern <dsahern@gmail.com>
Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
tools/bpf/bpftool/map.c