libbpf: Support loading individual progs
authorJoe Stringer <joe@wand.net.nz>
Tue, 2 Oct 2018 20:35:39 +0000 (13:35 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Wed, 3 Oct 2018 00:53:48 +0000 (02:53 +0200)
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>
tools/lib/bpf/libbpf.c
tools/lib/bpf/libbpf.h

index 425d5ca45c97feec66d55c1e84244f8a1f8c6670..9e68fd9fcfcaece0aed6eadf5eec99bce857fd67 100644 (file)
@@ -228,7 +228,7 @@ struct bpf_object {
 };
 #define obj_elf_valid(o)       ((o)->efile.elf)
 
-static void bpf_program__unload(struct bpf_program *prog)
+void bpf_program__unload(struct bpf_program *prog)
 {
        int i;
 
@@ -1375,7 +1375,7 @@ out:
        return ret;
 }
 
-static int
+int
 bpf_program__load(struct bpf_program *prog,
                  char *license, u32 kern_version)
 {
index 511c1294dcbf34833e75b0c3e3df6c7fec6c15f1..2ed24d3f80b36adba93ab968ff7727142ba80131 100644 (file)
@@ -128,10 +128,13 @@ void bpf_program__set_ifindex(struct bpf_program *prog, __u32 ifindex);
 
 const char *bpf_program__title(struct bpf_program *prog, bool needs_copy);
 
+int bpf_program__load(struct bpf_program *prog, char *license,
+                     u32 kern_version);
 int bpf_program__fd(struct bpf_program *prog);
 int bpf_program__pin_instance(struct bpf_program *prog, const char *path,
                              int instance);
 int bpf_program__pin(struct bpf_program *prog, const char *path);
+void bpf_program__unload(struct bpf_program *prog);
 
 struct bpf_insn;