• Quentin Monnet's avatar
    tools: bpftool: add probes for eBPF map types · f99e1663
    Quentin Monnet authored
    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: default avatarQuentin Monnet <quentin.monnet@netronome.com>
    Reviewed-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
    Reviewed-by: default avatarStanislav Fomichev <sdf@google.com>
    Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    f99e1663
libbpf_probes.c 4.38 KB