fuchsia.ebpf

Added: HEAD

PROTOCOLS

ProgramLinker

Defined in fuchsia.ebpf/ebpf.fidl

Protocol used by a target process to link and compile a verified eBPF program with its local process addresses (maps, helpers, and struct mappings).

Links the program using the provided linkage info, returning either an executable VMO containing JIT-compiled machine code or linked bytecode for interpreter execution.

This is a one-shot method; the server closes the channel after sending the response.

NameType
payload ProgramLinkageInfo
NameType
payload ProgramLinker_Link_Result

STRUCTS

Bytecode

Defined in fuchsia.ebpf/ebpf.fidl

Linked eBPF bytecode for interpreter execution.

FieldTypeDescriptionDefault
instructions vector<uint64>:4096

Program instructions.

No default

HelperLinkage

Defined in fuchsia.ebpf/ebpf.fidl

Relocation info for an eBPF helper function in a target process.

FieldTypeDescriptionDefault
id uint32

Helper function ID.

No default
fn_addr uint64

Function address in the target process.

Must be a non-zero address of a function using the platform C calling convention (extern "C") with the signature:

uint64_t helper(
    void* run_context,
    uint64_t arg1,
    uint64_t arg2,
    uint64_t arg3,
    uint64_t arg4,
    uint64_t arg5);

where run_context is the opaque context pointer passed by the runner when invoking the compiled program, arg1..arg5 correspond to eBPF registers r1..r5, and the return value is placed in r0.

No default

MapLinkage

Defined in fuchsia.ebpf/ebpf.fidl

Relocation info for an eBPF map in a target process.

FieldTypeDescriptionDefault
map_addr uint64

Address of the map object in the target process.

No default
data_addr uint64

Address of the map's data buffer in the target process for eBPF array maps, or 0 if not applicable.

No default

MapSchema

Defined in fuchsia.ebpf/ebpf.fidl

Schema of an eBPF map.

FieldTypeDescriptionDefault
type MapType

Map type.

No default
key_size uint32

Key size in bytes.

No default
value_size uint32

Value size in bytes.

No default
max_entries uint32

Maximum number of entries in the map.

No default
flags MapFlags

Map flags.

No default

ProgramHandle resource

Defined in fuchsia.ebpf/ebpf.fidl

A handle of an eBPF program.

FieldTypeDescriptionDefault
handle handle<eventpair> No default

ProgramId

Defined in fuchsia.ebpf/ebpf.fidl

An ID used to uniquely identify an eBPF program. The ID is the KOID of the ProgramHandle.

FieldTypeDescriptionDefault
id zx/Koid No default

Defined in fuchsia.ebpf/ebpf.fidl

FieldTypeDescriptionDefault

StructFieldMapping

Defined in fuchsia.ebpf/ebpf.fidl

Relocation info for a struct field offset mapping.

FieldTypeDescriptionDefault
struct_id StructId

Identifier of the struct being remapped.

No default
source_offset uint64

Offset of the field in the UAPI struct.

No default
target_offset uint64

Offset of the field in the host struct.

No default

ENUMS

LinkError flexible

Type: uint32

Defined in fuchsia.ebpf/ebpf.fidl

Error returned by ProgramLinker.Link.

NameValueDescription
1

A struct field mapping has an unknown StructId, an out-of-range offset, or a required 32-bit pointer field is not mapped.

2

ProgramLinkageInfo.maps does not match VerifiedProgram.maps, is missing data_addr for an array map direct value access, or has an invalid map offset.

3

The program calls a helper function that is missing from ProgramLinkageInfo.helpers or has a zero fn_addr.

4

The program contains packet access instructions (BPF_LD | BPF_ABS or BPF_LD | BPF_IND), but ProgramLinkageInfo.packet_load_fn_addr was not provided.

5

The program contains a malformed instruction that cannot be linked.

MapType strict

Type: uint32

Defined in fuchsia.ebpf/ebpf.fidl

Type of an eBPF maps.

NameValueDescription
1

An array map. Equivalent to BPF_MAP_TYPE_ARRAY.

2

A hash map. Equivalent to BPF_MAP_TYPE_HASH.

3

A hash map. Equivalent to BPF_MAP_TYPE_RINGBUF.

4

A per-CPU array. Equivalent to BPF_MAP_TYPE_PERCPU_ARRAY.

5

A per-CPU hash map. Equivalent to BPF_MAP_TYPE_PERCPU_HASH.

6

A device-map that holds references to network devices. Equivalent to BPF_MAP_TYPE_DEVMAP.

7

A longest prefix match trie. Equivalent to BPF_MAP_TYPE_LPM_TRIE.

8

A LRU hash map. Equivalent to BPF_MAP_TYPE_LRU_HASH.

9

A socket storage map. Equivalent to BPF_MAP_TYPE_SK_STORAGE.

StructId flexible

Type: uint32

Defined in fuchsia.ebpf/ebpf.fidl

An identifier of a struct that may be passed to an eBPF program.

NameValueDescription
1
2
3
4
5
6

TABLES

Map resource

Defined in fuchsia.ebpf/ebpf.fidl

A representation of eBPF map that can be shared between processes.

OrdinalFieldTypeDescription
schema MapSchema

Map schema.

vmo handle<vmo>

VMO used to store the map data. The layout of the data stored in the VMO depends on the schema as defined in the ebpf_api create.

ProgramLinkageInfo

Defined in fuchsia.ebpf/ebpf.fidl

Target-process linkage information required to link and compile an eBPF program.

OrdinalFieldTypeDescription
struct_mappings vector<StructFieldMapping>:256

Struct field offset mappings for the program's context arguments.

helpers vector<HelperLinkage>:256

Helper function addresses in the target process.

maps vector<MapLinkage>:4096

Map addresses in the target process.

Must have the same length as VerifiedProgram.maps and a one-to-one mapping with the maps in VerifiedProgram.maps.

packet_load_fn_addr uint64

Address of the packet-load trampoline function in the target process.

Required if the eBPF program contains legacy packet access instructions (BPF_LD | BPF_ABS or BPF_LD | BPF_IND); if omitted or 0 when the program contains these instructions, ProgramLinker.Link fails with LinkError.MISSING_PACKET_LOAD_FN. May be omitted or 0 if the program does not use these instructions.

When provided, must be the address of a function in the target process using the platform C calling convention (extern "C") with the signature:

uint64_t packet_load_fn(
    void* run_context,
    uint64_t skb,
    int32_t reg_offset,
    int32_t imm_offset,
    uint32_t width_bytes,
    uint64_t* out_value);

where run_context is the opaque context pointer passed by the runner, skb is the packet pointer held in eBPF register r6, reg_offset + imm_offset is the byte offset into the packet (reg_offset is 0 for BPF_ABS or the source register value for BPF_IND), and width_bytes is the load width in bytes (1, 2, 4, or 8). On success, the function writes the loaded host-endian value to *out_value and returns 1. On out-of-bounds access, it returns 0, causing the eBPF program to immediately exit with return value 0.

VerifiedProgram resource

Defined in fuchsia.ebpf/ebpf.fidl

A verified eBPF program.

OrdinalFieldTypeDescription
linker client_end:ProgramLinker

Linker channel for linking and compiling the program.

maps vector<Map>:4096

List of the maps used by the program. The program may reference these maps by their index in this array.

UNIONS

LinkedProgram flexible resource

Defined in fuchsia.ebpf/ebpf.fidl

Result of linking an eBPF program via ProgramLinker.Link.

OrdinalVariantTypeDescription
compiled_program handle<vmo>

Executable VMO containing JIT-compiled machine code.

bytecode Bytecode

Linked bytecode for interpreter execution when the producer does not use JIT compilation.

Defined in fuchsia.ebpf/ebpf.fidl

OrdinalVariantTypeDescription

BITS

MapFlags flexible

Type: uint32

Defined in fuchsia.ebpf/ebpf.fidl

Map flags.

NameValueDescription
1

Memory is not pre-allocated.

2

bpf() syscall can read from the map, but can't write to it.

4

bpf() syscall can write to the map, but can't read it.

8

The map can be mapped in a Starnix process's address space.

16

Clones the storage when the parent socket is cloned. Equivalent to BPF_F_CLONE.

32

Programs can only read from the map. Equivalent to BPF_F_RDONLY_PROG.

CONSTANTS

NameValueTypeDescription
COMPILED_PROGRAM_RIGHTS

Required handle rights for a JIT-compiled program VMO.

MAX_PROGRAM_HELPERS 256 uint32

Maximum number of helper functions in ProgramLinkageInfo.

MAX_PROGRAM_INSTRUCTIONS 4096 uint32

Maximum allowed number of instructions in an eBPF program.

MAX_PROGRAM_MAPS 4096 uint32

Maximum number of maps an eBPF program can use.

MAX_STRUCT_FIELD_MAPPINGS 256 uint32

Maximum number of struct field mappings in ProgramLinkageInfo.

PROGRAM_DEFUNCT_SIGNAL 16777216 uint32

The signal raised on a ProgramHandle to indicate that the program should be dropped.