Note: This readme is still a work in progress
There are 2 main directories:
ebpf
for ebpf-related cratesuserspace
for the user space side of things
This library is composed of 3 crates:
firewall-ebpf
with the ebpf codefirewall-common
code shared between ebpf and user-spacefirewall
library code
Furthermore, we have an example of how to use the library in userspace/firewall/examples/logger-firewall.rs
.
The library exposes functions to log and block traffic.
- Install a rust stable toolchain:
rustup install stable
- Install a rust nightly toolchain:
rustup install nightly
- Install bpf-linker:
cargo install bpf-linker
From userspace
:
cargo xtask codegen
To compile:
cd userspace && cargo build
cd userspace && cargo run --example logger-firewall -- --iface <interface_name>
To build using docker:
- run
./build-docker-builder.sh
- run
./build-with-docker.sh
All flags are passed to build-with-docker.sh
so if you will run in in wireguard add --features wireguard
when running the script.
After building
cd userspace/docker
docker compose build
docker compose up
- Bounded loops require kernel 5.3 see here
Note: We can pass
RUSTFLAGS=-C link-arg=--unroll-loops
to let the compiler try to unroll them instead.
- LPM Trie requires version 4.11
Architecture | Common devices | Minimum kernel required |
---|---|---|
amd64 |
Commodity hardware | |
armv7 |
Embedded devices | |
arm64 |
Commodity hardware, embedded devices | |
MIPS |
Embedded devices | |
RISC-V |
Embedded devices |