Skip to content

Commit

Permalink
libbpf: Support loading individual progs
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Joe Stringer authored and Daniel Borkmann committed Oct 3, 2018
1 parent b584ab8 commit 29cd77f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tools/lib/bpf/libbpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -1375,7 +1375,7 @@ load_program(enum bpf_prog_type type, enum bpf_attach_type expected_attach_type,
return ret;
}

static int
int
bpf_program__load(struct bpf_program *prog,
char *license, u32 kern_version)
{
Expand Down
3 changes: 3 additions & 0 deletions tools/lib/bpf/libbpf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 29cd77f

Please sign in to comment.