Commit 8cccee9e authored by Florent Revest's avatar Florent Revest Committed by Andrii Nakryiko

libbpf: Change bpf_program__set_extra_flags to bpf_program__set_flags

bpf_program__set_extra_flags has just been introduced so we can still
change it without breaking users.

This new interface is a bit more flexible (for example if someone wants
to clear a flag).
Signed-off-by: default avatarFlorent Revest <revest@chromium.org>
Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20211119180035.1396139-1-revest@chromium.org
parent 9a49afe6
......@@ -8315,12 +8315,12 @@ __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)
int bpf_program__set_flags(struct bpf_program *prog, __u32 flags)
{
if (prog->obj->loaded)
return libbpf_err(-EBUSY);
prog->prog_flags |= extra_flags;
prog->prog_flags = flags;
return 0;
}
......
......@@ -498,7 +498,7 @@ 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_flags(struct bpf_program *prog, __u32 flags);
LIBBPF_API int
bpf_program__set_attach_target(struct bpf_program *prog, int attach_prog_fd,
......
......@@ -400,7 +400,7 @@ LIBBPF_0.6.0 {
bpf_program__flags;
bpf_program__insn_cnt;
bpf_program__insns;
bpf_program__set_extra_flags;
bpf_program__set_flags;
btf__add_btf;
btf__add_decl_tag;
btf__add_type_tag;
......
......@@ -91,6 +91,7 @@ int bpf_prog_test_load(const char *file, enum bpf_prog_type type,
struct bpf_object_load_attr attr = {};
struct bpf_object *obj;
struct bpf_program *prog;
__u32 flags;
int err;
obj = bpf_object__open(file);
......@@ -106,7 +107,8 @@ 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);
bpf_program__set_extra_flags(prog, BPF_F_TEST_RND_HI32);
flags = bpf_program__flags(prog) | BPF_F_TEST_RND_HI32;
bpf_program__set_flags(prog, flags);
attr.obj = obj;
attr.log_level = extra_prog_load_log_flags;
......
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