diff options
author | Daniel Borkmann <daniel@iogearbox.net> | 2017-07-20 18:00:22 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-07-20 18:20:27 -0400 |
commit | d655490417ee22da3267fe6592a0ec2023c3c0db (patch) | |
tree | d6a46018c9e1e644757d89b763e09a4472254d16 | |
parent | 4cabc5b186b5427b9ee5a7495172542af105f02b (diff) |
bpf: allow to specify log level and reduce it for test_verifier
For the test_verifier case, it's quite hard to parse log level 2 to
figure out what's causing an issue when used to log level 1. We do
want to use bpf_verify_program() in order to simulate some of the
tests with strict alignment. So just add an argument to pass the level
and put it to 1 for test_verifier.
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | tools/lib/bpf/bpf.c | 4 | ||||
-rw-r--r-- | tools/lib/bpf/bpf.h | 2 | ||||
-rw-r--r-- | tools/testing/selftests/bpf/test_align.c | 2 | ||||
-rw-r--r-- | tools/testing/selftests/bpf/test_verifier.c | 2 |
4 files changed, 5 insertions, 5 deletions
diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c index 7e0405e1651d..412a7c82995a 100644 --- a/tools/lib/bpf/bpf.c +++ b/tools/lib/bpf/bpf.c | |||
@@ -120,7 +120,7 @@ int bpf_load_program(enum bpf_prog_type type, const struct bpf_insn *insns, | |||
120 | int bpf_verify_program(enum bpf_prog_type type, const struct bpf_insn *insns, | 120 | int bpf_verify_program(enum bpf_prog_type type, const struct bpf_insn *insns, |
121 | size_t insns_cnt, int strict_alignment, | 121 | size_t insns_cnt, int strict_alignment, |
122 | const char *license, __u32 kern_version, | 122 | const char *license, __u32 kern_version, |
123 | char *log_buf, size_t log_buf_sz) | 123 | char *log_buf, size_t log_buf_sz, int log_level) |
124 | { | 124 | { |
125 | union bpf_attr attr; | 125 | union bpf_attr attr; |
126 | 126 | ||
@@ -131,7 +131,7 @@ int bpf_verify_program(enum bpf_prog_type type, const struct bpf_insn *insns, | |||
131 | attr.license = ptr_to_u64(license); | 131 | attr.license = ptr_to_u64(license); |
132 | attr.log_buf = ptr_to_u64(log_buf); | 132 | attr.log_buf = ptr_to_u64(log_buf); |
133 | attr.log_size = log_buf_sz; | 133 | attr.log_size = log_buf_sz; |
134 | attr.log_level = 2; | 134 | attr.log_level = log_level; |
135 | log_buf[0] = 0; | 135 | log_buf[0] = 0; |
136 | attr.kern_version = kern_version; | 136 | attr.kern_version = kern_version; |
137 | attr.prog_flags = strict_alignment ? BPF_F_STRICT_ALIGNMENT : 0; | 137 | attr.prog_flags = strict_alignment ? BPF_F_STRICT_ALIGNMENT : 0; |
diff --git a/tools/lib/bpf/bpf.h b/tools/lib/bpf/bpf.h index 16de44a14b48..418c86e69bcb 100644 --- a/tools/lib/bpf/bpf.h +++ b/tools/lib/bpf/bpf.h | |||
@@ -38,7 +38,7 @@ int bpf_load_program(enum bpf_prog_type type, const struct bpf_insn *insns, | |||
38 | int bpf_verify_program(enum bpf_prog_type type, const struct bpf_insn *insns, | 38 | int bpf_verify_program(enum bpf_prog_type type, const struct bpf_insn *insns, |
39 | size_t insns_cnt, int strict_alignment, | 39 | size_t insns_cnt, int strict_alignment, |
40 | const char *license, __u32 kern_version, | 40 | const char *license, __u32 kern_version, |
41 | char *log_buf, size_t log_buf_sz); | 41 | char *log_buf, size_t log_buf_sz, int log_level); |
42 | 42 | ||
43 | int bpf_map_update_elem(int fd, const void *key, const void *value, | 43 | int bpf_map_update_elem(int fd, const void *key, const void *value, |
44 | __u64 flags); | 44 | __u64 flags); |
diff --git a/tools/testing/selftests/bpf/test_align.c b/tools/testing/selftests/bpf/test_align.c index bccebd935907..29793694cbc7 100644 --- a/tools/testing/selftests/bpf/test_align.c +++ b/tools/testing/selftests/bpf/test_align.c | |||
@@ -380,7 +380,7 @@ static int do_test_single(struct bpf_align_test *test) | |||
380 | prog_len = probe_filter_length(prog); | 380 | prog_len = probe_filter_length(prog); |
381 | fd_prog = bpf_verify_program(prog_type ? : BPF_PROG_TYPE_SOCKET_FILTER, | 381 | fd_prog = bpf_verify_program(prog_type ? : BPF_PROG_TYPE_SOCKET_FILTER, |
382 | prog, prog_len, 1, "GPL", 0, | 382 | prog, prog_len, 1, "GPL", 0, |
383 | bpf_vlog, sizeof(bpf_vlog)); | 383 | bpf_vlog, sizeof(bpf_vlog), 2); |
384 | if (fd_prog < 0) { | 384 | if (fd_prog < 0) { |
385 | printf("Failed to load program.\n"); | 385 | printf("Failed to load program.\n"); |
386 | printf("%s", bpf_vlog); | 386 | printf("%s", bpf_vlog); |
diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c index 404aec520812..f4d0a1de3925 100644 --- a/tools/testing/selftests/bpf/test_verifier.c +++ b/tools/testing/selftests/bpf/test_verifier.c | |||
@@ -5633,7 +5633,7 @@ static void do_test_single(struct bpf_test *test, bool unpriv, | |||
5633 | 5633 | ||
5634 | fd_prog = bpf_verify_program(prog_type ? : BPF_PROG_TYPE_SOCKET_FILTER, | 5634 | fd_prog = bpf_verify_program(prog_type ? : BPF_PROG_TYPE_SOCKET_FILTER, |
5635 | prog, prog_len, test->flags & F_LOAD_WITH_STRICT_ALIGNMENT, | 5635 | prog, prog_len, test->flags & F_LOAD_WITH_STRICT_ALIGNMENT, |
5636 | "GPL", 0, bpf_vlog, sizeof(bpf_vlog)); | 5636 | "GPL", 0, bpf_vlog, sizeof(bpf_vlog), 1); |
5637 | 5637 | ||
5638 | expected_ret = unpriv && test->result_unpriv != UNDEF ? | 5638 | expected_ret = unpriv && test->result_unpriv != UNDEF ? |
5639 | test->result_unpriv : test->result; | 5639 | test->result_unpriv : test->result; |