This source file includes following definitions.
- bpf_prog_test_load
- bpf_test_load_program
1
2
3
4 #include <bpf/bpf.h>
5 #include <bpf/libbpf.h>
6 #include <string.h>
7
8 int bpf_prog_test_load(const char *file, enum bpf_prog_type type,
9 struct bpf_object **pobj, int *prog_fd)
10 {
11 struct bpf_prog_load_attr attr;
12
13 memset(&attr, 0, sizeof(struct bpf_prog_load_attr));
14 attr.file = file;
15 attr.prog_type = type;
16 attr.expected_attach_type = 0;
17 attr.prog_flags = BPF_F_TEST_RND_HI32;
18
19 return bpf_prog_load_xattr(&attr, pobj, prog_fd);
20 }
21
22 int bpf_test_load_program(enum bpf_prog_type type, const struct bpf_insn *insns,
23 size_t insns_cnt, const char *license,
24 __u32 kern_version, char *log_buf,
25 size_t log_buf_sz)
26 {
27 struct bpf_load_program_attr load_attr;
28
29 memset(&load_attr, 0, sizeof(struct bpf_load_program_attr));
30 load_attr.prog_type = type;
31 load_attr.expected_attach_type = 0;
32 load_attr.name = NULL;
33 load_attr.insns = insns;
34 load_attr.insns_cnt = insns_cnt;
35 load_attr.license = license;
36 load_attr.kern_version = kern_version;
37 load_attr.prog_flags = BPF_F_TEST_RND_HI32;
38
39 return bpf_load_program_xattr(&load_attr, log_buf, log_buf_sz);
40 }