你好,我是醉墨居士,本次我们学习一下eBPF,我们基于libbpf-bootstrap来进行我们的eBPF程序开发
一台Debian12操作系统的计算机,我使用的是Debian12.2.0-amd64
其它Linux发行版的环境也可以,Linux内核不低于5.4版本
c语言,linux系统基本操作
sudo apt install clang libelf1 libelf-dev zlib1g-dev build-essential
git clone --recurse-submodules https://github.com/libbpf/libbpf-bootstrap
cd ./libbpf-bootstrap/examples/c
make sockfilter
cd ./.output/bpftool/bootstrap
./bpftool btf dump file /sys/kernel/btf/vmlinux format c > vmlinux.h
mv vmlinux.h ../../../vmlinux.h
cd ../../..
make fentry
如果编译未报错,那么我们的开发环境就配置好了
我们的环境搭建就到此为止了,接下来让我们继续去探索eBPF吧