Skip to content

Commit 29cd77f

Browse files
joestringerborkmann
authored andcommitted
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>
1 parent b584ab8 commit 29cd77f

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

tools/lib/bpf/libbpf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ struct bpf_object {
228228
};
229229
#define obj_elf_valid(o) ((o)->efile.elf)
230230

231-
static void bpf_program__unload(struct bpf_program *prog)
231+
void bpf_program__unload(struct bpf_program *prog)
232232
{
233233
int i;
234234

@@ -1375,7 +1375,7 @@ load_program(enum bpf_prog_type type, enum bpf_attach_type expected_attach_type,
13751375
return ret;
13761376
}
13771377

1378-
static int
1378+
int
13791379
bpf_program__load(struct bpf_program *prog,
13801380
char *license, u32 kern_version)
13811381
{

tools/lib/bpf/libbpf.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,13 @@ void bpf_program__set_ifindex(struct bpf_program *prog, __u32 ifindex);
128128

129129
const char *bpf_program__title(struct bpf_program *prog, bool needs_copy);
130130

131+
int bpf_program__load(struct bpf_program *prog, char *license,
132+
u32 kern_version);
131133
int bpf_program__fd(struct bpf_program *prog);
132134
int bpf_program__pin_instance(struct bpf_program *prog, const char *path,
133135
int instance);
134136
int bpf_program__pin(struct bpf_program *prog, const char *path);
137+
void bpf_program__unload(struct bpf_program *prog);
135138

136139
struct bpf_insn;
137140

0 commit comments

Comments
 (0)