* Load BPF instructions to kernel * * @param[in] type * BPF program type: classifier or action * * @param[in] insns * Array of BPF instructions (equivalent to BPF instructions) * * @param[in] insns_cnt * Number of BPF instructions (size of array) * * @param[in] license * License string that must be acknowledged by the kernel * * @return * -1 if the BPF program couldn't be
| 111 | * -1 if the BPF program couldn't be loaded, fd (file descriptor) otherwise |
| 112 | */ |
| 113 | static int bpf_load(enum bpf_prog_type type, |
| 114 | const struct bpf_insn *insns, |
| 115 | size_t insns_cnt, |
| 116 | const char *license) |
| 117 | { |
| 118 | union bpf_attr attr = {}; |
| 119 | |
| 120 | bzero(&attr, sizeof(attr)); |
| 121 | attr.prog_type = type; |
| 122 | attr.insn_cnt = (__u32)insns_cnt; |
| 123 | attr.insns = ptr_to_u64(insns); |
| 124 | attr.license = ptr_to_u64(license); |
| 125 | attr.log_buf = ptr_to_u64(NULL); |
| 126 | attr.log_level = 0; |
| 127 | attr.kern_version = 0; |
| 128 | |
| 129 | return sys_bpf(BPF_PROG_LOAD, &attr, sizeof(attr)); |
| 130 | } |
| 131 | |
| 132 | /** |
| 133 | * Create BPF map for RSS rules |
no test coverage detected