eBPF routing to/from interface devices on a host machine.
- llvm >= 10
- clang >= 10
- libelf
- Ubuntu >= 18.04 LTS
- libbpf & bpftool
- Add the appropriate repository:
add-apt-repository 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main'
-
Update packages:
sudo apt update
. -
Install the dependencies:
sudo apt-get install llvm-10 \
lldb-10 \
llvm-10-dev \
libllvm10 \
llvm-10-runtime \
clang-10 \
gcc-multilib
sudo ln -s /usr/bin/llvm-strip-10 /usr/bin/llvm-strip
sudo ln -s /usr/bin/clang-10 /usr/bin/clang
Ubuntu versions older than 20.04 dont come with libbpf
built-in thus,
we need to manually install the library from source in order to use its provided bpf
helpers.
- Clone the git repo of libbpf into you're work machine:
git clone https://github.com/libbpf/libbpf.git
- Run the following commands:
cd /src
sudo make install
Once installed you can make sure that the required headers are in the file system under /usr/include/bpf
.
Use the bpftool
to debug maps, programs, etc.
To download run: sudo apt install linux-tools-common
.
Run the following command: sudo cat /sys/kernel/debug/tracing/trace_pipe
Compile the program using make
, followed by: sudo ./fwrouter run
Use the following command: ip link
, and find the added interfaces listed.
To see the bpf
filter added use the following: sudo tc -s -d filter show dev eth0 ingress
.
Use the following command to remove the qdisc: sudo tc qdisc del dev eth0 clsact
.