libbpf: Fix debian kernel version information parsing

Currently get_debian_kernel_version() expects the version to be in the
form of x.y.z but the Debian kernels uploaded to experimental are not
always LTS kernels. Like the current Debian kernel in experimental
is 7.2~rc7-1~exp1 and uname -v reported "Debian 7.2~rc7-1~exp1".

Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20260831134537.1227914-1-sudipm.mukherjee@gmail.com
This commit is contained in:
Sudip Mukherjee authored and Andrii Nakryiko committed 2026-10-02 05:41:50 -07:00
1 parent 0256cea002
commit bb78d847a7
1 file changed
+7 -4
+7 -4
View File
@@ -62,7 +62,7 @@ static __u32 get_ubuntu_kernel_version(void)
*/
static __u32 get_debian_kernel_version(struct utsname *info)
{
__u32 major, minor, patch;
__u32 major, minor, patch = 0;
char *p;
p = strstr(info->version, "Debian ");
@@ -71,10 +71,13 @@ static __u32 get_debian_kernel_version(struct utsname *info)
return 0;
}
if (sscanf(p, "Debian %u.%u.%u", &major, &minor, &patch) != 3)
return 0;
if (sscanf(p, "Debian %u.%u.%u", &major, &minor, &patch) == 3)
return KERNEL_VERSION(major, minor, patch);
return KERNEL_VERSION(major, minor, patch);
if (sscanf(p, "Debian %u.%u", &major, &minor) == 2)
return KERNEL_VERSION(major, minor, patch);
return 0;
}
__u32 get_kernel_version(void)