[英]How can I get the bpf_helpers.h header file for my Linux kernel?
I am developing an eBPF program on an Ubuntu machine:我正在 Ubuntu 机器上开发 eBPF 程序:
$ 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.要做到这一点,我需要两个
bpf.h
了许多的定义以及bpf_helpers.h
的辅助函数的定义。 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
:头文件包括
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
:但不是
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.我可以检出特定版本的 Linux 内核或从master获取文件,但发行版可能对上游进行了更改,这让我感到不舒服。
bpf_helpers.h
is not distributed with the kernel headers . bpf_helpers.h
不随内核头文件一起分发 。 As suggested by agg3l in comments, you could copy it from Ubuntu's linux-source package . 正如评论中的agg3l所建议的那样,你可以从Ubuntu的linux-source包中复制它。
On Ubuntu I installed libbpf-dev to get that header:在 Ubuntu 上,我安装了 libbpf-dev 来获取该标头:
sudo apt-get install libbpf-dev
$ apt-file list libbpf-dev | grep bpf_helpers.h
libbpf-dev: /usr/include/bpf/bpf_helpers.h
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.