Simple BPF examples.
Adapted from man 2 bpf
. The original example in the man page does
not compile. This example has all the necessary helpers to make it
working.
Build the target with make
and run it with packetcount <ifname>
.
Adapted from the stacksnoop.py
example in the
bcc project. This example is
implemented in C to demonstrated the following development process:
- develop kernel eBPF filter in C,
- use llvm to compile the kernel eBPF to an object file,
- userspace application load the eBPF object file to kernel.
Build the target with make
and run it with stacksnoop <func_name>
.
Proper cleanups and etc.