• David Ahern's avatar
    bpftool: Improve handling of ENOENT on map dumps · bf598a8f
    David Ahern authored
    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: default avatarDavid Ahern <dsahern@gmail.com>
    Acked-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
    Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
    bf598a8f
map.c 26.7 KB