bcc
bcc copied to clipboard
Issue with bcc tools execution
Ubuntu Server 20.04.3 LTS, Kernel 5.4.0-84-generic This is similar to 3386 i have tried both package installer and build from source method but get this error
~# tcplife-bpfcc
modprobe: FATAL: Module kheaders not found in directory /lib/modules/5.4.0-84-generic
Unable to find kernel headers. Try rebuilding kernel with CONFIG_IKHEADERS=m (module)
chdir(/lib/modules/5.4.0-84-generic/build): No such file or directory
Traceback (most recent call last):
File "/usr/sbin/tcplife-bpfcc", line 456, in <module>
b = BPF(text=bpf_text)
File "/usr/lib/python3/dist-packages/bcc/__init__.py", line 347, in __init__
raise Exception("Failed to compile BPF module %s" % (src_file or "<text>"))
Exception: Failed to compile BPF module <text>
I think the CONFIG_IKHEADERS=m option is enabled in the kernel build
root@server1:/# cat /usr/src/linux-headers-5.4.0-84-generic/.config | grep CONFIG_IKHEADERS
CONFIG_IKHEADERS=m
# dpkg --get-selections | grep linux
binutils-x86-64-linux-gnu install
console-setup-linux install
libselinux1:amd64 install
linux-base install
linux-firmware install
linux-generic install
linux-headers-5.4.0-84 install
linux-headers-5.4.0-84-generic install
linux-headers-5.4.0-89 install
linux-headers-5.4.0-89-generic install
linux-headers-generic install
linux-image-5.4.0-81-generic deinstall
linux-image-5.4.0-84-generic install
linux-image-5.4.0-89-generic install
linux-image-generic install
linux-libc-dev:amd64 install
linux-modules-5.4.0-81-generic deinstall
linux-modules-5.4.0-84-generic install
linux-modules-5.4.0-89-generic install
linux-modules-extra-5.4.0-81-generic deinstall
linux-modules-extra-5.4.0-84-generic install
linux-modules-extra-5.4.0-89-generic install
util-linux install
# uname -r
5.4.0-84-generic
If you have tried build from source
, try:
$ cd tools
$ sudo ./tcplife.py
@chenhengqi , it returned same error
root@server1:/check/bcc# ./tools/execsnoop.py
modprobe: FATAL: Module kheaders not found in directory /lib/modules/5.4.0-84-generic
Unable to find kernel headers. Try rebuilding kernel with CONFIG_IKHEADERS=m (module) or installing the kernel development package for your running kernel version.
chdir(/lib/modules/5.4.0-84-generic/build): No such file or directory
Traceback (most recent call last):
File "./tools/execsnoop.py", line 227, in <module>
b = BPF(text=bpf_text)
File "/usr/lib/python2.7/dist-packages/bcc/__init__.py", line 479, in __init__
raise Exception("Failed to compile BPF module %s" % (src_file or "<text>"))
Exception: Failed to compile BPF module <text>
root@server1:/check/bcc# ./tools/tcplife.py
modprobe: FATAL: Module kheaders not found in directory /lib/modules/5.4.0-84-generic
Unable to find kernel headers. Try rebuilding kernel with CONFIG_IKHEADERS=m (module) or installing the kernel development package for your running kernel version.
chdir(/lib/modules/5.4.0-84-generic/build): No such file or directory
Traceback (most recent call last):
File "./tools/tcplife.py", line 474, in <module>
b = BPF(text=bpf_text)
File "/usr/lib/python2.7/dist-packages/bcc/__init__.py", line 479, in __init__
raise Exception("Failed to compile BPF module %s" % (src_file or "<text>"))
Exception: Failed to compile BPF module <text>
root@server1:/check/bcc# pwd /check/bcc
root@server1:/check/bcc# ls
build CMakeLists.txt CONTRIBUTING-SCRIPTS.md Dockerfile.debian Dockerfile.ubuntu examples images introspection LICENSE.txt man README.md snap src tools
cmake CODEOWNERS debian Dockerfile.tests docs FAQ.txt INSTALL.md libbpf-tools LINKS.md QUICKSTART.md scripts SPECS tests
When installing BCC both package installer and build from source method , the two libbpf packages could cause conflicts. Try compiling and installing the release version of BCC tools in a pure clean environment at https://github.com/iovisor/bcc/releases/tag/v0.15.0. Good luck!
The problem of software package version mismatch can be solved by keeping the linux-xxx-5.4.0-84-generic version and uninstalling other versions.