From: wireguard@wut.to
To: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: WireGuard mailing list <wireguard@lists.zx2c4.com>
Subject: Re: making wireguard work on RHEL7/etc.
Date: Mon, 26 Jun 2017 20:55:02 +0100 (BST) [thread overview]
Message-ID: <alpine.LRH.2.20.1706262050540.17486@bcny.fcbq.bet> (raw)
In-Reply-To: <CAHmME9ph1LQ0kufpf2RMDsMRpz7txWJGvr=d=Jr5Z1kxqqOWfQ@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 88 bytes --]
I think this might work ...
I was still able to compile on Amazon AMI/4.9.32 Kernel
[-- Attachment #2: Type: text/plain, Size: 6176 bytes --]
diff --git a/src/compat/compat.h b/src/compat/compat.h
index 159abb1..903c9be 100644
--- a/src/compat/compat.h
+++ b/src/compat/compat.h
@@ -7,6 +7,13 @@
#include <linux/version.h>
#include <linux/types.h>
+//#undef LINUX_VERSION_CODE
+//#define LINUX_VERSION_CODE KERNEL_VERSION(3, 18, 0)
+
+#if defined(RHEL_MAJOR) && RHEL_MAJOR <= 7
+#define ISRHEL7
+#endif
+
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 10, 0)
#error "WireGuard requires Linux >= 3.10"
#endif
@@ -15,7 +22,7 @@
#define CONFIG_AS_SSSE3
#endif
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 0)
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 0)) && !defined(ISRHEL7)
#define headers_start data
#define headers_end data
#endif
@@ -34,13 +41,15 @@
#endif
#if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 19, 0) && LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 6)) || \
- (LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 12) && LINUX_VERSION_CODE > KERNEL_VERSION(3, 17, 0)) || \
- (LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 8) && LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0)) || \
- LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 40)
+ (LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 12) && LINUX_VERSION_CODE > KERNEL_VERSION(3, 17, 0)) || \
+ (LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 8) && LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0)) || \
+ LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 40)
+#if !defined(ISRHEL7)
#define dev_recursion_level() 0
#endif
+#endif
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0)
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0)) && !defined(ISRHEL7)
#define ipv6_dst_lookup(a, b, c, d) ipv6_dst_lookup(b, c, d)
#endif
@@ -49,21 +58,21 @@
(LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 27) && LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || \
(LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 8) && LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0)) || \
(LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 40) && LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)) || \
- (LINUX_VERSION_CODE < KERNEL_VERSION(3, 12, 54))
+ (LINUX_VERSION_CODE < KERNEL_VERSION(3, 12, 54) || defined(ISRHEL7))
#include <linux/if.h>
#include <net/ip_tunnels.h>
#define IP6_ECN_set_ce(a, b) IP6_ECN_set_ce(b)
#endif
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0))
#define time_is_before_jiffies64(a) time_after64(get_jiffies_64(), a)
#define time_is_after_jiffies64(a) time_before64(get_jiffies_64(), a)
#define time_is_before_eq_jiffies64(a) time_after_eq64(get_jiffies_64(), a)
#define time_is_after_eq_jiffies64(a) time_before_eq64(get_jiffies_64(), a)
#endif
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 12, 0) && IS_ENABLED(CONFIG_IPV6)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 12, 0) && IS_ENABLED(CONFIG_IPV6) && !defined(ISRHEL7)
#include <net/ipv6.h>
struct ipv6_stub_type {
void *udpv6_encap_enable;
@@ -114,17 +123,17 @@ static inline u32 get_random_u32(void)
}
#endif
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 0) && !defined(ISRHEL7)
static inline void netif_keep_dst(struct net_device *dev)
{
dev->priv_flags &= ~IFF_XMIT_DST_RELEASE;
}
#endif
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0) && !defined(ISRHEL7)
#define pcpu_sw_netstats pcpu_tstats
#define netdev_alloc_pcpu_stats alloc_percpu
-#elif LINUX_VERSION_CODE < KERNEL_VERSION(3, 15, 0)
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(3, 15, 0) && !defined(ISRHEL7)
#define netdev_alloc_pcpu_stats(type) \
({ \
typeof(type) __percpu *pcpu_stats = alloc_percpu(type); \
@@ -153,7 +162,7 @@ static inline void *our_pskb_put(struct sk_buff *skb, struct sk_buff *tail, int
#define pskb_put our_pskb_put
#endif
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 11, 0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 11, 0) && !defined(ISRHEL7)
#include <net/xfrm.h>
static inline void skb_scrub_packet(struct sk_buff *skb, bool xnet)
{
@@ -175,7 +184,7 @@ static inline void skb_scrub_packet(struct sk_buff *skb, bool xnet)
}
#endif
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 12, 0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 12, 0) && !defined(ISRHEL7)
#include <linux/random.h>
static inline u32 prandom_u32_max(u32 ep_ro)
{
@@ -183,7 +192,7 @@ static inline u32 prandom_u32_max(u32 ep_ro)
}
#endif
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 10, 75)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 10, 75) && !defined(ISRHEL7)
#define U8_MAX ((u8)~0U)
#define S8_MAX ((s8)(U8_MAX >> 1))
#define S8_MIN ((s8)(-S8_MAX - 1))
@@ -198,7 +207,7 @@ static inline u32 prandom_u32_max(u32 ep_ro)
#define S64_MIN ((s64)(-S64_MAX - 1))
#endif
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 10, 60)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 10, 60) && !defined(ISRHEL7)
/* Making this static may very well invalidate its usefulness,
* but so it goes with compat code. */
static inline void memzero_explicit(void *s, size_t count)
@@ -208,7 +217,7 @@ static inline void memzero_explicit(void *s, size_t count)
}
#endif
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 12, 0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 12, 0) && !defined(ISRHEL7)
static const struct in6_addr our_in6addr_any = IN6ADDR_ANY_INIT;
#define in6addr_any our_in6addr_any
#endif
@@ -267,11 +276,11 @@ static inline int get_random_bytes_wait(void *buf, int nbytes)
}
#endif
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 11, 0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 11, 0) && !defined(ISRHEL7)
#define system_power_efficient_wq system_unbound_wq
#endif
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0) && !defined(ISRHEL7)
#include <linux/ktime.h>
static inline u64 ktime_get_ns(void)
{
@@ -339,4 +348,7 @@ static inline struct net_device *netdev_pub(void *dev)
#define net_dbg_skb_ratelimited(fmt, skb, ...)
#endif
+#if defined(ISRHEL7)
+#undef ISRHEL7
+#endif
#endif
next prev parent reply other threads:[~2017-06-26 19:38 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-24 15:18 wireguard
2017-06-26 8:07 ` Aaron Muir Hamilton
2017-06-26 8:19 ` wireguard
2017-06-26 9:04 ` Jason A. Donenfeld
2017-06-26 9:25 ` wireguard
2017-06-26 9:57 ` Jason A. Donenfeld
2017-06-26 10:47 ` Jason A. Donenfeld
2017-06-26 19:55 ` wireguard [this message]
2017-06-27 11:02 ` Jason A. Donenfeld
2017-06-26 20:45 ` wireguard
2017-06-27 11:05 ` Jason A. Donenfeld
2017-06-27 11:38 ` wireguard
2017-06-27 19:23 ` Jason A. Donenfeld
2017-06-27 19:43 ` wireguard
2017-06-27 19:59 ` Jason A. Donenfeld
2017-06-27 20:22 ` Jason A. Donenfeld
2017-06-27 20:52 ` Jason A. Donenfeld
2017-06-27 21:30 ` wireguard
2017-06-27 22:09 ` Jason A. Donenfeld
2017-06-27 5:35 ` Andrej Kacian
2017-06-27 7:25 ` wireguard
2017-06-27 9:39 ` Andrej Kacian
2017-06-27 11:08 ` Jason A. Donenfeld
2018-04-05 15:08 ` Daniel Kahn Gillmor
2018-04-05 16:15 ` Daniel Kahn Gillmor
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=alpine.LRH.2.20.1706262050540.17486@bcny.fcbq.bet \
--to=wireguard@wut.to \
--cc=Jason@zx2c4.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).