Crate redbpf[−][src]
Expand description
Rust API to load BPF programs.
Overview
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 https://github.com/foniod/redbpf/tree/master/redbpf-tools.
Example
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() { kprobe .attach_kprobe(&kprobe.name(), 0) .expect(&format!("error attaching program {}", kprobe.name())); }
Modules
Structs
Array map corresponding to BPF_MAP_TYPE_ARRAY
Type to work with kprobes
or kretprobes
.
A builder of Module
Per-cpu array map corresponding to BPF_MAP_TYPE_PERCPU_ARRAY
A structure representing values of per-cpu map structures such as PerCpuArray
Program array map.
SockMap structure for storing file descriptors of TCP sockets by userspace program.
Type to work with socket filters
.
Type to work with stream_parser
BPF programs.
Type to work with stream_verdict
BPF programs.
Type to work with uprobes
or uretprobes
.
Type to work with XDP
programs.