| 295 | } |
| 296 | |
| 297 | struct rte_bpf * |
| 298 | rte_bpf_elf_load(const struct rte_bpf_prm *prm, const char *fname, |
| 299 | const char *sname) |
| 300 | { |
| 301 | int32_t fd, rc; |
| 302 | struct rte_bpf *bpf; |
| 303 | |
| 304 | if (prm == NULL || fname == NULL || sname == NULL) { |
| 305 | rte_errno = EINVAL; |
| 306 | return NULL; |
| 307 | } |
| 308 | |
| 309 | fd = open(fname, O_RDONLY); |
| 310 | if (fd < 0) { |
| 311 | rc = errno; |
| 312 | RTE_BPF_LOG(ERR, "%s(%s) error code: %d(%s)\n", |
| 313 | __func__, fname, rc, strerror(rc)); |
| 314 | rte_errno = EINVAL; |
| 315 | return NULL; |
| 316 | } |
| 317 | |
| 318 | bpf = bpf_load_elf(prm, fd, sname); |
| 319 | close(fd); |
| 320 | |
| 321 | if (bpf == NULL) { |
| 322 | RTE_BPF_LOG(ERR, |
| 323 | "%s(fname=\"%s\", sname=\"%s\") failed, " |
| 324 | "error code: %d\n", |
| 325 | __func__, fname, sname, rte_errno); |
| 326 | return NULL; |
| 327 | } |
| 328 | |
| 329 | RTE_BPF_LOG(INFO, "%s(fname=\"%s\", sname=\"%s\") " |
| 330 | "successfully creates %p(jit={.func=%p,.sz=%zu});\n", |
| 331 | __func__, fname, sname, bpf, bpf->jit.func, bpf->jit.sz); |
| 332 | return bpf; |
| 333 | } |
nothing calls this directly
no test coverage detected