# l3-l4-forwarding-in-xdp L3/L4 XDP-based forwarding system for BIRD and Linux routers for achieving line-speed forwarding. This project implements Layer 3 (IP) and Layer 4 (TCP/UDP) packet forwarding using eBPF and XDP (eXpress Data Path). It leverages the high-performance capabilities of XDP for efficient packet processing in the Linux kernel with bird or FRR. **Note:** `xdp-tools` is highly recommended for loading and managing the XDP program. ## Installation Install the necessary dependencies using `apt`: ```bash apt update apt install clang llvm libbpf-dev libelf-dev pkg-config make git bpftool xdp-tools ``` ## Compilation Compile the eBPF program from the source code: ```bash clang -O2 -g -Wall -target bpf -D__BPF_TRACING__ -I /usr/src/linux-headers-$(uname -r)/include -c main.c -o main.o ``` This will generate the object file `main.o` which contains the compiled eBPF code. ## Usage ### Attach to the Interface Load the XDP program onto a network interface (e.g., `eth0`): ```bash xdp-loader load eth0 ./main.o ``` Check the status of loaded XDP programs: ```bash xdp-loader status ``` ### Monitoring and Debugging Use `bpftool` to inspect maps and statistics: ```bash bpftool map show ``` These commands will display information about the eBPF maps used in the program, such as flow statistics. ## Unloading the Program To unload the XDP program from the interface: ```bash xdp-loader unload eth0 ```