modulepackage
0.0.0-20240920015331-ff978e94500b
Repository: https://github.com/cloudflare/cbpfc.git
Documentation: pkg.go.dev
# README
cbpfc
cbpfc is a classic BPF (cBPF) to extended BPF (eBPF) compiler. It can compile cBPF to eBPF, or to C, and the generated code should be accepted by the kernel verifier.
cbpfc/clang is a simple clang wrapper for compiling C to eBPF.
Tests
Dependencies
clang
- Path can be set via environment variable
$CLANG
- Path can be set via environment variable
Unprivileged
go test -short
Full
-
Requires:
root
orCAP_SYS_ADMIN
to load XDP programs- Recent (4.14+) Linux kernel
-
sudo go test
# Packages
Package clang implements a simple wrapper for invoking clang to compile C to eBPF.
# Functions
ToC compiles a cBPF filter to a C function with a signature of:
uint32_t opts.FunctionName(const uint8_t *const data, const uint8_t *const data_end)
The function returns the filter's return value: 0 if the packet does not match the cBPF filter, non 0 if the packet does match.
ToEBF converts a cBPF filter to eBPF.