This is an example to demonstrate tracing system calls using ebpf programs by running them at various syscall tracepoints. The various syscalls traced in this demo are read(), recvfrom(), write(), and sendto().
User application will be statically linked to libbpf. To facilitate that, the build machine needs static libbpf.a library and its path must be exported before invoking the make.
-
export LIBBPF. Populate LIBBPF variable with the path of the libbpf.a archive file.
-
Run make.
$ export LIBBPF="/home/vagrant/libbpf.a" #Use appropriate path here
$ makeA successfull invocation of make generates the user application 'loader' and the bpf object file 'EXE'
By default, the resulting ebpf program will trace application named 'nginx'. To build the ebpf code for intercepting applications other than 'nginx', pass the application name with -DAPP_NAME macro. For example,
$ make CFLAGS='-DAPP_NAME=\"server\"'The resulting ebpf binary will trace applications named 'server'
$ ./loaderlibbpf source code is available at https://github.com/libbpf/libbpf The page has instructions on how to build a static libbpf.a archive.