Issue
I am developing an eBPF program on an Ubuntu machine:
$ uname -a
Linux ubuntu-bionic 4.18.0-16-generic #17~18.04.1-Ubuntu SMP Tue Feb 12 13:35:51 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
To do this I need both bpf.h
for a number of definitions as well bpf_helpers.h
for helper function definitions. I installed a new kernel with the headers:
apt-get update -y
apt-get install -y linux-image-4.18.0-16-generic linux-headers-4.18.0-16-generic
The headers include bpf.h
:
$ find /usr/src/linux-headers-4.18.0-16 -name bpf.h
/usr/src/linux-headers-4.18.0-16/include/uapi/linux/bpf.h
/usr/src/linux-headers-4.18.0-16/include/linux/bpf.h
but not bpf_helpers.h
:
$ find /usr/src/linux-headers-4.18.0-16 -name bpf_helpers.h
How can I get this file for my kernel and why is it not included with the distribution headers?
I could checkout a particular version of the Linux kernel or get the file from master but the distribution could have potentially made changes to upstream which makes me uncomfortable doing this.
Solution
bpf_helpers.h
is not distributed with the kernel headers, but with libbpf.
You can install libbpf on Ubuntu with:
apt install libbpf-dev
Or you can install it from the sources at https://github.com/libbpf/libbpf.
Answered By - pchaigno Answer Checked By - David Goodson (WPSolving Volunteer)