Closed bitness closed 7 months ago
For some reason your program is causing our CO-RE code to bail out. 195896080
is 0xbad2310
in hex, which is https://github.com/cilium/ebpf/blob/4927ec860f48ed564beb410ffff2575cfbb2d98b/btf/core.go#L44 So most likely the cause is that there is a slight mismatch between libbpf and our rules around type eqality for CO-RE.
Can you please upload the compiled BPF .o
? Compiling it on my machine doesn't work out of the box.
Certainly, here are the compiled object files. I'm including the ones from the go build as well as the one I built for the libbpf program, which was compiled with this command:
clang -g -O2 -target bpf -march=probe -D__TARGET_ARCH_x86 -Ix86/ -c rmdir-watch.bpf.c -o rmdir-watch.bpf.o
I'm doing the build on an AlmaLinux 9.1 machine with the clang-14.0.6-4.el9_1.x86_64
RPM. Here's its version output:
clang version 14.0.6 (Red Hat 14.0.6-4.el9_1)
Target: x86_64-redhat-linux-gnu
Thread model: posix
InstalledDir: /bin
The libbpf RPM is libbpf-0.6.0-1.el9.x86_64
. Its source rpm is here if that's helpful.
Also, if it helps--even with libbpf, I've found that I have to use bpf_core_read
and friends to access data through pointers I get out of container_of
usage. I think the pointer math it does is weird enough to confuse libbpf's automatic access conversions.
So, the problem is that struct nfs_inode
is not part of vmlinux BTF, instead it is part of module nfs
. Our current CO-RE code is oblivious to kernel modules, and so can't find nfs_inode
. We don't bail out with an error, since it's valid to reference non-existent types when their use is guarded by if core_type_exists(...)
.
So, unfortunately, you've run into the last remaining point of #705. I'm also unhappy that the error message is so obtuse, unfortunately the error is output by the kernel. Maybe there is a way to improve that.
Thanks for tracking this down! I subscribed to #705 and will try again once it's resolved.
This should be doable now.
Hello, I'm having trouble using the kernel's
container_of
macro in a BPF program loaded with cilium/ebpf v0.10.0. This program works as expected when loaded with libbpf 0.6.0 or by runningsudo bpftool prog load rmdir-watch.bpf.o /sys/fs/bpf/rmdir-watch
.I'll attach a zip file with all the files needed to reproduce it, but to summarize, the BPF program tries to do this:
container_of
does some pointer math:When I run the go code using cilium/ebpf's bpf20 and calling
loadBpfObjects
to load the BPF program, it fails with this:Some details about the machine I'm developing on:
When I run the same BPF program through libbpf 0.6.0, I'm able to write a simple C program that logs some of the
struct nfs_inode
's data whenever a directory is removed on an NFS mount. If the BPF program is working in that context, or throughbpftool prog load
, should I expect that it'd also work with cilium/ebpf v0.10.0 without changes?In the attached zip file, the
justfile
has the commands used for building the Go test program and the C program. If the Go program loads the BPF program without error, it'll just print "it worked!" and exit; currently it prints the error above. The C program will succeed and log NFS rmdir calls.Thanks for any advice! container-of-repro.zip