It's trying different kernel versions and getting a -EINVAL. Checking the source code for bpf_prog_load(), I see that one of the ways for that function to return -EINVAL is if the given kern_version doesn't match the definition of LINUX_VERSION_CODE in /usr/include/linux/version.h (or wherever this header is).
This happens because my docker image has a different kernel version than my machine, and bpftrace uses the LINUX_VERSION_CODE macro in its version getter (preprocessing is a compile-time operation). This patch adds the ability for bpftrace to get the value of LINUX_VERSION_CODE at runtime, which is what we need to do if we want to run bpftrace on a different kernel version than it was compiled on.
After a build using docker, I was getting this error:
strace to the rescue:
It's trying different kernel versions and getting a
-EINVAL
. Checking the source code forbpf_prog_load()
, I see that one of the ways for that function to return-EINVAL
is if the givenkern_version
doesn't match the definition ofLINUX_VERSION_CODE
in/usr/include/linux/version.h
(or wherever this header is).This happens because my docker image has a different kernel version than my machine, and bpftrace uses the
LINUX_VERSION_CODE
macro in its version getter (preprocessing is a compile-time operation). This patch adds the ability for bpftrace to get the value ofLINUX_VERSION_CODE
at runtime, which is what we need to do if we want to run bpftrace on a different kernel version than it was compiled on.