Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpftool not found for kernel 6.5.0-26 #1

Open
lneto opened this issue Mar 30, 2024 · 8 comments
Open

bpftool not found for kernel 6.5.0-26 #1

lneto opened this issue Mar 30, 2024 · 8 comments

Comments

@lneto
Copy link

lneto commented Mar 30, 2024

Firstly, thank you very much for this example! I'm opening this issue because it might be useful for others. I tried to run it on Ubuntu 22.04 with kernel 6.5 and I needed to update linux-tools as described below:

$ uname -a
Linux ubuntu 6.5.0-26-generic #26~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Mar 12 19:16:50 UTC 2 aarch64 aarch64 aarch64 GNU/Linux
$ make
bpftool btf dump file /sys/kernel/btf/vmlinux format c > vmlinux.h
WARNING: bpftool not found for kernel 6.5.0-26

  You may need to install the following packages for this specific kernel:
    linux-tools-6.5.0-26-generic
    linux-cloud-tools-6.5.0-26-generic

  You may also want to install one of the following packages to keep up to date:
    linux-tools-generic
    linux-cloud-tools-generic
make: *** [Makefile:4: vmlinux] Error 2
$ sudo apt-get install linux-tools-6.5.0-26-generic
$ make
bpftool btf dump file /sys/kernel/btf/vmlinux format c > vmlinux.h
clang -target bpf -Wall -O2 -c example.bpf.c
bpftool gen skeleton example.bpf.o > example.skel.h
gcc -Wall -o test test.c -lbpf
$ sudo ./test
[success] drop ICMP packets
[success] pass non-ICMP packets
@pvvm
Copy link

pvvm commented Jun 25, 2024

Would you know the version of bpftool that this command installs?
Because I'm currently facing an error where bpf_prog_test_run_opts always returns error 524 and I also have kernel 6.5.0. So, I wonder if it might be related.
The current version of bpftool I have installed is 7.2

@lneto
Copy link
Author

lneto commented Jun 25, 2024

it will depend on the kernel version..

ubuntu@ubuntu:~/lunatik$ dpkg-query -L linux-tools-$(uname -r)
/.
/usr
/usr/lib
/usr/lib/linux-tools
/usr/lib/linux-tools/6.5.0-41-generic
/usr/share
/usr/share/doc
/usr/share/doc/linux-tools-6.5.0-41-generic
/usr/share/doc/linux-tools-6.5.0-41-generic/copyright
/usr/lib/linux-tools/6.5.0-41-generic/bpftool
/usr/lib/linux-tools/6.5.0-41-generic/cpupower
/usr/lib/linux-tools/6.5.0-41-generic/libperf-jvmti.so
/usr/lib/linux-tools/6.5.0-41-generic/perf
/usr/lib/linux-tools/6.5.0-41-generic/usbip
/usr/lib/linux-tools/6.5.0-41-generic/usbipd
/usr/share/doc/linux-tools-6.5.0-41-generic/changelog.Debian.gz
ubuntu@ubuntu:~/lunatik$ /usr/lib/linux-tools/6.5.0-41-generic/bpftool version
bpftool v7.3.0
using libbpf v1.3
features:

try sudo apt install linux-tools-$(uname -r); I've created a PR for this.

you might be also interested in this small article I wrote ;-).

@pvvm
Copy link

pvvm commented Jun 25, 2024

I guess bpftool version isn't what is causing my problem. But thanks for the help anyway!

@pvvm
Copy link

pvvm commented Jun 25, 2024

Actually, could you please also tell me the version of clang and llc you are using?
Because I've just tested executing a similar program on Kernel 5.11.0 and with clang-11, and it is working well. While in the other machine I have 6.5.0 and clang-16.

@lneto
Copy link
Author

lneto commented Jun 26, 2024

ubuntu@ubuntu:~/lunatik$ clang --version
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
ubuntu@ubuntu:~/lunatik$ llc --version
Ubuntu LLVM version 14.0.0

  Optimized build.
  Default target: aarch64-unknown-linux-gnu
  Host CPU: (unknown)

@lneto
Copy link
Author

lneto commented Jun 26, 2024

@pvvm did you check your libebpf version? I would recommend you to get it from github, as I pointed in this article:

$ git clone -b v1.4.2 --depth 1 --recurse-submodules https://github.com/xdp-project/xdp-tools.git
$ cd xdp-tools/lib/libbpf/src
$ make
$ sudo DESTDIR=/ make install
$ cd ../../../
$ make libxdp
$ cd xdp-loader
$ make
$ sudo make install
$ cd ../../

@pvvm
Copy link

pvvm commented Jun 26, 2024

Thank you very much for your help! And the article looks pretty good!
But I sorted out a way to solve my problem in this post I made

@lneto
Copy link
Author

lneto commented Jun 27, 2024

btw, even that it doesn't see related.. just for the records.. I've had a trouble with SEC("xdp_drop_icmp") and needed to change it to SEC("xdp") to make it work..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants