Exercises and sample created while learning eBPF.
- Learning eBPF book by Liz Rice
- Repository of sample code from the book
- eBPF website
- BPF Compiler Collection (BCC)
You can follow the instructions from Liz Rice's sample code repository
Alternatively you can install the tools manually.
- Install BCC (needed to run the Python examples). Find instructions for your OS
- Install
clang
compiler or LLVM - Install
libbpf
(needed to compile the C examples)
I went with the following options for my local setup:
- Install Ubuntu Desktop 22.04 on a virtual machine (using VMWare Workstation Player)
- Installed bcc tools using:
sudo apt-get install bpfcc-tools linux-headers-$(uname -r)
- Note: The bcc install instructions for Ubuntu warn that packages may be out of date and you should build from source to get the most up-to-date version. But I wasted a lot of time debugging compiler errors when I built from source that I prefered to risk it with the package manager.
- Installed clang using:
sudo apt install clang
(probably redundant since I also installed llvm) - Installed llvm using
sudp apt install llvm
- Installed libbpf using
sudo apt install libbpf-dev
- If building from source instead of a package manager, may also need to install
libelf-dev
and/or other dependencies
- If building from source instead of a package manager, may also need to install
- Installed
bpftool
by building from source:- Cloned the repo in my home directory:
git clone --recurse-submodules https://github.com/libbpf/bpftool.git
- Then
cd bpftool/src
- Then
make install
- Cloned the repo in my home directory: