Commit 3a75111d authored by Alexei Starovoitov's avatar Alexei Starovoitov

Merge branch 'selftests/bpf: fix test_progs' log_level logic'

Andrii Nakryiko says:

====================

Fix the ability to request verbose (log_level=1) or very verbose (log_level=2)
logs with test_progs's -vv or -vvv parameters. This ability regressed during
recent bpf_prog_load() API refactoring. Also add
bpf_program__set_extra_flags() API to allow setting extra testing flags
(BPF_F_TEST_RND_HI32), which was also dropped during recent changes.
====================
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parents 04f8cb6d 50dee707
......@@ -8262,6 +8262,20 @@ void bpf_program__set_expected_attach_type(struct bpf_program *prog,
prog->expected_attach_type = type;
}
__u32 bpf_program__flags(const struct bpf_program *prog)
{
return prog->prog_flags;
}
int bpf_program__set_extra_flags(struct bpf_program *prog, __u32 extra_flags)
{
if (prog->obj->loaded)
return libbpf_err(-EBUSY);
prog->prog_flags |= extra_flags;
return 0;
}
#define SEC_DEF(sec_pfx, ptype, atype, flags, ...) { \
.sec = sec_pfx, \
.prog_type = BPF_PROG_TYPE_##ptype, \
......
......@@ -493,6 +493,9 @@ LIBBPF_API void
bpf_program__set_expected_attach_type(struct bpf_program *prog,
enum bpf_attach_type type);
LIBBPF_API __u32 bpf_program__flags(const struct bpf_program *prog);
LIBBPF_API int bpf_program__set_extra_flags(struct bpf_program *prog, __u32 extra_flags);
LIBBPF_API int
bpf_program__set_attach_target(struct bpf_program *prog, int attach_prog_fd,
const char *attach_func_name);
......
......@@ -397,8 +397,10 @@ LIBBPF_0.6.0 {
bpf_object__prev_program;
bpf_prog_load_deprecated;
bpf_prog_load;
bpf_program__flags;
bpf_program__insn_cnt;
bpf_program__insns;
bpf_program__set_extra_flags;
btf__add_btf;
btf__add_decl_tag;
btf__raw_data;
......
......@@ -88,6 +88,7 @@ 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)
{
struct bpf_object_load_attr attr = {};
struct bpf_object *obj;
struct bpf_program *prog;
int err;
......@@ -105,7 +106,11 @@ int bpf_prog_test_load(const char *file, enum bpf_prog_type type,
if (type != BPF_PROG_TYPE_UNSPEC)
bpf_program__set_type(prog, type);
err = bpf_object__load(obj);
bpf_program__set_extra_flags(prog, BPF_F_TEST_RND_HI32);
attr.obj = obj;
attr.log_level = extra_prog_load_log_flags;
err = bpf_object__load_xattr(&attr);
if (err)
goto err_out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment