• Quentin Monnet's avatar
    tools: bpftool: make -d option print debug output from verifier · 55d77807
    Quentin Monnet authored
    The "-d" option is used to require all logs available for bpftool. So
    far it meant telling libbpf to print even debug-level information. But
    there is another source of info that can be made more verbose: when we
    attemt to load programs with bpftool, we can pass a log_level parameter
    to the verifier in order to control the amount of information that is
    printed to the console.
    
    Reuse the "-d" option to print all information the verifier can tell. At
    this time, this means logs related to BPF_LOG_LEVEL1, BPF_LOG_LEVEL2 and
    BPF_LOG_STATS. As mentioned in the discussion on the first version of
    this set, these macros are internal to the kernel
    (include/linux/bpf_verifier.h) and are not meant to be part of the
    stable user API, therefore we simply use the related constants to print
    whatever we can at this time, without trying to tell users what is
    log_level1 or what is statistics.
    
    Verifier logs are only used when loading programs for now (In the
    future: for loading BTF objects with bpftool? Although libbpf does not
    currently offer to print verifier info at debug level if no error
    occurred when loading BTF objects), so bpftool.rst and bpftool-prog.rst
    are the only man pages to get the update.
    
    v3:
    - Add details on log level and BTF loading at the end of commit log.
    
    v2:
    - Remove the possibility to select the log levels to use (v1 offered a
      combination of "log_level1", "log_level2" and "stats").
    - The macros from kernel header bpf_verifier.h are not used (and
      therefore not moved to UAPI header).
    - In v1 this was a distinct option, but is now merged in the only "-d"
      switch to activate libbpf and verifier debug-level logs all at the
      same time.
    Signed-off-by: default avatarQuentin Monnet <quentin.monnet@netronome.com>
    Reviewed-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
    Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
    55d77807
main.c 7.8 KB