1
0
Fork 0
alistair23-linux/tools/bpf
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
..
bpftool bpf: btf: print map dump and lookup with btf info 2018-07-14 13:00:40 +02:00
Makefile bpf: fix for lex/yacc build error with gcc-5 2018-04-25 23:27:46 +02:00
Makefile.helpers tools: bpf: build and install man page for eBPF helpers from bpftool/ 2018-07-12 18:55:53 +02:00
bpf_asm.c tools: rename tools/net directory to tools/bpf 2017-10-04 21:45:05 -07:00
bpf_dbg.c bpf: fix uninitialized variable in bpf tools 2018-04-26 22:23:02 +02:00
bpf_exp.l bpf: fix cbpf parser bug for octal numbers 2018-06-03 07:46:55 -07:00
bpf_exp.y tools: rename tools/net directory to tools/bpf 2017-10-04 21:45:05 -07:00
bpf_jit_disasm.c tools/bpf_jit_disasm: silence a static checker warning 2018-01-18 22:15:37 +01:00