简体   繁体   English

如何获取 Linux 内核的 bpf_helpers.h 头文件?

[英]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.

相关问题 如何将 /kernel/sched/* 包含到 BPF 程序中? - How I can include the /kernel/sched/* into a BPF program? 编译树外Linux内核模块时如何解决stdarg.h没有这样的文件或目录? - How can I solve stdarg.h No such file or directory while compiling out-of-tree Linux kernel module? 如何获取正确的.config文件来编译特定于我的硬件的Linux内核源代码? - How do I get the correct .config file for compiling the Linux kernel source specific to my hardware? 我怎样才能得到 <linux/bootmem.h> 文件并修复错误“严重错误:linux / bootmem.h:没有这样的文件或目录#include <linux/bootmem.h> ”? - How can I get <linux/bootmem.h> fileand fix the error “fatal error: linux/bootmem.h: No such file or directory #include <linux/bootmem.h>”? 如何从Linux内核的PID中获取进程描述符? - How can I get the process descriptor from a PID in Linux kernel? 在linux内核模块中,如何获取已知路径的inode - In a linux kernel module, how can I get inode of a known path Linux内核编程:不能包含头文件 - Linux kernel programming: can't include header file linux / kernel.h:没有这样的文件或目录 - linux/kernel.h : No such file or directory 在Linux kernel中,当我们可以得到“struct file”时如何识别打开的文件 - In Linux kernel how to identify the opened file when we can get “struct file” 如何构建 Linux 内核以支持 SO_ATTACH_BPF 套接字选项? - How to build Linux kernel to support SO_ATTACH_BPF socket option?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM