tools/bpf: add new fields for program load in lib/bpf
authorYonghong Song <yhs@fb.com>
Mon, 19 Nov 2018 23:29:14 +0000 (15:29 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 20 Nov 2018 18:54:39 +0000 (10:54 -0800)
The new fields are added for program load in lib/bpf so
application uses api bpf_load_program_xattr() is able
to load program with btf and func_info data.

This functionality will be used in next patch
by bpf selftest test_btf.

Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/lib/bpf/bpf.c
tools/lib/bpf/bpf.h

index 961e1b9fc5927637d708d4679ee421ec046b517d..9b5cf22c4e64b0ae7b0e2975466847998f7119b1 100644 (file)
@@ -205,6 +205,10 @@ int bpf_load_program_xattr(const struct bpf_load_program_attr *load_attr,
        attr.log_level = 0;
        attr.kern_version = load_attr->kern_version;
        attr.prog_ifindex = load_attr->prog_ifindex;
+       attr.prog_btf_fd = load_attr->prog_btf_fd;
+       attr.func_info_rec_size = load_attr->func_info_rec_size;
+       attr.func_info_cnt = load_attr->func_info_cnt;
+       attr.func_info = ptr_to_u64(load_attr->func_info);
        memcpy(attr.prog_name, load_attr->name,
               min(name_len, BPF_OBJ_NAME_LEN - 1));
 
index 26a51538213cd1fe368a1776e6b610856df0e5b7..8bdfd806253ae64310a397213a3328706fcf4542 100644 (file)
@@ -74,6 +74,10 @@ struct bpf_load_program_attr {
        const char *license;
        __u32 kern_version;
        __u32 prog_ifindex;
+       __u32 prog_btf_fd;
+       __u32 func_info_rec_size;
+       const void *func_info;
+       __u32 func_info_cnt;
 };
 
 /* Flags to direct loading requirements */