EBPF

From Wiki 4 Men
Jump to navigation Jump to search

https://www.srodi.com/posts/how-to-write-and-run-an-ebpf-program-on-linux/

https://www.wwt.com/blog/ebpf-is-the-bees-knees-for-enterprise-environments

https://medium.com/@megawan/writing-compiling-and-loading-ebpf-program-7b0efa014142

Prepare

Might be needed:

sudo ln -s /usr/include/x86_64-linux-gnu/asm /usr/include/asm

sudo apt install bpftool clang llvm libbpf-dev

bpftool btf dump file /sys/kernel/btf/vmlinux format c > vmlinux.h

Compile

clang -O2 -g -target bpf -c trace_file_delete.c -o trace_file_delete.o


Load

bpftool prog load trace_file_delete.o /sys/fs/bpf/trace_file_delete

List

bpftool prog list

Unload

rm /sys/fs/bpf/trace_file_delete

External Links

This is a draft article and so will not be published on A Voice for Men or appear in random article selections. Wiki4Men is looking for trustworthy editors that can turn draft articles in to featured articles. Information on how to apply is on the Main Page.

Technical articles in this category are applicable to Linux. Debian GNU/Linux is used in examples. Much of the information is also applicable to other Linux distributions and Unix flavours.