#bpf #bindings #bcc

bcc

Idiomatic Rust bindings for BPF Compiler Collection (BCC)

25 releases

0.0.25 Sep 15, 2020
0.0.21 Jul 24, 2020
0.0.17 Mar 20, 2020
0.0.14 Dec 10, 2019
0.0.3 Feb 8, 2018

#26 in Development tools

Download history 36/week @ 2020-06-08 61/week @ 2020-06-15 9/week @ 2020-06-22 73/week @ 2020-06-29 369/week @ 2020-07-06 410/week @ 2020-07-13 1095/week @ 2020-07-20 283/week @ 2020-07-27 523/week @ 2020-08-03 396/week @ 2020-08-10 349/week @ 2020-08-17 475/week @ 2020-08-24 94/week @ 2020-08-31 189/week @ 2020-09-07 552/week @ 2020-09-14 279/week @ 2020-09-21

1,684 downloads per month

MIT license

98KB
2.5K SLoC

rust-bcc

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.15.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

~5MB
~144K SLoC