| 264 | } |
| 265 | |
| 266 | static struct rte_bpf * |
| 267 | bpf_load_elf(const struct rte_bpf_prm *prm, int32_t fd, const char *section) |
| 268 | { |
| 269 | Elf *elf; |
| 270 | Elf_Data *sd; |
| 271 | size_t sidx; |
| 272 | int32_t rc; |
| 273 | struct rte_bpf *bpf; |
| 274 | struct rte_bpf_prm np; |
| 275 | |
| 276 | elf_version(EV_CURRENT); |
| 277 | elf = elf_begin(fd, ELF_C_READ, NULL); |
| 278 | |
| 279 | rc = find_elf_code(elf, section, &sd, &sidx); |
| 280 | if (rc == 0) |
| 281 | rc = elf_reloc_code(elf, sd, sidx, prm); |
| 282 | |
| 283 | if (rc == 0) { |
| 284 | np = prm[0]; |
| 285 | np.ins = sd->d_buf; |
| 286 | np.nb_ins = sd->d_size / sizeof(struct ebpf_insn); |
| 287 | bpf = rte_bpf_load(&np); |
| 288 | } else { |
| 289 | bpf = NULL; |
| 290 | rte_errno = -rc; |
| 291 | } |
| 292 | |
| 293 | elf_end(elf); |
| 294 | return bpf; |
| 295 | } |
| 296 | |
| 297 | struct rte_bpf * |
| 298 | rte_bpf_elf_load(const struct rte_bpf_prm *prm, const char *fname, |
no test coverage detected