1
0
Fork 0
alistair23-linux/tools/bpf/bpftool
Okash Khawaja 2d3feca8c4 bpf: btf: print map dump and lookup with btf info
This patch augments the output of bpftool's map dump and map lookup
commands to print data along side btf info, if the correspondin btf
info is available. The outputs for each of  map dump and map lookup
commands are augmented in two ways:

1. when neither of -j and -p are supplied, btf-ful map data is printed
whose aim is human readability. This means no commitments for json- or
backward- compatibility.

2. when either -j or -p are supplied, a new json object named
"formatted" is added for each key-value pair. This object contains the
same data as the key-value pair, but with btf info. "formatted" object
promises json- and backward- compatibility. Below is a sample output.

$ bpftool map dump -p id 8
[{
        "key": ["0x0f","0x00","0x00","0x00"
        ],
        "value": ["0x03", "0x00", "0x00", "0x00", ...
        ],
        "formatted": {
                "key": 15,
                "value": {
                        "int_field":  3,
                        ...
                }
        }
}
]

This patch calls btf_dumper introduced in previous patch to accomplish
the above. Indeed, btf-ful info is only displayed if btf data for the
given map is available. Otherwise existing output is displayed as-is.

Signed-off-by: Okash Khawaja <osk@fb.com>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2018-07-14 13:00:40 +02:00
..
Documentation tools: bpf: build and install man page for eBPF helpers from bpftool/ 2018-07-12 18:55:53 +02:00
bash-completion tools: bpftool: allow reuse of maps with bpftool prog load 2018-07-11 22:13:34 +02:00
.gitignore selftests/bpf: ignore build products 2018-05-10 00:41:06 +02:00
Makefile tools: bpf: make use of reallocarray 2018-07-11 22:13:34 +02:00
btf_dumper.c bpf: btf: add btf print functionality 2018-07-14 13:00:40 +02:00
cfg.c tools: bpftool: generate .dot graph from CFG information 2018-03-01 18:29:49 -08:00
cfg.h tools: bpftool: detect sub-programs from the eBPF sequence 2018-03-01 18:29:48 -08:00
cgroup.c bpftool: introduce cgroup tree command 2018-07-07 01:38:38 +02:00
common.c tools: bpftool: drop unnecessary Author comments 2018-07-01 01:01:50 +02:00
jit_disasm.c tools: bpftool: improve architecture detection by using ifindex 2018-01-18 01:26:15 +01:00
json_writer.c tools: bpftool: add JSON output for `bpftool prog dump xlated *` command 2017-10-24 01:25:08 +01:00
json_writer.h tools: bpftool: add JSON output for `bpftool prog dump xlated *` command 2017-10-24 01:25:08 +01:00
main.c tools: bpftool: drop unnecessary Author comments 2018-07-01 01:01:50 +02:00
main.h bpf: btf: add btf print functionality 2018-07-14 13:00:40 +02:00
map.c bpf: btf: print map dump and lookup with btf info 2018-07-14 13:00:40 +02:00
map_perf_ring.c tools: bpf: move the event reading loop to libbpf 2018-05-11 01:40:52 +02:00
perf.c tools/bpftool: fix a bug in bpftool perf 2018-06-13 02:03:17 +02:00
prog.c tools: bpftool: allow reuse of maps with bpftool prog load 2018-07-11 22:13:34 +02:00
xlated_dumper.c tools: bpf: make use of reallocarray 2018-07-11 22:13:34 +02:00
xlated_dumper.h tools: bpftool: add delimiters to multi-function JITed dumps 2018-05-24 09:20:50 +02:00