Fail to get exact Centos kernel version

Viewed 41

uname -a tells the "kernel version" is 3.10.0

[root@iZbp16uggk8lf3x949ewxiZ ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
[root@iZbp16uggk8lf3x949ewxiZ ~]# uname -a
Linux iZbp16uggk8lf3x949ewxiZ 3.10.0-957.21.3.el7.x86_64 #1 SMP Tue Jun 18 16:35:19 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

LINUX_VERSION_CODE also says current kernel version is 3.10.0

[root@iZbp16uggk8lf3x949ewxiZ ~]# grep -rni "LINUX_VERSION_CODE" /usr/include/
/usr/include/linux/version.h:1:#define LINUX_VERSION_CODE 199168

But When I find a kernel function tcp_rtx_synack exist

[root@iZbp16uggk8lf3x949ewxiZ ~]# cat /proc/kallsyms | grep tcp_rtx_synack
ffffffff952a0700 t tcp_rtx_synack.part.26
ffffffff952a0730 T tcp_rtx_synack
ffffffff95721f90 r __ksymtab_tcp_rtx_synack
ffffffff95739e78 r __kcrctab_tcp_rtx_synack
ffffffff95765c36 r __kstrtab_tcp_rtx_synack

3.17 https://elixir.bootlin.com/linux/v3.17/A/ident/tcp_rtx_synack func tcp_rtx_synack exist
3.16 https://elixir.bootlin.com/linux/v3.17/A/ident/tcp_rtx_synack func tcp_rtx_synack not exist
Which means my centos kernel version is at least 3.17 not 3.10

I'm writting the eBPF which need more exact kernel version info because function and data struct are different from each kernel version.

I have buy two VMs on different Cloud provisioner and both VMs show like above.

1 Answers

CentOS, like RHEL, contains backports of various patches (features, fixes, etc.) to older kernel versions. So you can't rely on the kernel version to know which features or functions are available.

Instead, you can either probe for the available features from userspace (e.g., with bpftool feature probe) or use CO-RE to detect it with BTF.

Related