Skip to main content

Crate bpf_tracing

Crate bpf_tracing 

Source
Expand description

Rich and event-based diagnostic information for eBPF.

It exports a set of macros that can be used to emit diagnostic events from eBPF programs. The events are efficiently copied to user space via a ring buffer and integrated into the tracing infrastructure.

§Example


tracing_subscriber::fmt()
    .with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
    .with_file(true)
    .with_line_number(true)
    .init();

let mut open_obj = MaybeUninit::uninit();
let skel_builder = SkelBuilder::default();
let open_skel = skel_builder.open(&mut open_obj)?;
let skel = open_skel.load()?;

bpf_tracing::try_init(skel.object());

And in your eBPF program:

bpf_info("Established socket [%pI4:%u->%pI4:%u]", &skey.local.ip4, skey.local.port, &skey.remote.ip4, skey.remote.port);

Functions§

try_init
Initializes a ring buffer reader that continuously observes and emits tracing events.