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

Function bpf_load

dpdk/lib/bpf/bpf_load.c:15–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13#include "bpf_impl.h"
14
15static struct rte_bpf *
16bpf_load(const struct rte_bpf_prm *prm)
17{
18 uint8_t *buf;
19 struct rte_bpf *bpf;
20 size_t sz, bsz, insz, xsz;
21
22 xsz = prm->nb_xsym * sizeof(prm->xsym[0]);
23 insz = prm->nb_ins * sizeof(prm->ins[0]);
24 bsz = sizeof(bpf[0]);
25 sz = insz + xsz + bsz;
26
27 buf = mmap(NULL, sz, PROT_READ | PROT_WRITE,
28 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
29 if (buf == MAP_FAILED)
30 return NULL;
31
32 bpf = (void *)buf;
33 bpf->sz = sz;
34
35 memcpy(&bpf->prm, prm, sizeof(bpf->prm));
36
37 if (xsz > 0)
38 memcpy(buf + bsz, prm->xsym, xsz);
39 memcpy(buf + bsz + xsz, prm->ins, insz);
40
41 bpf->prm.xsym = (void *)(buf + bsz);
42 bpf->prm.ins = (void *)(buf + bsz + xsz);
43
44 return bpf;
45}
46
47/*
48 * Check that user provided external symbol.

Callers 1

rte_bpf_loadFunction · 0.70

Calls 1

memcpyFunction · 0.50

Tested by

no test coverage detected