| .. | .. |
|---|
| 14 | 14 | |
|---|
| 15 | 15 | #include <bpf/bpf.h> |
|---|
| 16 | 16 | |
|---|
| 17 | +#include <bpf/libbpf.h> |
|---|
| 17 | 18 | #include "bpf_insn.h" |
|---|
| 18 | | -#include "bpf_load.h" |
|---|
| 19 | 19 | #include "sock_example.h" |
|---|
| 20 | 20 | |
|---|
| 21 | 21 | #define BPF_F_PIN (1 << 0) |
|---|
| .. | .. |
|---|
| 29 | 29 | #define BPF_M_UNSPEC 0 |
|---|
| 30 | 30 | #define BPF_M_MAP 1 |
|---|
| 31 | 31 | #define BPF_M_PROG 2 |
|---|
| 32 | + |
|---|
| 33 | +char bpf_log_buf[BPF_LOG_BUF_SIZE]; |
|---|
| 32 | 34 | |
|---|
| 33 | 35 | static void usage(void) |
|---|
| 34 | 36 | { |
|---|
| .. | .. |
|---|
| 57 | 59 | BPF_EXIT_INSN(), |
|---|
| 58 | 60 | }; |
|---|
| 59 | 61 | size_t insns_cnt = sizeof(insns) / sizeof(struct bpf_insn); |
|---|
| 62 | + struct bpf_object *obj; |
|---|
| 63 | + int prog_fd; |
|---|
| 60 | 64 | |
|---|
| 61 | 65 | if (object) { |
|---|
| 62 | | - assert(!load_bpf_file((char *)object)); |
|---|
| 63 | | - return prog_fd[0]; |
|---|
| 66 | + assert(!bpf_prog_load(object, BPF_PROG_TYPE_UNSPEC, |
|---|
| 67 | + &obj, &prog_fd)); |
|---|
| 68 | + return prog_fd; |
|---|
| 64 | 69 | } else { |
|---|
| 65 | 70 | return bpf_load_program(BPF_PROG_TYPE_SOCKET_FILTER, |
|---|
| 66 | 71 | insns, insns_cnt, "GPL", 0, |
|---|