Commit 04656198 authored by Jiong Wang's avatar Jiong Wang Committed by Alexei Starovoitov

libbpf: add "prog_flags" to bpf_program/bpf_prog_load_attr/bpf_load_program_attr

libbpf doesn't allow passing "prog_flags" during bpf program load in a
couple of load related APIs, "bpf_load_program_xattr", "load_program" and
"bpf_prog_load_xattr".

It makes sense to allow passing "prog_flags" which is useful for
customizing program loading.
Reviewed-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: default avatarJiong Wang <jiong.wang@netronome.com>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent d6c2308c
...@@ -256,6 +256,7 @@ int bpf_load_program_xattr(const struct bpf_load_program_attr *load_attr, ...@@ -256,6 +256,7 @@ int bpf_load_program_xattr(const struct bpf_load_program_attr *load_attr,
if (load_attr->name) if (load_attr->name)
memcpy(attr.prog_name, load_attr->name, memcpy(attr.prog_name, load_attr->name,
min(strlen(load_attr->name), BPF_OBJ_NAME_LEN - 1)); min(strlen(load_attr->name), BPF_OBJ_NAME_LEN - 1));
attr.prog_flags = load_attr->prog_flags;
fd = sys_bpf_prog_load(&attr, sizeof(attr)); fd = sys_bpf_prog_load(&attr, sizeof(attr));
if (fd >= 0) if (fd >= 0)
......
...@@ -87,6 +87,7 @@ struct bpf_load_program_attr { ...@@ -87,6 +87,7 @@ struct bpf_load_program_attr {
const void *line_info; const void *line_info;
__u32 line_info_cnt; __u32 line_info_cnt;
__u32 log_level; __u32 log_level;
__u32 prog_flags;
}; };
/* Flags to direct loading requirements */ /* Flags to direct loading requirements */
......
...@@ -188,6 +188,7 @@ struct bpf_program { ...@@ -188,6 +188,7 @@ struct bpf_program {
void *line_info; void *line_info;
__u32 line_info_rec_size; __u32 line_info_rec_size;
__u32 line_info_cnt; __u32 line_info_cnt;
__u32 prog_flags;
}; };
enum libbpf_map_type { enum libbpf_map_type {
...@@ -2076,6 +2077,7 @@ load_program(struct bpf_program *prog, struct bpf_insn *insns, int insns_cnt, ...@@ -2076,6 +2077,7 @@ load_program(struct bpf_program *prog, struct bpf_insn *insns, int insns_cnt,
load_attr.line_info_rec_size = prog->line_info_rec_size; load_attr.line_info_rec_size = prog->line_info_rec_size;
load_attr.line_info_cnt = prog->line_info_cnt; load_attr.line_info_cnt = prog->line_info_cnt;
load_attr.log_level = prog->log_level; load_attr.log_level = prog->log_level;
load_attr.prog_flags = prog->prog_flags;
if (!load_attr.insns || !load_attr.insns_cnt) if (!load_attr.insns || !load_attr.insns_cnt)
return -EINVAL; return -EINVAL;
...@@ -3521,6 +3523,7 @@ int bpf_prog_load_xattr(const struct bpf_prog_load_attr *attr, ...@@ -3521,6 +3523,7 @@ int bpf_prog_load_xattr(const struct bpf_prog_load_attr *attr,
expected_attach_type); expected_attach_type);
prog->log_level = attr->log_level; prog->log_level = attr->log_level;
prog->prog_flags = attr->prog_flags;
if (!first_prog) if (!first_prog)
first_prog = prog; first_prog = prog;
} }
......
...@@ -320,6 +320,7 @@ struct bpf_prog_load_attr { ...@@ -320,6 +320,7 @@ struct bpf_prog_load_attr {
enum bpf_attach_type expected_attach_type; enum bpf_attach_type expected_attach_type;
int ifindex; int ifindex;
int log_level; int log_level;
int prog_flags;
}; };
LIBBPF_API int bpf_prog_load_xattr(const struct bpf_prog_load_attr *attr, LIBBPF_API int bpf_prog_load_xattr(const struct bpf_prog_load_attr *attr,
......
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