• Stanislav Fomichev's avatar
    bpftool: don't print empty key/value for maps · 04a5d323
    Stanislav Fomichev authored
    When doing dump or lookup, don't print key if key_size == 0 or value if
    value_size == 0. The initial usecase is queue and stack, where we have
    only values.
    
    This is for regular output only, json still has all the fields.
    
    Before:
    bpftool map create /sys/fs/bpf/q type queue value 4 entries 10 name q
    bpftool map update pinned /sys/fs/bpf/q value 0 1 2 3
    bpftool map lookup pinned /sys/fs/bpf/q
    key:   value: 00 01 02 03
    
    After:
    bpftool map create /sys/fs/bpf/q type queue value 4 entries 10 name q
    bpftool map update pinned /sys/fs/bpf/q value 0 1 2 3
    bpftool map lookup pinned /sys/fs/bpf/q
    value: 00 01 02 03
    Signed-off-by: default avatarStanislav Fomichev <sdf@google.com>
    Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
    04a5d323
map.c 25.7 KB