mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
libbpf: Add error returns to two API functions
This adds an error return to the following API functions: - bpf_program__set_expected_attach_type() - bpf_program__set_type() In both cases, the error occurs when the BPF object has already been loaded when the function is called. In this case -EBUSY is returned. Signed-off-by: Grant Seltzer <grantseltzer@gmail.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20220420161226.86803-1-grantseltzer@gmail.com
This commit is contained in:
parent
db69264f98
commit
93442f132b
2 changed files with 13 additions and 5 deletions
|
@ -8562,9 +8562,13 @@ enum bpf_prog_type bpf_program__type(const struct bpf_program *prog)
|
|||
return prog->type;
|
||||
}
|
||||
|
||||
void bpf_program__set_type(struct bpf_program *prog, enum bpf_prog_type type)
|
||||
int bpf_program__set_type(struct bpf_program *prog, enum bpf_prog_type type)
|
||||
{
|
||||
if (prog->obj->loaded)
|
||||
return libbpf_err(-EBUSY);
|
||||
|
||||
prog->type = type;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool bpf_program__is_type(const struct bpf_program *prog,
|
||||
|
@ -8609,10 +8613,14 @@ enum bpf_attach_type bpf_program__expected_attach_type(const struct bpf_program
|
|||
return prog->expected_attach_type;
|
||||
}
|
||||
|
||||
void bpf_program__set_expected_attach_type(struct bpf_program *prog,
|
||||
int bpf_program__set_expected_attach_type(struct bpf_program *prog,
|
||||
enum bpf_attach_type type)
|
||||
{
|
||||
if (prog->obj->loaded)
|
||||
return libbpf_err(-EBUSY);
|
||||
|
||||
prog->expected_attach_type = type;
|
||||
return 0;
|
||||
}
|
||||
|
||||
__u32 bpf_program__flags(const struct bpf_program *prog)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue