Module aya::programs [−][src]
Expand description
eBPF program types.
eBPF programs are loaded inside the kernel and attached to one or more hook points. Whenever the hook points are reached, the programs are executed.
Loading and attaching programs
When you call Bpf::load_file
or Bpf::load
, all the programs included
in the object code are parsed and relocated. Programs are not loaded
automatically though, since often you will need to do some application
specific setup before you can actually load them.
In order to load and attach a program, you need to retrieve it using Bpf::program_mut
,
then call the load()
and attach()
methods, for example:
use aya::{Bpf, programs::KProbe}; use std::convert::TryInto; let mut bpf = Bpf::load_file("ebpf_programs.o")?; // intercept_wakeups is the name of the program we want to load let program: &mut KProbe = bpf.program_mut("intercept_wakeups")?.try_into()?; program.load()?; // intercept_wakeups will be called every time try_to_wake_up() is called // inside the kernel program.attach("try_to_wake_up", 0)?;
The signature of the attach()
method varies depending on what kind of
program you’re trying to attach.
Re-exports
Modules
Network traffic control programs.
Structs
A program used to inspect or filter network activity for a given cgroup.
A kernel probe.
The return type of program.attach(...)
.
A program used to decode IR into key events for a lirc device.
Provides information about a loaded program, like name, id and statistics
A program used to intercept messages sent with sendmsg()
/sendfile()
.
A program used to intercept ingress socket buffers.
A program used to work with sockets.
A program used to inspect and filter incoming packets on a socket.
A program that can be attached at a pre-defined kernel trace point.
An user space probe.
An XDP program.
Flags passed to Xdp::attach()
.
Enums
Defines where to attach a CgroupSkb
program.
The type returned when attaching a KProbe
fails.
eBPF program type.
Error type returned when working with programs.
The kind of SkSkb
program.
The type returned when attaching a SocketFilter
fails.
The type returned when attaching a TracePoint
fails.
The type returned when attaching an UProbe
fails.
The type returned when attaching an Xdp
program fails on kernels < 5.9
.