OSDN Git Service

tools: bpftool: add probes for eBPF map types
authorQuentin Monnet <quentin.monnet@netronome.com>
Thu, 17 Jan 2019 15:27:54 +0000 (15:27 +0000)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 23 Jan 2019 06:15:40 +0000 (22:15 -0800)
commitf99e166397f0298fe78bce24c55c6d074f9bf196
treee9f31b1ccd938793704a80cce059d7fd25541842
parent1bf4b05810fe38c5f09973295e8d4234a4fd5d87
tools: bpftool: add probes for eBPF map types

Add new probes for eBPF map types, to detect what are the ones available
on the system. Try creating one map of each type, and see if the kernel
complains.

Sample output:

    # bpftool feature probe kernel
    ...
    Scanning eBPF map types...
    eBPF map_type hash is available
    eBPF map_type array is available
    eBPF map_type prog_array is available
    ...

    # bpftool --json --pretty feature probe kernel
    {
        ...
        "map_types": {
            "have_hash_map_type": true,
            "have_array_map_type": true,
            "have_prog_array_map_type": true,
            ...
        }
    }

v5:
- In libbpf.map, move global symbol to the new LIBBPF_0.0.2 section.

v3:
- Use a switch with all enum values for setting specific map parameters,
  so that gcc complains at compile time (-Wswitch-enum) if new map types
  were added to the kernel but libbpf was not updated.

v2:
- Move probes from bpftool to libbpf.
- Remove C-style macros output from this patch.

Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com>
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Stanislav Fomichev <sdf@google.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/bpf/bpftool/feature.c
tools/bpf/bpftool/main.h
tools/bpf/bpftool/map.c
tools/lib/bpf/libbpf.h
tools/lib/bpf/libbpf.map
tools/lib/bpf/libbpf_probes.c