aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYonghong Song <yhs@fb.com>2018-11-19 18:29:14 -0500
committerAlexei Starovoitov <ast@kernel.org>2018-11-20 13:54:39 -0500
commit7e0d0fb5522a388700ceff723af98c47ffa8a0a9 (patch)
treed2e6a0de7257b79ef093f31e4d52e7fa368b8b54
parentcc19435cb2ee34a3663f0be69f3a4647795b0417 (diff)
tools/bpf: add new fields for program load in lib/bpf
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>
-rw-r--r--tools/lib/bpf/bpf.c4
-rw-r--r--tools/lib/bpf/bpf.h4
2 files changed, 8 insertions, 0 deletions
diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
index 961e1b9fc592..9b5cf22c4e64 100644
--- a/tools/lib/bpf/bpf.c
+++ b/tools/lib/bpf/bpf.c
@@ -205,6 +205,10 @@ int bpf_load_program_xattr(const struct bpf_load_program_attr *load_attr,
205 attr.log_level = 0; 205 attr.log_level = 0;
206 attr.kern_version = load_attr->kern_version; 206 attr.kern_version = load_attr->kern_version;
207 attr.prog_ifindex = load_attr->prog_ifindex; 207 attr.prog_ifindex = load_attr->prog_ifindex;
208 attr.prog_btf_fd = load_attr->prog_btf_fd;
209 attr.func_info_rec_size = load_attr->func_info_rec_size;
210 attr.func_info_cnt = load_attr->func_info_cnt;
211 attr.func_info = ptr_to_u64(load_attr->func_info);
208 memcpy(attr.prog_name, load_attr->name, 212 memcpy(attr.prog_name, load_attr->name,
209 min(name_len, BPF_OBJ_NAME_LEN - 1)); 213 min(name_len, BPF_OBJ_NAME_LEN - 1));
210 214
diff --git a/tools/lib/bpf/bpf.h b/tools/lib/bpf/bpf.h
index 26a51538213c..8bdfd806253a 100644
--- a/tools/lib/bpf/bpf.h
+++ b/tools/lib/bpf/bpf.h
@@ -74,6 +74,10 @@ struct bpf_load_program_attr {
74 const char *license; 74 const char *license;
75 __u32 kern_version; 75 __u32 kern_version;
76 __u32 prog_ifindex; 76 __u32 prog_ifindex;
77 __u32 prog_btf_fd;
78 __u32 func_info_rec_size;
79 const void *func_info;
80 __u32 func_info_cnt;
77}; 81};
78 82
79/* Flags to direct loading requirements */ 83/* Flags to direct loading requirements */