24 releases (6 stable)

1.3.0 Dec 7, 2020
1.2.0 Oct 28, 2020
1.1.2 Sep 16, 2020
1.0.0 Apr 1, 2020
0.1.1 Sep 26, 2018

#45 in Development tools

Download history 181/week @ 2021-01-13 124/week @ 2021-01-20 128/week @ 2021-01-27 177/week @ 2021-02-03 299/week @ 2021-02-10 145/week @ 2021-02-17 57/week @ 2021-02-24 63/week @ 2021-03-03 61/week @ 2021-03-10 102/week @ 2021-03-17 197/week @ 2021-03-24 159/week @ 2021-03-31 122/week @ 2021-04-07 93/week @ 2021-04-14 212/week @ 2021-04-21 60/week @ 2021-04-28

796 downloads per month
Used in cargo-bpf


16K SLoC

C 11K SLoC // 0.1% comments Rust 4K SLoC // 0.0% comments Shell 377 SLoC // 0.1% comments BASH 44 SLoC // 0.0% comments


LICENSE CircleCI element

A Rust eBPF toolchain.


The redbpf project is a collection of tools and libraries to build eBPF programs using Rust. It includes:

  • redbpf - a user space library that can be used to load eBPF programs

  • redbpf-probes - an idiomatic Rust API to write eBPF programs that can be loaded by the linux kernel

  • redbpf-macros - companion crate to redbpf-probes which provides convenient procedural macros useful when writing eBPF programs

  • cargo-bpf - a cargo subcommand for creating, building and debugging eBPF programs


In order to use redbpf you need LLVM 11 and the headers for the kernel you want to target.

Linux kernel

The minimum kernel version supported is 4.19. Kernel headers are discovered automatically, or you can use the KERNEL_SOURCE environment variable to point to a specific location. Building against a linux source tree is supported as long as you run make prepare first.

Installing dependencies on Debian based distributions

On Debian, Ubuntu and derivatives you can install the dependencies running:

sudo apt-get -y install build-essential zlib1g-dev \
		llvm-11-dev libclang-11-dev linux-headers-$(uname -r)

If your distribution doesn't have LLVM 11, you can add the official LLVM APT repository to your sources.list.

Installing dependencies on RPM based distributions

First ensure that your distro includes LLVM 11:

yum info llvm-devel | grep Version
Version      : 11.0.0

If you don't have vesion 11, you can get it from the Fedora 33 repository.

Then install the dependencies running:

yum install clang llvm-devel zlib-devel kernel-devel

Getting started

The easiest way to get started is using cargo-bpf, see the documentation for more info.

redbpf-tools is a cargo-bpf generated crate that includes simple examples you can use to understand how to structure your programs.

Finally the ingraind project includes more concrete examples of redbpf programs.

Building from source

After cloning the repository run:

git submodule sync
git submodule update --init

Install the dependencies as documented above, then run cargo build as usual.


This repository contains code from other software in the following directories, licensed under their own particular licenses:

  • bpf-sys/libelf/*: GPL2 + LGPL3
  • bpf-sys/bcc/*: Apache2, public domain
  • include/bpf_helpers.h LGPL2 + BSD-2
  • include/bpf_helper_defs.h: LGPL2 + BSD-2
  • bpf-sys/libbpf: LGPL2 + BSD-2

Where '+' means they are dual licensed.

RedBPF and its components, unless otherwise stated, are licensed under either of

at your option.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


~181K SLoC