@@ -77,7 +77,7 @@ static int load_and_attach(const char *event, struct bpf_insn *prog, int size)
return -1;
}
- fd = bpf_prog_load(prog_type, prog, size, license, kern_version);
+ fd = bpf_prog_load(prog_type, prog, size, license, kern_version, NULL);
if (fd < 0) {
printf("bpf_prog_load() err=%d\n%s", errno, bpf_log_buf);
return -1;
@@ -59,7 +59,7 @@ static int bpf_prog_create(const char *object)
return prog_fd[0];
} else {
return bpf_prog_load(BPF_PROG_TYPE_SOCKET_FILTER,
- insns, sizeof(insns), "GPL", 0);
+ insns, sizeof(insns), "GPL", 0, NULL);
}
}
@@ -82,7 +82,8 @@ char bpf_log_buf[LOG_BUF_SIZE];
int bpf_prog_load(enum bpf_prog_type prog_type,
const struct bpf_insn *insns, int prog_len,
- const char *license, int kern_version)
+ const char *license, int kern_version,
+ union bpf_prog_subtype *prog_subtype)
{
union bpf_attr attr = {
.prog_type = prog_type,
@@ -98,6 +99,8 @@ int bpf_prog_load(enum bpf_prog_type prog_type,
* padding is zero initialized
*/
attr.kern_version = kern_version;
+ if (prog_subtype)
+ attr.prog_subtype = *prog_subtype;
bpf_log_buf[0] = 0;
@@ -13,7 +13,8 @@ int bpf_get_next_key(int fd, void *key, void *next_key);
int bpf_prog_load(enum bpf_prog_type prog_type,
const struct bpf_insn *insns, int insn_len,
- const char *license, int kern_version);
+ const char *license, int kern_version,
+ union bpf_prog_subtype *prog_subtype);
int bpf_prog_attach(int prog_fd, int attachable_fd, enum bpf_attach_type type);
int bpf_prog_detach(int attachable_fd, enum bpf_attach_type type);
@@ -56,7 +56,7 @@ static int test_sock(void)
};
prog_fd = bpf_prog_load(BPF_PROG_TYPE_SOCKET_FILTER, prog, sizeof(prog),
- "GPL", 0);
+ "GPL", 0, NULL);
if (prog_fd < 0) {
printf("failed to load prog '%s'\n", strerror(errno));
goto cleanup;
Add bpf_prog_subtype argument to bpf_prog_load. If arg is non-NULL, it is added to the attr passed to the bpf system call. Signed-off-by: David Ahern <dsa@cumulusnetworks.com> --- samples/bpf/bpf_load.c | 2 +- samples/bpf/fds_example.c | 2 +- samples/bpf/libbpf.c | 5 ++++- samples/bpf/libbpf.h | 3 ++- samples/bpf/sock_example.c | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-)