This is an eBPF / XDP example application using CO-RE in C.
- Using XDP to statistic received packets and print result in user space application.
- Only C language and libbpf are used.
- After compiled, there is a get_pkts user space applicaiton, it will load get_pkts_kern.o elf files to kernel and hook to network device.
- Linux OS with root account
- pre-request libraries:
ubuntu series OS:
# apt install zlib1g-dev gcc clang libelf1 libelf-dev -y
Red-Hat series OS:
# yum install make elfutils-dev clang -y
Git clone this repository
# git clone --recurse-submodules https://github.com/w180112/ebpf_example.git
Type
# cd ebpf_example
Run
# make
to compile
Then
# ./get_pkts <interface name> <option>
Note: The option here is --skb-mode or --drv-mode to determine native XDP mode is used or not
To remove the binary and elf files
# make clean