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

Function bpf_load

dpdk/drivers/net/tap/tap_bpf_api.c:113–130  ·  view source on GitHub ↗

* 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

Source from the content-addressed store, hash-verified

111 * -1 if the BPF program couldn't be loaded, fd (file descriptor) otherwise
112 */
113static 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

Callers 2

tap_flow_bpf_cls_qFunction · 0.70

Calls 3

bzeroFunction · 0.85
ptr_to_u64Function · 0.85
sys_bpfFunction · 0.85

Tested by

no test coverage detected