mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-25 05:34:00 +08:00
libbpf: Add ability to get/set per-program load flags
Add bpf_program__flags() API to retrieve prog_flags that will be (or were) supplied to BPF_PROG_LOAD command. Also add bpf_program__set_extra_flags() API to allow to set *extra* flags, in addition to those determined by program's SEC() definition. Such flags are logically OR'ed with libbpf-derived flags. Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20211111051758.92283-2-andrii@kernel.org
This commit is contained in:
parent
04f8cb6d6b
commit
a6ca715831
@ -8262,6 +8262,20 @@ void bpf_program__set_expected_attach_type(struct bpf_program *prog,
|
|||||||
prog->expected_attach_type = type;
|
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, ...) { \
|
#define SEC_DEF(sec_pfx, ptype, atype, flags, ...) { \
|
||||||
.sec = sec_pfx, \
|
.sec = sec_pfx, \
|
||||||
.prog_type = BPF_PROG_TYPE_##ptype, \
|
.prog_type = BPF_PROG_TYPE_##ptype, \
|
||||||
|
@ -493,6 +493,9 @@ LIBBPF_API void
|
|||||||
bpf_program__set_expected_attach_type(struct bpf_program *prog,
|
bpf_program__set_expected_attach_type(struct bpf_program *prog,
|
||||||
enum bpf_attach_type type);
|
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
|
LIBBPF_API int
|
||||||
bpf_program__set_attach_target(struct bpf_program *prog, int attach_prog_fd,
|
bpf_program__set_attach_target(struct bpf_program *prog, int attach_prog_fd,
|
||||||
const char *attach_func_name);
|
const char *attach_func_name);
|
||||||
|
@ -397,8 +397,10 @@ LIBBPF_0.6.0 {
|
|||||||
bpf_object__prev_program;
|
bpf_object__prev_program;
|
||||||
bpf_prog_load_deprecated;
|
bpf_prog_load_deprecated;
|
||||||
bpf_prog_load;
|
bpf_prog_load;
|
||||||
|
bpf_program__flags;
|
||||||
bpf_program__insn_cnt;
|
bpf_program__insn_cnt;
|
||||||
bpf_program__insns;
|
bpf_program__insns;
|
||||||
|
bpf_program__set_extra_flags;
|
||||||
btf__add_btf;
|
btf__add_btf;
|
||||||
btf__add_decl_tag;
|
btf__add_decl_tag;
|
||||||
btf__raw_data;
|
btf__raw_data;
|
||||||
|
Loading…
Reference in New Issue
Block a user