MCPcopy Create free account
hub / github.com/F-Stack/f-stack / rte_bpf_elf_load

Function rte_bpf_elf_load

dpdk/lib/bpf/bpf_load_elf.c:297–333  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

295}
296
297struct rte_bpf *
298rte_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}

Callers

nothing calls this directly

Calls 2

bpf_load_elfFunction · 0.85
closeFunction · 0.50

Tested by

no test coverage detected