]> git.baikalelectronics.ru Git - kernel.git/commit
libbpf: Improve LINUX_VERSION_CODE detection
authorAndrii Nakryiko <andrii@kernel.org>
Wed, 22 Dec 2021 23:10:03 +0000 (15:10 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 29 Dec 2021 03:20:31 +0000 (19:20 -0800)
commita62393602638e0dfff7f17bd790467815a7eaecf
tree02e2914a801f88f5ebfa97c884057856e97ec2e1
parent3f9ff4d4e6f41352f726bf8bd6c0b6dc15fd55b4
libbpf: Improve LINUX_VERSION_CODE detection

Ubuntu reports incorrect kernel version through uname(), which on older
kernels leads to kprobe BPF programs failing to load due to the version
check mismatch.

Accommodate Ubuntu's quirks with LINUX_VERSION_CODE by using
Ubuntu-specific /proc/version_code to fetch major/minor/patch versions
to form LINUX_VERSION_CODE.

While at it, consolide libbpf's kernel version detection code between
libbpf.c and libbpf_probes.c.

  [0] Closes: https://github.com/libbpf/libbpf/issues/421

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/20211222231003.2334940-1-andrii@kernel.org
tools/lib/bpf/libbpf.c
tools/lib/bpf/libbpf_internal.h
tools/lib/bpf/libbpf_probes.c