Struct aya::BpfLoader [−][src]
pub struct BpfLoader<'a> { /* fields omitted */ }
Expand description
Builder style API for advanced loading of eBPF programs.
Loading eBPF code involves a few steps, including loading maps and applying
relocations. You can use BpfLoader
to customize some of the loading
options.
Examples
use aya::{BpfLoader, Btf};
use std::fs;
let bpf = BpfLoader::new()
// load the BTF data from /sys/kernel/btf/vmlinux
.btf(Btf::from_sys_fs().ok().as_ref())
// load pinned maps from /sys/fs/bpf/my-program
.map_pin_path("/sys/fs/bpf/my-program")
// finally load the code
.load_file("file.o")?;
Implementations
Sets the target BTF info.
The loader defaults to loading BTF
info using Btf::from_sys_fs.
Use this method if you want to load BTF
from a custom location or
pass None
to disable BTF
relocations entirely.
Example
use aya::{BpfLoader, Btf, Endianness};
let bpf = BpfLoader::new()
// load the BTF data from a custom location
.btf(Btf::parse_file("/custom_btf_file", Endianness::default()).ok().as_ref())
.load_file("file.o")?;
Sets the base directory path for pinned maps.
Pinned maps will be loaded from path/MAP_NAME
.
Example
use aya::BpfLoader;
let bpf = BpfLoader::new()
.map_pin_path("/sys/fs/bpf/my-program")
.load_file("file.o")?;
Loads eBPF bytecode from a file.
Examples
use aya::BpfLoader;
let bpf = BpfLoader::new().load_file("file.o")?;