Crate redbpf[][src]

Expand description

Rust API to load BPF programs.


The redbpf crate provides an idiomatic Rust API to load and interact with BPF programs. It is part of the larger redbpf project.

BPF programs used with redbpf are typically created and built with cargo-bpf, and use the redbpf-probes and redbpf-macros APIs.

For full featured examples on how to use redbpf see


The following example loads all the kprobes defined in the file iotop.elf.

use redbpf::load::Loader;

let mut loader = Loader::load_file("iotop.elf").expect("error loading probe");

// attach all the kprobes defined in iotop.elf
for kprobe in loader.kprobes_mut() {
        .attach_kprobe(&, 0)
        .expect(&format!("error attaching program {}",;



Array map corresponding to BPF_MAP_TYPE_ARRAY

A structure for reading data from BPF iterators

A BPF hash map structure

Type to work with kprobes or kretprobes.

A BPF LRU hash map structure

An LRU per-cpu BPF hash map structure

A base BPF map data structure

A builder of Module

Per-cpu array map corresponding to BPF_MAP_TYPE_PERCPU_ARRAY

A per-cpu BPF hash map structure

A structure representing values of per-cpu map structures such as PerCpuArray

Program array map.

Type to work with sk_lookup BPF programs.

SockMap structure for storing file descriptors of TCP sockets by userspace program.

Type to work with socket filters.

A stacktrace BPF map structure

Type to work with stream_parser BPF programs.

Type to work with stream_verdict BPF programs.

A structure supporting BPF iterators that handle task

Type to work with uprobes or uretprobes.

Type to work with XDP programs.


A BPF program defined in a Module.

Type Definitions