aboutsummaryrefslogtreecommitdiffstats
path: root/tools/lib/bpf
diff options
context:
space:
mode:
authorJoe Stringer <joe@wand.net.nz>2018-10-02 16:35:39 -0400
committerDaniel Borkmann <daniel@iogearbox.net>2018-10-02 20:53:48 -0400
commit29cd77f41620dca22bdee092217c16b49ece8915 (patch)
treefeaff57b3414658b3eeccbf2d91f94a0585bcc1b /tools/lib/bpf
parentb584ab8840fdc17f0d75ac62510396b8f657ed8f (diff)
libbpf: Support loading individual progs
Allow the individual program load to be invoked. This will help with testing, where a single ELF may contain several sections, some of which denote subprograms that are expected to fail verification, along with some which are expected to pass verification. By allowing programs to be iterated and individually loaded, each program can be independently checked against its expected verification result. Signed-off-by: Joe Stringer <joe@wand.net.nz> Acked-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'tools/lib/bpf')
-rw-r--r--tools/lib/bpf/libbpf.c4
-rw-r--r--tools/lib/bpf/libbpf.h3
2 files changed, 5 insertions, 2 deletions
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 425d5ca45c97..9e68fd9fcfca 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -228,7 +228,7 @@ struct bpf_object {
228}; 228};
229#define obj_elf_valid(o) ((o)->efile.elf) 229#define obj_elf_valid(o) ((o)->efile.elf)
230 230
231static void bpf_program__unload(struct bpf_program *prog) 231void bpf_program__unload(struct bpf_program *prog)
232{ 232{
233 int i; 233 int i;
234 234
@@ -1375,7 +1375,7 @@ out:
1375 return ret; 1375 return ret;
1376} 1376}
1377 1377
1378static int 1378int
1379bpf_program__load(struct bpf_program *prog, 1379bpf_program__load(struct bpf_program *prog,
1380 char *license, u32 kern_version) 1380 char *license, u32 kern_version)
1381{ 1381{
diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
index 511c1294dcbf..2ed24d3f80b3 100644
--- a/tools/lib/bpf/libbpf.h
+++ b/tools/lib/bpf/libbpf.h
@@ -128,10 +128,13 @@ void bpf_program__set_ifindex(struct bpf_program *prog, __u32 ifindex);
128 128
129const char *bpf_program__title(struct bpf_program *prog, bool needs_copy); 129const char *bpf_program__title(struct bpf_program *prog, bool needs_copy);
130 130
131int bpf_program__load(struct bpf_program *prog, char *license,
132 u32 kern_version);
131int bpf_program__fd(struct bpf_program *prog); 133int bpf_program__fd(struct bpf_program *prog);
132int bpf_program__pin_instance(struct bpf_program *prog, const char *path, 134int bpf_program__pin_instance(struct bpf_program *prog, const char *path,
133 int instance); 135 int instance);
134int bpf_program__pin(struct bpf_program *prog, const char *path); 136int bpf_program__pin(struct bpf_program *prog, const char *path);
137void bpf_program__unload(struct bpf_program *prog);
135 138
136struct bpf_insn; 139struct bpf_insn;
137 140