[−][src]Crate redbpf_macros
Procedural macros to help writing eBPF programs using the redbpf-probes
crate.
Overview
redbpf-macros is part of the redbpf project. Together with
redbpf-probes, it
provides an idiomatic Rust API to write programs that can be compiled to eBPF
bytecode and executed by the linux in-kernel eBPF virtual machine.
To streamline the process of working with eBPF programs even further,
redbpf also provides
cargo-bpf - a cargo subcommand
to simplify creating and building eBPF programs.
Example
#![no_std] #![no_main] use redbpf_probes::xdp::prelude::*; // configure kernel version compatibility and license program!(0xFFFFFFFE, "GPL"); #[xdp] fn example_xdp_probe(ctx: XdpContext) -> XdpResult { // do something here Ok(XdpAction::Pass) }
Macros
| program | Generates program metadata. |
Attribute Macros
| kprobe | Attribute macro that must be used to define |
| kretprobe | Attribute macro that must be used to define |
| map | Attribute macro that must be used when creating eBPF maps. |
| socket_filter | Attribute macro that must be used to define |
| tc_action | Define tc action BPF programs |
| uprobe | Attribute macro that must be used to define |
| uretprobe | Attribute macro that must be used to define |
| xdp | Attribute macro that must be used to define |