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 #include +//#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 #include #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 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 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 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 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