MEng Project - Accelerating network communication patterns using eBPF
- The following dependencies are needed (note
clang+llvm-12
is required):
$ sudo apt-get update
$ sudo apt install -y build-essential pkgconf git make gcc clang-12 llvm-12 libelf-dev gcc-multilib
-
Ensure you have installed
liburing
and its headers on your system:$ git clone https://github.com/axboe/liburing
$ cd liburing
$ ./configure && make
$ sudo make install
-
Clone this project (and all the submodules) using:
$ git clone --recurse-submodules https://gitlab.doc.ic.ac.uk/ac3419/meng-project.git
-
Build and install
libbpf
on your system (included as a submodule insidesgbpf
):$ cd meng-project/sgbpf/dep/libbpf/src
$ make all
$ sudo DESTDIR=root make install
$ sudo make install_headers
$ sudo make install_uapi_headers
-
This assumes you have followed the steps above and installed all the required dependencies.
-
Create a new directory. For this example, it will be called
my-project
. -
Add a Makefile pointing to the correct
libbpf
andsgbpf
locations (seemy-project/Makefile
). -
Write your program using the
sgbpf
library (seemy-project/main.cpp
for an example). -
Run
make install
to buildlibbpf
andsgbpf
libraries. -
Run
make
to build your program.- If you get a linker error (eg: undefined references), try re-running
make install
and thenmake
.
- If you get a linker error (eg: undefined references), try re-running
-
Now, you need to build the BPF object files that contain the programs that will be loaded into the kernel:
-
You may optionally set the
OUTPUT_BPF_OBJ_DIR
environment variable to a (full) directory in which the built object files will be placed. If ommitted, the object files will be placed underbpfobj/
in the sgbpf directory by default. -
You are required to set the
CUSTOM_AGGREGATION_BPF_PROG
environment variable which should be the FULL path to your source file written in C containing the custom aggregation logic in a XDP program (which must be namedaggregation_prog
). See the example inmy-project/custom_aggregation.bpf.c
. Example (from insidemy-project
):export CUSTOM_AGGREGATION_BPF_PROG=$(pwd)/custom_aggregation.bpf.c
-
Now, run
make --directory=<path/to/sgbpf> bpf
to build all required BPF object files.
-
-
Create a line-separated config file containing a list of worker endpoints, in the format: IPv4_Address:Port (see the example in
my-project
). -
Run your program:
sudo ./sg_program <path/to/bpfobjs> lo
(remember that to load BPF programs, you need admin privileges).
Note: When running the loader program, if you get a message about the missing shared library libbpf.so.1
, you can copy the missing shared object to lib/x86_64-linux-gnu
from the build inside libbpf/src
using: sudo cp sgbpf/dep/libbpf/src/libbpf.so.1 /lib/x86_64-linux-gnu/