• Quentin Monnet's avatar
    tools: bpftool: add probes for kernel configuration options · 4567b983
    Quentin Monnet authored
    Add probes to dump a number of options set (or not set) for compiling
    the kernel image. These parameters provide information about what BPF
    components should be available on the system. A number of them are not
    directly related to eBPF, but are in fact used in the kernel as
    conditions on which to compile, or not to compile, some of the eBPF
    helper functions.
    
    Sample output:
    
        # bpftool feature probe kernel
        Scanning system configuration...
        ...
        CONFIG_BPF is set to y
        CONFIG_BPF_SYSCALL is set to y
        CONFIG_HAVE_EBPF_JIT is set to y
        ...
    
        # bpftool --pretty --json feature probe kernel
        {
            "system_config": {
                ...
                "CONFIG_BPF": "y",
                "CONFIG_BPF_SYSCALL": "y",
                "CONFIG_HAVE_EBPF_JIT": "y",
                ...
            }
        }
    
    v5:
    - Declare options[] array in probe_kernel_image_config() as static.
    
    v4:
    - Add some options to the list:
        - CONFIG_TRACING
        - CONFIG_KPROBE_EVENTS
        - CONFIG_UPROBE_EVENTS
        - CONFIG_FTRACE_SYSCALLS
    - Add comments about those options in the source code.
    
    v3:
    - Add a comment about /proc/config.gz not being supported as a path for
      the config file at this time.
    - Use p_info() instead of p_err() on failure to get options from config
      file, as bpftool keeps probing other parameters and that would
      possibly create duplicate "error" entries for JSON.
    
    v2:
    - Remove C-style macros output from this patch.
    - NOT addressed: grouping of those config options into subsections
      (I don't see an easy way of grouping them at the moment, please see
      also the discussion on v1 thread).
    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>
    4567b983
feature.c 10.8 KB