Development discussion of WireGuard
 help / color / mirror / Atom feed
From: Shen Red <darkranger_red@hotmail.com>
To: "wireguard@lists.zx2c4.com" <wireguard@lists.zx2c4.com>
Subject: [PATCH] compat: don't backport ktime_get_coarse_boottime_ns to kernel-4.18.0-394
Date: Wed, 27 Jul 2022 08:38:27 +0000	[thread overview]
Message-ID: <SYBP282MB04604E97C0764B3D6FF3D27FF2979@SYBP282MB0460.AUSP282.PROD.OUTLOOK.COM> (raw)

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_red@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

                 reply	other threads:[~2022-07-27  8:38 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=SYBP282MB04604E97C0764B3D6FF3D27FF2979@SYBP282MB0460.AUSP282.PROD.OUTLOOK.COM \
    --to=darkranger_red@hotmail.com \
    --cc=wireguard@lists.zx2c4.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).