Crate redbpf

Source
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§

Enums§

Type Aliases§