This patch aims to deal with the recent compilation breakage in CentOS 8 Stream, and the future RHEL 8.7 release. Due to a change in the kernel-4.18.0-394, which has implemented ktime_get_coarse_boottime_ns() and caused a redefinition error. According to the response from Red Hat Bugzilla #2103865. It doesn't seem that change will be reverted. So we have to deal with it in WireGuard.
In this patch, the addition in compat.h is actually very similar to the previous abandoned commit 99935b0. But the condition is a little more precise. There is a new definition named RHEL_KERNEL_RELEASE represents RHEL-specific kernel versioning. E.g., 372 from 4.18.0-372.16.1. The RHEL_KERNEL_RELEASE definition is generated by the shell command in the modified Kbuild.include. It will return 0 if there is no RHEL kernel version found. Signed-off-by: Red Shen <darkranger_...@hotmail.com> --- src/compat/Kbuild.include | 2 ++ src/compat/compat.h | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/compat/Kbuild.include b/src/compat/Kbuild.include index 0192ecd..f170a42 100644 --- a/src/compat/Kbuild.include +++ b/src/compat/Kbuild.include @@ -109,3 +109,5 @@ endif ifneq ($(shell grep -s -F "\#define LINUX_PACKAGE_ID \" Debian " "$(CURDIR)/include/generated/package.h"),) ccflags-y += -DISDEBIAN endif + +ccflags-y += -DRHEL_KERNEL_RELEASE=$(shell grep -s -E '^\#define RHEL_RELEASE[[:space:]]+"[[:digit:]]+' "$(CURDIR)/include/generated/uapi/linux/version.h"| sed 's/\./ /g'| sed 's/"/ /g' | awk '{print $$3} END {if (!NR) print "0"}') diff --git a/src/compat/compat.h b/src/compat/compat.h index 69dada8..4f8ee69 100644 --- a/src/compat/compat.h +++ b/src/compat/compat.h @@ -16,6 +16,9 @@ #define ISRHEL7 #elif RHEL_MAJOR == 8 #define ISRHEL8 +#if RHEL_MINOR >= 7 && RHEL_KERNEL_RELEASE >= 394 +#define IS_NEWER_RHEL8 +#endif #endif #endif #ifdef UTS_UBUNTU_RELEASE_ABI @@ -387,7 +390,7 @@ static inline int get_random_bytes_wait(void *buf, int nbytes) #define system_power_efficient_wq system_unbound_wq #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 3, 0) +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 3, 0) && !defined(IS_NEWER_RHEL8) #include <linux/ktime.h> #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0) #include <linux/hrtimer.h> -- 1.8.3.1