#bpf #bindings #kernel #collection #compiler #idiomatic #api-bindings

unmaintained bcc

Idiomatic Rust bindings for BPF Compiler Collection (BCC)

33 releases

0.0.34 Oct 25, 2023
0.0.33 Sep 9, 2022
0.0.32 Nov 24, 2021
0.0.31 Mar 30, 2021
0.0.3 Feb 8, 2018

#231 in Development tools

Download history 572/week @ 2024-07-22 563/week @ 2024-07-29 452/week @ 2024-08-05 570/week @ 2024-08-12 736/week @ 2024-08-19 511/week @ 2024-08-26 531/week @ 2024-09-02 504/week @ 2024-09-09 504/week @ 2024-09-16 886/week @ 2024-09-23 228/week @ 2024-09-30 484/week @ 2024-10-07 825/week @ 2024-10-14 692/week @ 2024-10-21 605/week @ 2024-10-28 495/week @ 2024-11-04

2,627 downloads per month
Used in 2 crates

MIT license

150KB
4K SLoC

rust-bcc

Warning! Unmaintained!

With the advances in other BPF crates in the Rust ecosystem, this crate is no longer actively maintained. We recommend adopting libbpf-rs

About

Idiomatic Rust bindings for the BPF compiler collection. The goal is to mimic the Python BCC bindings in https://github.com/iovisor/bcc in a Rusty way.

The C bcc API (as exposed in bcc-sys) is very powerful, but it's fairly nontrivial to try to use it by itself and manage all the resources it allocates safely.

This crate is currently experimental and has several things in it which are either unsafe or not particularly idiomatic for Rust. Pull requests very much appreciated.

Prerequisites

  • bcc v0.4.0-v0.23.0

Static linking

This crate allows for statically linking libbpf/libbcc which enables the creation of tools which have no runtime dependency on matching versions being present on target systems. To statically link, you may need to compile several dependencies from source. See the build/ci.sh script for how those dependencies are built and how we build and run statically linked examples in CI.

Getting Started

The best way to learn about how to use this crate right now is to read the examples. The exciting thing about these examples is that the Rust version isn't really more verbose than the Python version. In some ways the Rust code is more legible because it's much more natural to work with C data structure in Rust than it is in Python.

Building

This library uses features to allow support for multiple versions of bcc. Depending on what version of bcc you have installed, you may need to use a feature flag while building the examples in-order to match the expected version of bcc with the version you have installed on your system.

Examples

Dependencies

~5.5MB
~158K SLoC