Skip to content

BPF library for Async Rust, complementary for libbpf-rs.

License

BSD-2-Clause, LGPL-2.1 licenses found

Licenses found

BSD-2-Clause
LICENSE-BSD2
LGPL-2.1
LICENSE-LGPL21
Notifications You must be signed in to change notification settings

fujita/libbpf-async

libbpf-async

A library for writing BPF programs in Async Rust, complementary for libbpf-rs, Rust wrapper for libbpf.

Currently, this provides Async-friendly APIs for BPF ring buffer.

To use in your project, add into your Cargo.toml:

[dependencies]
libbpf-async = "0.2"

Example

#[tokio::main]
async fn main() {
    let mut builder = TracerSkelBuilder::default();
    let mut skel = builder.open().unwrap().load().unwrap();

    let mut rb = libbpf_async::RingBuffer::new(skel.obj.map_mut("ringbuf").unwrap());
    loop {
        let mut buf = [0; 128];
        let n = rb.read(&mut buf).await.unwrap();
        // do something useful with the buffer
    }
}

A working example code can be found here.

License

This work is dual-licensed under BSD 2-clause license and GNU LGPL v2.1 license. You can choose between one of them if you use this work.

About

BPF library for Async Rust, complementary for libbpf-rs.

Resources

License

BSD-2-Clause, LGPL-2.1 licenses found

Licenses found

BSD-2-Clause
LICENSE-BSD2
LGPL-2.1
LICENSE-LGPL21

Stars

Watchers

Forks

Releases

No releases published

Contributors 4

  •  
  •  
  •  
  •  

Languages