python: Print BPF syscall error if DEBUG_BPF is on but log_buf is empty.
Commit 759029fe provided an option to store the output from BPF syscall into a buffer (and not to print it systematically to standard output) on program load in libbpf.c. But doing so, it only stores the content of attr.log_buf, while the error string--resulting from a failed BPF syscall--is no more displayed when the DEBUG_BPF flag is used in the Python script responsible for converting and injecting the code. This commit proposes a fix for this bug by printing the error message (associated to the return value from the syscall) from the Python caller, when all the following conditions are met: - the syscall fails, - the DEBUG_BPF flag has been provided, and - log_buf is empty (has not been filled by kernel). Note: when DEBUG_BPF is not provided, the error string is printed in the C wrapper in libbpf.c (bpf_prog_load) anyway. Fixes: 759029fe ("Add option for custom log string to bpf_prog_load") Signed-off-by: Quentin Monnet <quentin.monnet@6wind.com>
Showing
Please register or sign in to comment