selftests/bpf: Integrate verbose verifier log into test_progs
Add exra level of verboseness, activated by -vvv argument. When -vv is specified, verbose libbpf and verifier log (level 1) is output, even for successful tests. With -vvv, verifier log goes to level 2. This is extremely useful to debug verifier failures, as well as just see the state and flow of verification. Before this, you'd have to go and modify load_program()'s source code inside libbpf to specify extra log_level flags, which is suboptimal to say the least. Currently -vv and -vvv triggering verifier output is integrated into test_stub's bpf_prog_load as well as bpf_verif_scale.c tests. Signed-off-by: Andrii Nakryiko <andriin@fb.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20191120003548.4159797-1-andriin@fb.com
This commit is contained in:

committed by
Alexei Starovoitov

parent
5940c5bf65
commit
a8fdaad5cf
@@ -5,6 +5,8 @@
|
||||
#include <bpf/libbpf.h>
|
||||
#include <string.h>
|
||||
|
||||
int extra_prog_load_log_flags = 0;
|
||||
|
||||
int bpf_prog_test_load(const char *file, enum bpf_prog_type type,
|
||||
struct bpf_object **pobj, int *prog_fd)
|
||||
{
|
||||
@@ -15,6 +17,7 @@ int bpf_prog_test_load(const char *file, enum bpf_prog_type type,
|
||||
attr.prog_type = type;
|
||||
attr.expected_attach_type = 0;
|
||||
attr.prog_flags = BPF_F_TEST_RND_HI32;
|
||||
attr.log_level = extra_prog_load_log_flags;
|
||||
|
||||
return bpf_prog_load_xattr(&attr, pobj, prog_fd);
|
||||
}
|
||||
@@ -35,6 +38,7 @@ int bpf_test_load_program(enum bpf_prog_type type, const struct bpf_insn *insns,
|
||||
load_attr.license = license;
|
||||
load_attr.kern_version = kern_version;
|
||||
load_attr.prog_flags = BPF_F_TEST_RND_HI32;
|
||||
load_attr.log_level = extra_prog_load_log_flags;
|
||||
|
||||
return bpf_load_program_xattr(&load_attr, log_buf, log_buf_sz);
|
||||
}
|
||||
|
Reference in New Issue
Block a user