#include <rte_compat.h>
#include <rte_common.h>
#include <rte_mbuf.h>
#include <bpf_def.h>
Go to the source code of this file.
RTE BPF support.
librte_bpf provides a framework to load and execute eBPF bytecode inside user-space dpdk based applications. It supports basic set of features from eBPF spec (https://www.kernel.org/doc/Documentation/networking/filter.txt).
Definition in file rte_bpf.h.
◆ RTE_BPF_ARG_PTR_TYPE
determine is argument a pointer
Definition at line 56 of file rte_bpf.h.
◆ rte_bpf_arg_type
Possible types for function/BPF program arguments.
Enumerator |
---|
RTE_BPF_ARG_UNDEF | undefined
|
RTE_BPF_ARG_RAW | scalar value
|
RTE_BPF_ARG_PTR | pointer to data buffer
|
RTE_BPF_ARG_PTR_MBUF | pointer to rte_mbuf
|
RTE_BPF_ARG_RESERVED | reserved for internal use
|
Definition at line 31 of file rte_bpf.h.
◆ rte_bpf_xtype
Possible types for external symbols.
Enumerator |
---|
RTE_BPF_XTYPE_FUNC | function
|
RTE_BPF_XTYPE_VAR | variable
|
Definition at line 61 of file rte_bpf.h.
◆ rte_bpf_destroy()
void rte_bpf_destroy |
( |
struct rte_bpf * |
bpf | ) |
|
De-allocate all memory used by this eBPF execution context.
- Parameters
-
bpf | BPF handle to destroy. |
◆ rte_bpf_load()
struct rte_bpf * rte_bpf_load |
( |
const struct rte_bpf_prm * |
prm | ) |
|
Create a new eBPF execution context and load given BPF code into it.
- Parameters
-
prm | Parameters used to create and initialise the BPF execution context. |
- Returns
- BPF handle that is used in future BPF operations, or NULL on error, with error code set in rte_errno. Possible rte_errno errors include:
- EINVAL - invalid parameter passed to function
- ENOMEM - can't reserve enough memory
◆ rte_bpf_elf_load()
struct rte_bpf * rte_bpf_elf_load |
( |
const struct rte_bpf_prm * |
prm, |
|
|
const char * |
fname, |
|
|
const char * |
sname |
|
) |
| |
Create a new eBPF execution context and load BPF code from given ELF file into it. Note that if the function will encounter EBPF_PSEUDO_CALL instruction that references external symbol, it will treat is as standard BPF_CALL to the external helper function.
- Parameters
-
prm | Parameters used to create and initialise the BPF execution context. |
fname | Pathname for a ELF file. |
sname | Name of the executable section within the file to load. |
- Returns
- BPF handle that is used in future BPF operations, or NULL on error, with error code set in rte_errno. Possible rte_errno errors include:
- EINVAL - invalid parameter passed to function
- ENOMEM - can't reserve enough memory
◆ rte_bpf_exec()
uint64_t rte_bpf_exec |
( |
const struct rte_bpf * |
bpf, |
|
|
void * |
ctx |
|
) |
| |
Execute given BPF bytecode.
- Parameters
-
bpf | handle for the BPF code to execute. |
ctx | pointer to input context. |
- Returns
- BPF execution return value.
◆ rte_bpf_exec_burst()
uint32_t rte_bpf_exec_burst |
( |
const struct rte_bpf * |
bpf, |
|
|
void * |
ctx[], |
|
|
uint64_t |
rc[], |
|
|
uint32_t |
num |
|
) |
| |
Execute given BPF bytecode over a set of input contexts.
- Parameters
-
bpf | handle for the BPF code to execute. |
ctx | array of pointers to the input contexts. |
rc | array of return values (one per input). |
num | number of elements in ctx[] (and rc[]). |
- Returns
- number of successfully processed inputs.
◆ rte_bpf_get_jit()
int rte_bpf_get_jit |
( |
const struct rte_bpf * |
bpf, |
|
|
struct rte_bpf_jit * |
jit |
|
) |
| |
Provide information about natively compiled code for given BPF handle.
- Parameters
-
bpf | handle for the BPF code. |
jit | pointer to the rte_bpf_jit structure to be filled with related data. |
- Returns
- -EINVAL if the parameters are invalid.
- Zero if operation completed successfully.
◆ rte_bpf_dump()
__rte_experimental void rte_bpf_dump |
( |
FILE * |
f, |
|
|
const struct ebpf_insn * |
buf, |
|
|
uint32_t |
len |
|
) |
| |
Dump epf instructions to a file.
- Parameters
-
f | A pointer to a file for output |
buf | A pointer to BPF instructions |
len | Number of BPF instructions to dump. |
◆ rte_bpf_convert()
__rte_experimental struct rte_bpf_prm * rte_bpf_convert |
( |
const struct bpf_program * |
prog | ) |
|
Convert a Classic BPF program from libpcap into a DPDK BPF code.
- Parameters
-
prog | Classic BPF program from pcap_compile(). |
- Returns
- Pointer to BPF program (allocated with rte_malloc) that is used in future BPF operations, or NULL on error, with error code set in rte_errno. Possible rte_errno errors include:
- EINVAL - invalid parameter passed to function
- ENOMEM - can't reserve enough memory
- ENOTSUP - operation not supported