mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-25 02:20:52 +07:00
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>
This commit is contained in:
parent
4cabc5b186
commit
d655490417
@ -120,7 +120,7 @@ int bpf_load_program(enum bpf_prog_type type, const struct bpf_insn *insns,
|
|||||||
int bpf_verify_program(enum bpf_prog_type type, const struct bpf_insn *insns,
|
int bpf_verify_program(enum bpf_prog_type type, const struct bpf_insn *insns,
|
||||||
size_t insns_cnt, int strict_alignment,
|
size_t insns_cnt, int strict_alignment,
|
||||||
const char *license, __u32 kern_version,
|
const char *license, __u32 kern_version,
|
||||||
char *log_buf, size_t log_buf_sz)
|
char *log_buf, size_t log_buf_sz, int log_level)
|
||||||
{
|
{
|
||||||
union bpf_attr attr;
|
union bpf_attr attr;
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ int bpf_verify_program(enum bpf_prog_type type, const struct bpf_insn *insns,
|
|||||||
attr.license = ptr_to_u64(license);
|
attr.license = ptr_to_u64(license);
|
||||||
attr.log_buf = ptr_to_u64(log_buf);
|
attr.log_buf = ptr_to_u64(log_buf);
|
||||||
attr.log_size = log_buf_sz;
|
attr.log_size = log_buf_sz;
|
||||||
attr.log_level = 2;
|
attr.log_level = log_level;
|
||||||
log_buf[0] = 0;
|
log_buf[0] = 0;
|
||||||
attr.kern_version = kern_version;
|
attr.kern_version = kern_version;
|
||||||
attr.prog_flags = strict_alignment ? BPF_F_STRICT_ALIGNMENT : 0;
|
attr.prog_flags = strict_alignment ? BPF_F_STRICT_ALIGNMENT : 0;
|
||||||
|
@ -38,7 +38,7 @@ int bpf_load_program(enum bpf_prog_type type, const struct bpf_insn *insns,
|
|||||||
int bpf_verify_program(enum bpf_prog_type type, const struct bpf_insn *insns,
|
int bpf_verify_program(enum bpf_prog_type type, const struct bpf_insn *insns,
|
||||||
size_t insns_cnt, int strict_alignment,
|
size_t insns_cnt, int strict_alignment,
|
||||||
const char *license, __u32 kern_version,
|
const char *license, __u32 kern_version,
|
||||||
char *log_buf, size_t log_buf_sz);
|
char *log_buf, size_t log_buf_sz, int log_level);
|
||||||
|
|
||||||
int bpf_map_update_elem(int fd, const void *key, const void *value,
|
int bpf_map_update_elem(int fd, const void *key, const void *value,
|
||||||
__u64 flags);
|
__u64 flags);
|
||||||
|
@ -380,7 +380,7 @@ static int do_test_single(struct bpf_align_test *test)
|
|||||||
prog_len = probe_filter_length(prog);
|
prog_len = probe_filter_length(prog);
|
||||||
fd_prog = bpf_verify_program(prog_type ? : BPF_PROG_TYPE_SOCKET_FILTER,
|
fd_prog = bpf_verify_program(prog_type ? : BPF_PROG_TYPE_SOCKET_FILTER,
|
||||||
prog, prog_len, 1, "GPL", 0,
|
prog, prog_len, 1, "GPL", 0,
|
||||||
bpf_vlog, sizeof(bpf_vlog));
|
bpf_vlog, sizeof(bpf_vlog), 2);
|
||||||
if (fd_prog < 0) {
|
if (fd_prog < 0) {
|
||||||
printf("Failed to load program.\n");
|
printf("Failed to load program.\n");
|
||||||
printf("%s", bpf_vlog);
|
printf("%s", bpf_vlog);
|
||||||
|
@ -5633,7 +5633,7 @@ static void do_test_single(struct bpf_test *test, bool unpriv,
|
|||||||
|
|
||||||
fd_prog = bpf_verify_program(prog_type ? : BPF_PROG_TYPE_SOCKET_FILTER,
|
fd_prog = bpf_verify_program(prog_type ? : BPF_PROG_TYPE_SOCKET_FILTER,
|
||||||
prog, prog_len, test->flags & F_LOAD_WITH_STRICT_ALIGNMENT,
|
prog, prog_len, test->flags & F_LOAD_WITH_STRICT_ALIGNMENT,
|
||||||
"GPL", 0, bpf_vlog, sizeof(bpf_vlog));
|
"GPL", 0, bpf_vlog, sizeof(bpf_vlog), 1);
|
||||||
|
|
||||||
expected_ret = unpriv && test->result_unpriv != UNDEF ?
|
expected_ret = unpriv && test->result_unpriv != UNDEF ?
|
||||||
test->result_unpriv : test->result;
|
test->result_unpriv : test->result;
|
||||||
|
Loading…
Reference in New Issue
Block a user