NOTE: since the bpf2go library generates the go skeletal code using clang and other linux-based tools, I could not create a general way of writing eBPF programs in mac. Might be a nice project to create a compiler for all this, but not in scope currently. The code was moved to the repository “rutu-sh/cloudlab-ebpf”
Any eBPF experiment contains two main components:
eBPF programs are quite easy to write. But writing the scaffolding code, which is responsible for loading the eBPF program into the kernel is the hardest part. There are quite a lot of libraries to write the loader programs, and I’m choosing the one that’s used widely: ebpf-go
. This library is used by Cilium, containerd, datadog, Istio, and more
.
This setup would include a three node setup used in a previous example (Trying out eBPF and XDP)
Went the repository and created a github codespace
Opened it locally in VS Code
Installed eBPF dependencies
sudo apt-get update
sudo apt install clang llvm libelf-dev libpcap-dev build-essential libc6-dev-i386
sudo apt install linux-tools-azure
sudo apt install linux-headers-azure
sudo apt install linux-tools-common linux-tools-generic
sudo apt install tcpdump
sudo apt install m4
sudo apt install libbpf-dev
I added these commands, along with the commands to install go in scripts/install.sh