Repository : ssh://git@open-mesh.org/batman-adv
On branch : master
commit a42eafc55fd9a5d351822f7209e02975c1cf21cf Author: Sven Eckelmann sven@narfation.org Date: Sat Jan 25 19:58:32 2020 +0100
batman-adv: Provide backports-like kernel version helpers
The backports.git provides internal helper function to simplify the comparison of the LINUX_VERSION_CODE against the current kernel version. Also add thes to the batman-adv private compat helpers to simplify these kind of checks.
Signed-off-by: Sven Eckelmann sven@narfation.org
a42eafc55fd9a5d351822f7209e02975c1cf21cf compat-include/linux/average.h | 4 ++-- compat-include/linux/build_bug.h | 2 +- compat-include/linux/cache.h | 4 ++-- compat-include/linux/compiler.h | 8 ++++---- compat-include/linux/ethtool.h | 4 ++-- compat-include/linux/fs.h | 8 ++++---- compat-include/linux/if_bridge.h | 16 ++++++++-------- compat-include/linux/igmp.h | 6 +++--- compat-include/linux/list.h | 8 ++++---- compat-include/linux/netdevice.h | 22 +++++++++++----------- compat-include/linux/netlink.h | 4 ++-- compat-include/linux/nl80211.h | 4 ++-- compat-include/linux/seq_file.h | 4 ++-- compat-include/linux/skbuff.h | 20 ++++++++++---------- compat-include/linux/stddef.h | 4 ++-- compat-include/linux/string.h | 4 ++-- compat-include/linux/timer.h | 4 ++-- compat-include/linux/types.h | 4 ++-- compat-include/linux/uaccess.h | 4 ++-- compat-include/linux/version.h | 21 +++++++++++++++++++++ compat-include/net/addrconf.h | 6 +++--- compat-include/net/cfg80211.h | 18 +++++++++--------- compat-include/net/genetlink.h | 8 ++++---- compat-include/net/ip6_checksum.h | 4 ++-- compat-include/net/netlink.h | 4 ++-- compat-include/uapi/linux/eventpoll.h | 4 ++-- compat-include/uapi/linux/nl80211.h | 4 ++-- compat-sources/net/core/skbuff.c | 8 ++++---- compat-sources/net/ipv4/igmp.c | 4 ++-- compat-sources/net/ipv6/mcast_snoop.c | 4 ++-- compat.h | 18 +++++++++--------- 31 files changed, 129 insertions(+), 108 deletions(-)
diff --git a/compat-include/linux/average.h b/compat-include/linux/average.h index 6e8ac3c4..046e9cb5 100644 --- a/compat-include/linux/average.h +++ b/compat-include/linux/average.h @@ -17,9 +17,9 @@ #include <linux/compiler.h> #include <linux/log2.h>
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) +#if LINUX_VERSION_IS_GEQ(4, 3, 0) #undef DECLARE_EWMA -#endif /* < KERNEL_VERSION(4, 3, 0) */ +#endif /* LINUX_VERSION_IS_LESS(4, 3, 0) */
/* * Exponentially weighted moving average (EWMA) diff --git a/compat-include/linux/build_bug.h b/compat-include/linux/build_bug.h index a372bced..5996d9e7 100644 --- a/compat-include/linux/build_bug.h +++ b/compat-include/linux/build_bug.h @@ -11,7 +11,7 @@ #define _NET_BATMAN_ADV_COMPAT_LINUX_BUILD_BUG_H_
#include <linux/version.h> -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 13, 0) +#if LINUX_VERSION_IS_GEQ(4, 13, 0) #include_next <linux/build_bug.h> #else #include <linux/bug.h> diff --git a/compat-include/linux/cache.h b/compat-include/linux/cache.h index 366d2835..82547e5c 100644 --- a/compat-include/linux/cache.h +++ b/compat-include/linux/cache.h @@ -13,10 +13,10 @@ #include <linux/version.h> #include_next <linux/cache.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0) +#if LINUX_VERSION_IS_LESS(4, 6, 0)
#define __ro_after_init
-#endif /* < KERNEL_VERSION(4, 6, 0) */ +#endif /* LINUX_VERSION_IS_LESS(4, 6, 0) */
#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_CACHE_H */ diff --git a/compat-include/linux/compiler.h b/compat-include/linux/compiler.h index 758d544e..89ed2929 100644 --- a/compat-include/linux/compiler.h +++ b/compat-include/linux/compiler.h @@ -13,7 +13,7 @@ #include <linux/version.h> #include_next <linux/compiler.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0) +#if LINUX_VERSION_IS_LESS(3, 19, 0)
#ifndef READ_ONCE #define READ_ONCE(x) ACCESS_ONCE(x) @@ -25,10 +25,10 @@ }) #endif
-#endif /* < KERNEL_VERSION(3, 19, 0) */ +#endif /* LINUX_VERSION_IS_LESS(3, 19, 0) */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0) +#if LINUX_VERSION_IS_LESS(5, 4, 0)
#ifndef fallthrough #if __GNUC__ > 7 && !defined(__CHECKER__) @@ -38,6 +38,6 @@ #endif #endif
-#endif /* < KERNEL_VERSION(5, 4, 0) */ +#endif /* LINUX_VERSION_IS_LESS(5, 4, 0) */
#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_COMPILER_H_ */ diff --git a/compat-include/linux/ethtool.h b/compat-include/linux/ethtool.h index c472233d..18629acd 100644 --- a/compat-include/linux/ethtool.h +++ b/compat-include/linux/ethtool.h @@ -13,7 +13,7 @@ #include <linux/version.h> #include_next <linux/ethtool.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0) +#if LINUX_VERSION_IS_LESS(4, 6, 0)
#define ethtool_link_ksettings batadv_ethtool_link_ksettings
@@ -48,6 +48,6 @@ batadv_ethtool_get_link_ksettings(struct net_device *dev, return 0; }
-#endif /* < KERNEL_VERSION(4, 6, 0) */ +#endif /* LINUX_VERSION_IS_LESS(4, 6, 0) */
#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_ETHTOOL_H_ */ diff --git a/compat-include/linux/fs.h b/compat-include/linux/fs.h index 1334eb17..6867e6d4 100644 --- a/compat-include/linux/fs.h +++ b/compat-include/linux/fs.h @@ -13,7 +13,7 @@ #include <linux/version.h> #include_next <linux/fs.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0) +#if LINUX_VERSION_IS_LESS(4, 6, 0)
static inline struct dentry *batadv_file_dentry(const struct file *file) { @@ -29,9 +29,9 @@ static inline struct dentry *batadv_file_dentry(const struct file *file)
#define file_dentry batadv_file_dentry
-#endif /* < KERNEL_VERSION(4, 6, 0) */ +#endif /* LINUX_VERSION_IS_LESS(4, 6, 0) */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 2, 0) +#if LINUX_VERSION_IS_LESS(5, 2, 0)
static inline int batadv_stream_open(struct inode *inode, struct file *filp) { @@ -40,6 +40,6 @@ static inline int batadv_stream_open(struct inode *inode, struct file *filp)
#define stream_open batadv_stream_open
-#endif /* < KERNEL_VERSION(5, 2, 0) */ +#endif /* LINUX_VERSION_IS_LESS(5, 2, 0) */
#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_FS_H_ */ diff --git a/compat-include/linux/if_bridge.h b/compat-include/linux/if_bridge.h index c4c4ff6c..8dfcef19 100644 --- a/compat-include/linux/if_bridge.h +++ b/compat-include/linux/if_bridge.h @@ -13,7 +13,7 @@ #include <linux/version.h> #include_next <linux/if_bridge.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0) +#if LINUX_VERSION_IS_LESS(3, 16, 0)
struct br_ip { union { @@ -31,12 +31,12 @@ struct br_ip_list { struct br_ip addr; };
-#endif /* < KERNEL_VERSION(3, 16, 0) */ +#endif /* LINUX_VERSION_IS_LESS(3, 16, 0) */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0) || \ +#if LINUX_VERSION_IS_LESS(3, 16, 0) || \ LINUX_VERSION_CODE == KERNEL_VERSION(3, 16, 0) && \ - (!IS_ENABLED(CONFIG_BRIDGE) || \ - !IS_ENABLED(CONFIG_BRIDGE_IGMP_SNOOPING)) + (!IS_ENABLED(CONFIG_BRIDGE) || \ + !IS_ENABLED(CONFIG_BRIDGE_IGMP_SNOOPING))
#define br_multicast_list_adjacent(dev, br_ip_list) \ batadv_br_multicast_list_adjacent(dev, br_ip_list) @@ -57,12 +57,12 @@ batadv_br_multicast_has_querier_adjacent(struct net_device *dev, int proto) return false; }
-#endif /* < KERNEL_VERSION(3, 16, 0) || +#endif /* LINUX_VERSION_IS_LESS(3, 16, 0) || * == KERNEL_VERSION(3, 16, 0) && * (!IS_ENABLED(CONFIG_BRIDGE) || * !IS_ENABLED(CONFIG_BRIDGE_IGMP_SNOOPING)) */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0) +#if LINUX_VERSION_IS_LESS(3, 17, 0)
static inline bool br_multicast_has_querier_anywhere(struct net_device *dev, int proto) @@ -72,6 +72,6 @@ static inline bool br_multicast_has_querier_anywhere(struct net_device *dev, return false; }
-#endif /* < KERNEL_VERSION(3, 17, 0) */ +#endif /* LINUX_VERSION_IS_LESS(3, 17, 0) */
#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_IF_BRIDGE_H_ */ diff --git a/compat-include/linux/igmp.h b/compat-include/linux/igmp.h index ecedc915..9875d6d4 100644 --- a/compat-include/linux/igmp.h +++ b/compat-include/linux/igmp.h @@ -13,11 +13,11 @@ #include <linux/version.h> #include_next <linux/igmp.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0) +#if LINUX_VERSION_IS_LESS(4, 2, 0)
int ip_mc_check_igmp(struct sk_buff *skb);
-#elif LINUX_VERSION_CODE < KERNEL_VERSION(5, 1, 0) +#elif LINUX_VERSION_IS_LESS(5, 1, 0)
static inline int batadv_ip_mc_check_igmp(struct sk_buff *skb) { @@ -27,6 +27,6 @@ static inline int batadv_ip_mc_check_igmp(struct sk_buff *skb) #define ip_mc_check_igmp(skb) \ batadv_ip_mc_check_igmp(skb)
-#endif /* < KERNEL_VERSION(4, 2, 0) */ +#endif /* LINUX_VERSION_IS_LESS(4, 2, 0) */
#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_IGMP_H_ */ diff --git a/compat-include/linux/list.h b/compat-include/linux/list.h index be02d75c..1bd85d0d 100644 --- a/compat-include/linux/list.h +++ b/compat-include/linux/list.h @@ -13,19 +13,19 @@ #include <linux/version.h> #include_next <linux/list.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0) +#if LINUX_VERSION_IS_LESS(3, 17, 0)
#define hlist_add_behind(n, prev) hlist_add_after(prev, n)
-#endif /* < KERNEL_VERSION(3, 17, 0) */ +#endif /* LINUX_VERSION_IS_LESS(3, 17, 0) */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0) +#if LINUX_VERSION_IS_LESS(4, 3, 0)
static inline bool hlist_fake(struct hlist_node *h) { return h->pprev == &h->next; }
-#endif /* < KERNEL_VERSION(4, 3, 0) */ +#endif /* LINUX_VERSION_IS_LESS(4, 3, 0) */
#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_LIST_H_ */ diff --git a/compat-include/linux/netdevice.h b/compat-include/linux/netdevice.h index 55189640..ae7fb906 100644 --- a/compat-include/linux/netdevice.h +++ b/compat-include/linux/netdevice.h @@ -13,34 +13,34 @@ #include <linux/version.h> #include_next <linux/netdevice.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0) +#if LINUX_VERSION_IS_LESS(3, 17, 0)
/* alloc_netdev() was defined differently before 2.6.38 */ #undef alloc_netdev #define alloc_netdev(sizeof_priv, name, name_assign_type, setup) \ alloc_netdev_mqs(sizeof_priv, name, setup, 1, 1)
-#endif /* < KERNEL_VERSION(3, 17, 0) */ +#endif /* LINUX_VERSION_IS_LESS(3, 17, 0) */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0) +#if LINUX_VERSION_IS_LESS(4, 1, 0)
#define dev_get_iflink(_net_dev) ((_net_dev)->iflink)
-#endif /* < KERNEL_VERSION(3, 19, 0) */ +#endif /* LINUX_VERSION_IS_LESS(3, 19, 0) */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0) +#if LINUX_VERSION_IS_LESS(4, 5, 0)
#define netdev_master_upper_dev_link(dev, upper_dev, upper_priv, upper_info, extack) \ netdev_master_upper_dev_link(dev, upper_dev)
-#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) +#elif LINUX_VERSION_IS_LESS(4, 15, 0)
#define netdev_master_upper_dev_link(dev, upper_dev, upper_priv, upper_info, extack) \ netdev_master_upper_dev_link(dev, upper_dev, upper_priv, upper_info)
-#endif /* < KERNEL_VERSION(4, 15, 0) */ +#endif /* LINUX_VERSION_IS_LESS(4, 15, 0) */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 7, 0) +#if LINUX_VERSION_IS_LESS(4, 7, 0)
#define netif_trans_update batadv_netif_trans_update static inline void batadv_netif_trans_update(struct net_device *dev) @@ -48,9 +48,9 @@ static inline void batadv_netif_trans_update(struct net_device *dev) dev->trans_start = jiffies; }
-#endif /* < KERNEL_VERSION(4, 7, 0) */ +#endif /* LINUX_VERSION_IS_LESS(4, 7, 0) */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 9) +#if LINUX_VERSION_IS_LESS(4, 11, 9)
/* work around missing attribute needs_free_netdev and priv_destructor in * net_device @@ -67,6 +67,6 @@ static inline void batadv_netif_trans_update(struct net_device *dev) #define needs_free_netdev destructor = batadv_softif_free2; t2 #define priv_destructor destructor = batadv_softif_free2; t1
-#endif /* < KERNEL_VERSION(4, 11, 9) */ +#endif /* LINUX_VERSION_IS_LESS(4, 11, 9) */
#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_NETDEVICE_H_ */ diff --git a/compat-include/linux/netlink.h b/compat-include/linux/netlink.h index b62e01e3..27dc6581 100644 --- a/compat-include/linux/netlink.h +++ b/compat-include/linux/netlink.h @@ -13,7 +13,7 @@ #include <linux/version.h> #include_next <linux/netlink.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 7, 0) +#if LINUX_VERSION_IS_LESS(4, 7, 0)
#include_next <net/netlink.h>
@@ -97,6 +97,6 @@ static inline int batadv_nla_put_u64_64bit(struct sk_buff *skb, int attrtype, padattr); }
-#endif /* < KERNEL_VERSION(4, 7, 0) */ +#endif /* LINUX_VERSION_IS_LESS(4, 7, 0) */
#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_NETLINK_H_ */ diff --git a/compat-include/linux/nl80211.h b/compat-include/linux/nl80211.h index d0fb9bb9..bea92d1b 100644 --- a/compat-include/linux/nl80211.h +++ b/compat-include/linux/nl80211.h @@ -13,11 +13,11 @@ #include <linux/version.h> #include_next <linux/nl80211.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0) +#if LINUX_VERSION_IS_LESS(3, 16, 0)
/* Linux 3.15 misses the uapi include.... */ #include <uapi/linux/nl80211.h>
-#endif /* < KERNEL_VERSION(3, 16, 0) */ +#endif /* LINUX_VERSION_IS_LESS(3, 16, 0) */
#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_NL80211_H_ */ diff --git a/compat-include/linux/seq_file.h b/compat-include/linux/seq_file.h index 192897f4..74854f56 100644 --- a/compat-include/linux/seq_file.h +++ b/compat-include/linux/seq_file.h @@ -13,13 +13,13 @@ #include <linux/version.h> #include_next <linux/seq_file.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0) +#if LINUX_VERSION_IS_LESS(3, 19, 0)
static inline bool seq_has_overflowed(struct seq_file *m) { return m->count == m->size; }
-#endif /* < KERNEL_VERSION(3, 19, 0) */ +#endif /* LINUX_VERSION_IS_LESS(3, 19, 0) */
#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_SEQ_FILE_H_ */ diff --git a/compat-include/linux/skbuff.h b/compat-include/linux/skbuff.h index 0fa77b99..e92f3422 100644 --- a/compat-include/linux/skbuff.h +++ b/compat-include/linux/skbuff.h @@ -13,7 +13,7 @@ #include <linux/version.h> #include_next <linux/skbuff.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0) +#if LINUX_VERSION_IS_LESS(3, 16, 0)
#define pskb_copy_for_clone pskb_copy
@@ -23,17 +23,17 @@ __sum16 skb_checksum_validate(struct sk_buff *skb, int proto, __wsum (*compute_pseudo)(struct sk_buff *skb, int proto));
-#endif /* < KERNEL_VERSION(3, 16, 0) */ +#endif /* LINUX_VERSION_IS_LESS(3, 16, 0) */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0) +#if LINUX_VERSION_IS_LESS(4, 2, 0)
struct sk_buff *skb_checksum_trimmed(struct sk_buff *skb, unsigned int transport_len, __sum16(*skb_chkf)(struct sk_buff *skb));
-#endif /* < KERNEL_VERSION(4, 2, 0) */ +#endif /* LINUX_VERSION_IS_LESS(4, 2, 0) */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0) +#if LINUX_VERSION_IS_LESS(4, 5, 0)
static inline void batadv_skb_postpush_rcsum(struct sk_buff *skb, const void *start, @@ -46,9 +46,9 @@ static inline void batadv_skb_postpush_rcsum(struct sk_buff *skb,
#define skb_postpush_rcsum batadv_skb_postpush_rcsum
-#endif /* < KERNEL_VERSION(4, 5, 0) */ +#endif /* LINUX_VERSION_IS_LESS(4, 5, 0) */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0) +#if LINUX_VERSION_IS_LESS(4, 13, 0)
static inline void *batadv_skb_put(struct sk_buff *skb, unsigned int len) { @@ -75,12 +75,12 @@ static inline void *skb_put_data(struct sk_buff *skb, const void *data, return tmp; }
-#endif /* < KERNEL_VERSION(4, 13, 0) */ +#endif /* LINUX_VERSION_IS_LESS(4, 13, 0) */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0) +#if LINUX_VERSION_IS_LESS(5, 4, 0)
#define nf_reset_ct nf_reset
-#endif /* < KERNEL_VERSION(5, 4, 0) */ +#endif /* LINUX_VERSION_IS_LESS(5, 4, 0) */
#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_SKBUFF_H_ */ diff --git a/compat-include/linux/stddef.h b/compat-include/linux/stddef.h index 67cd72f3..be4e31e9 100644 --- a/compat-include/linux/stddef.h +++ b/compat-include/linux/stddef.h @@ -13,12 +13,12 @@ #include <linux/version.h> #include_next <linux/stddef.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0) +#if LINUX_VERSION_IS_LESS(4, 16, 0)
#ifndef sizeof_field #define sizeof_field(TYPE, MEMBER) sizeof((((TYPE *)0)->MEMBER)) #endif
-#endif /* < KERNEL_VERSION(4, 16, 0) */ +#endif /* LINUX_VERSION_IS_LESS(4, 16, 0) */
#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_STDDEF_H_ */ diff --git a/compat-include/linux/string.h b/compat-include/linux/string.h index 36ec689e..71978031 100644 --- a/compat-include/linux/string.h +++ b/compat-include/linux/string.h @@ -12,7 +12,7 @@ #include_next <linux/string.h> #include <asm-generic/errno-base.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0) +#if LINUX_VERSION_IS_LESS(4, 3, 0)
#ifndef __HAVE_ARCH_STRSCPY
@@ -46,6 +46,6 @@ static inline ssize_t batadv_strscpy(char *dest, const char *src, size_t count)
#endif
-#endif /* < KERNEL_VERSION(4, 3, 0) */ +#endif /* LINUX_VERSION_IS_LESS(4, 3, 0) */
#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_STRING_H_ */ diff --git a/compat-include/linux/timer.h b/compat-include/linux/timer.h index 2968c255..8a4e714c 100644 --- a/compat-include/linux/timer.h +++ b/compat-include/linux/timer.h @@ -13,7 +13,7 @@ #include <linux/version.h> #include_next <linux/timer.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0) +#if LINUX_VERSION_IS_LESS(4, 14, 0)
#define TIMER_DATA_TYPE unsigned long #define TIMER_FUNC_TYPE void (*)(TIMER_DATA_TYPE) @@ -29,6 +29,6 @@ static inline void timer_setup(struct timer_list *timer, #define from_timer(var, callback_timer, timer_fieldname) \ container_of(callback_timer, typeof(*var), timer_fieldname)
-#endif /* < KERNEL_VERSION(4, 14, 0) */ +#endif /* LINUX_VERSION_IS_LESS(4, 14, 0) */
#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_TIMER_H */ diff --git a/compat-include/linux/types.h b/compat-include/linux/types.h index 1c17893b..33562897 100644 --- a/compat-include/linux/types.h +++ b/compat-include/linux/types.h @@ -13,7 +13,7 @@ #include <linux/version.h> #include_next <linux/types.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0) +#if LINUX_VERSION_IS_LESS(4, 16, 0)
#ifdef __CHECK_POLL typedef unsigned __bitwise __poll_t; @@ -21,6 +21,6 @@ typedef unsigned __bitwise __poll_t; typedef unsigned __poll_t; #endif
-#endif /* < KERNEL_VERSION(4, 16, 0) */ +#endif /* LINUX_VERSION_IS_LESS(4, 16, 0) */
#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_TYPES_H_ */ diff --git a/compat-include/linux/uaccess.h b/compat-include/linux/uaccess.h index e81ed805..b9b3a7cb 100644 --- a/compat-include/linux/uaccess.h +++ b/compat-include/linux/uaccess.h @@ -13,7 +13,7 @@ #include <linux/version.h> #include_next <linux/uaccess.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0) +#if LINUX_VERSION_IS_LESS(5, 0, 0)
static inline int batadv_access_ok(int type, const void __user *p, unsigned long size) @@ -32,6 +32,6 @@ static inline int batadv_access_ok(int type, const void __user *p, #define access_ok2(addr, size) batadv_access_ok(VERIFY_WRITE, (addr), (size)) #define access_ok3(type, addr, size) batadv_access_ok((type), (addr), (size))
-#endif /* < KERNEL_VERSION(5, 0, 0) */ +#endif /* LINUX_VERSION_IS_LESS(5, 0, 0) */
#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_UACCESS_H_ */ diff --git a/compat-include/linux/version.h b/compat-include/linux/version.h new file mode 100644 index 00000000..5582e8cb --- /dev/null +++ b/compat-include/linux/version.h @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (C) 2007-2020 B.A.T.M.A.N. contributors: + * + * Marek Lindner, Simon Wunderlich + * + * This file contains macros for maintaining compatibility with older versions + * of the Linux kernel. + */ + +#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_VERSION_H_ +#define _NET_BATMAN_ADV_COMPAT_LINUX_VERSION_H_ + +#include_next <linux/version.h> + +#define LINUX_VERSION_IS_LESS(a, b, c) \ + (LINUX_VERSION_CODE < KERNEL_VERSION(a, b, c)) + +#define LINUX_VERSION_IS_GEQ(a, b, c) \ + (LINUX_VERSION_CODE >= KERNEL_VERSION(a, b, c)) + +#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_VERSION_H_ */ diff --git a/compat-include/net/addrconf.h b/compat-include/net/addrconf.h index b826ee95..5430811a 100644 --- a/compat-include/net/addrconf.h +++ b/compat-include/net/addrconf.h @@ -13,11 +13,11 @@ #include <linux/version.h> #include_next <net/addrconf.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0) +#if LINUX_VERSION_IS_LESS(4, 2, 0)
int ipv6_mc_check_mld(struct sk_buff *skb);
-#elif LINUX_VERSION_CODE < KERNEL_VERSION(5, 1, 0) +#elif LINUX_VERSION_IS_LESS(5, 1, 0)
static inline int batadv_ipv6_mc_check_mld(struct sk_buff *skb) { @@ -27,6 +27,6 @@ static inline int batadv_ipv6_mc_check_mld(struct sk_buff *skb) #define ipv6_mc_check_mld(skb) \ batadv_ipv6_mc_check_mld(skb)
-#endif /* < KERNEL_VERSION(4, 2, 0) */ +#endif /* LINUX_VERSION_IS_LESS(4, 2, 0) */
#endif /* _NET_BATMAN_ADV_COMPAT_NET_ADDRCONF_H_ */ diff --git a/compat-include/net/cfg80211.h b/compat-include/net/cfg80211.h index b2f8dd73..241f44e0 100644 --- a/compat-include/net/cfg80211.h +++ b/compat-include/net/cfg80211.h @@ -13,7 +13,7 @@ #include <linux/version.h> #include_next <net/cfg80211.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0) +#if LINUX_VERSION_IS_LESS(3, 16, 0)
static inline int cfg80211_get_station(struct net_device *dev, const u8 *mac_addr, @@ -29,13 +29,13 @@ static inline int cfg80211_get_station(struct net_device *dev, */ #define expected_throughput filled
-#endif /* < KERNEL_VERSION(3, 16, 0) */ +#endif /* LINUX_VERSION_IS_LESS(3, 16, 0) */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0) +#if LINUX_VERSION_IS_LESS(4, 8, 0)
#if !IS_ENABLED(CONFIG_CFG80211) && \ - LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0) + LINUX_VERSION_IS_GEQ(3, 16, 0)
#define cfg80211_get_station(dev, mac_addr, sinfo) \ batadv_cfg80211_get_station(dev, mac_addr, sinfo) @@ -48,10 +48,10 @@ static inline int batadv_cfg80211_get_station(struct net_device *dev, } #endif
-#endif /* < KERNEL_VERSION(4, 8, 0) */ +#endif /* LINUX_VERSION_IS_LESS(4, 8, 0) */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0) && IS_ENABLED(CONFIG_CFG80211) +#if LINUX_VERSION_IS_LESS(4, 18, 0) && IS_ENABLED(CONFIG_CFG80211)
/* cfg80211 fix: https://patchwork.kernel.org/patch/10449857/ */ static inline int batadv_cfg80211_get_station(struct net_device *dev, @@ -65,13 +65,13 @@ static inline int batadv_cfg80211_get_station(struct net_device *dev, #define cfg80211_get_station(dev, mac_addr, sinfo) \ batadv_cfg80211_get_station(dev, mac_addr, sinfo)
-#endif /* < KERNEL_VERSION(4, 18, 0) && IS_ENABLED(CONFIG_CFG80211) */ +#endif /* LINUX_VERSION_IS_LESS(4, 18, 0) && IS_ENABLED(CONFIG_CFG80211) */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0) +#if LINUX_VERSION_IS_LESS(4, 18, 0)
#define cfg80211_sinfo_release_content(sinfo)
-#endif /* < KERNEL_VERSION(4, 18, 0) */ +#endif /* LINUX_VERSION_IS_LESS(4, 18, 0) */
#endif /* _NET_BATMAN_ADV_COMPAT_NET_CFG80211_H_ */ diff --git a/compat-include/net/genetlink.h b/compat-include/net/genetlink.h index d17fa82e..d1f80cd8 100644 --- a/compat-include/net/genetlink.h +++ b/compat-include/net/genetlink.h @@ -13,7 +13,7 @@ #include <linux/version.h> #include_next <net/genetlink.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) +#if LINUX_VERSION_IS_LESS(4, 15, 0)
static inline void batadv_genl_dump_check_consistent(struct netlink_callback *cb, @@ -28,10 +28,10 @@ void batadv_genl_dump_check_consistent(struct netlink_callback *cb,
#define genl_dump_check_consistent batadv_genl_dump_check_consistent
-#endif /* < KERNEL_VERSION(4, 15, 0) */ +#endif /* LINUX_VERSION_IS_LESS(4, 15, 0) */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 2, 0) +#if LINUX_VERSION_IS_LESS(5, 2, 0)
enum genl_validate_flags { GENL_DONT_VALIDATE_STRICT = BIT(0), @@ -150,6 +150,6 @@ batadv_genl_unregister_family(struct batadv_genl_family *family) genlmsg_multicast_netns(&(_family)->family, _net, _skb, _portid, \ _group, _flags)
-#endif /* < KERNEL_VERSION(5, 2, 0) */ +#endif /* LINUX_VERSION_IS_LESS(5, 2, 0) */
#endif /* _NET_BATMAN_ADV_COMPAT_NET_GENETLINK_H_ */ diff --git a/compat-include/net/ip6_checksum.h b/compat-include/net/ip6_checksum.h index 0d9596a8..8997cbf9 100644 --- a/compat-include/net/ip6_checksum.h +++ b/compat-include/net/ip6_checksum.h @@ -13,7 +13,7 @@ #include <linux/version.h> #include_next <net/ip6_checksum.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0) +#if LINUX_VERSION_IS_LESS(3, 16, 0)
static inline __wsum ip6_compute_pseudo(struct sk_buff *skb, int proto) { @@ -22,6 +22,6 @@ static inline __wsum ip6_compute_pseudo(struct sk_buff *skb, int proto) skb->len, proto, 0)); }
-#endif /* < KERNEL_VERSION(3, 16, 0) */ +#endif /* LINUX_VERSION_IS_LESS(3, 16, 0) */
#endif /* _NET_BATMAN_ADV_COMPAT_NET_IP6_CHECKSUM_H_ */ diff --git a/compat-include/net/netlink.h b/compat-include/net/netlink.h index e98ea1e6..c7419e15 100644 --- a/compat-include/net/netlink.h +++ b/compat-include/net/netlink.h @@ -13,7 +13,7 @@ #include <linux/version.h> #include_next <net/netlink.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0) +#if LINUX_VERSION_IS_LESS(4, 1, 0)
static inline int nla_put_in_addr(struct sk_buff *skb, int attrtype, __be32 addr) @@ -23,6 +23,6 @@ static inline int nla_put_in_addr(struct sk_buff *skb, int attrtype, return nla_put_be32(skb, attrtype, tmp); }
-#endif /* < KERNEL_VERSION(4, 1, 0) */ +#endif /* LINUX_VERSION_IS_LESS(4, 1, 0) */
#endif /* _NET_BATMAN_ADV_COMPAT_NET_NETLINK_H_ */ diff --git a/compat-include/uapi/linux/eventpoll.h b/compat-include/uapi/linux/eventpoll.h index 7ec15069..40c57ed9 100644 --- a/compat-include/uapi/linux/eventpoll.h +++ b/compat-include/uapi/linux/eventpoll.h @@ -14,7 +14,7 @@ #include <linux/types.h> #include_next <uapi/linux/eventpoll.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0) +#if LINUX_VERSION_IS_LESS(4, 12, 0)
#ifndef EPOLLIN #define EPOLLIN (__force __poll_t)0x00000001 @@ -24,6 +24,6 @@ #define EPOLLRDNORM (__force __poll_t)0x00000040 #endif
-#endif /* < KERNEL_VERSION(4, 12, 0) */ +#endif /* LINUX_VERSION_IS_LESS(4, 12, 0) */
#endif /* _NET_BATMAN_ADV_COMPAT_UAPI_LINUX_EVENTPOLL_H_ */ diff --git a/compat-include/uapi/linux/nl80211.h b/compat-include/uapi/linux/nl80211.h index ac4f50c2..dff0dd5c 100644 --- a/compat-include/uapi/linux/nl80211.h +++ b/compat-include/uapi/linux/nl80211.h @@ -13,13 +13,13 @@ #include <linux/version.h> #include_next <uapi/linux/nl80211.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0) +#if LINUX_VERSION_IS_LESS(4, 0, 0)
/* for batadv_v_elp_get_throughput which would have used * STATION_INFO_EXPECTED_THROUGHPUT in Linux 4.0.0 */ #define NL80211_STA_INFO_EXPECTED_THROUGHPUT 28
-#endif /* < KERNEL_VERSION(4, 0, 0) */ +#endif /* LINUX_VERSION_IS_LESS(4, 0, 0) */
#endif /* _NET_BATMAN_ADV_COMPAT_UAPI_LINUX_NL80211_H_ */ diff --git a/compat-sources/net/core/skbuff.c b/compat-sources/net/core/skbuff.c index 16ec56ef..fd2771ae 100644 --- a/compat-sources/net/core/skbuff.c +++ b/compat-sources/net/core/skbuff.c @@ -35,7 +35,7 @@ #include <net/checksum.h> #include <net/ip6_checksum.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0) +#if LINUX_VERSION_IS_LESS(3, 16, 0)
/* Compare with: * "bridge: multicast: call skb_checksum_{simple_, }validate" @@ -84,9 +84,9 @@ skb_checksum_validate(struct sk_buff *skb, int proto, return 0; }
-#endif /* < KERNEL_VERSION(3, 16, 0) */ +#endif /* LINUX_VERSION_IS_LESS(3, 16, 0) */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0) +#if LINUX_VERSION_IS_LESS(4, 2, 0)
/** * skb_push_rcsum - push skb and update receive checksum @@ -192,4 +192,4 @@ struct sk_buff *skb_checksum_trimmed(struct sk_buff *skb, return skb_chk; }
-#endif /* < KERNEL_VERSION(4, 2, 0) */ +#endif /* LINUX_VERSION_IS_LESS(4, 2, 0) */ diff --git a/compat-sources/net/ipv4/igmp.c b/compat-sources/net/ipv4/igmp.c index 762818b4..6c639676 100644 --- a/compat-sources/net/ipv4/igmp.c +++ b/compat-sources/net/ipv4/igmp.c @@ -71,7 +71,7 @@ #include <linux/skbuff.h> #include <net/ip.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0) +#if LINUX_VERSION_IS_LESS(4, 2, 0)
static int ip_mc_check_iphdr(struct sk_buff *skb) { @@ -220,4 +220,4 @@ int ip_mc_check_igmp(struct sk_buff *skb) return __ip_mc_check_igmp(skb); }
-#endif /* < KERNEL_VERSION(4, 2, 0) */ +#endif /* LINUX_VERSION_IS_LESS(4, 2, 0) */ diff --git a/compat-sources/net/ipv6/mcast_snoop.c b/compat-sources/net/ipv6/mcast_snoop.c index 9ab2a1a2..651b8e3b 100644 --- a/compat-sources/net/ipv6/mcast_snoop.c +++ b/compat-sources/net/ipv6/mcast_snoop.c @@ -11,7 +11,7 @@ #include <net/addrconf.h> #include <net/ip6_checksum.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0) +#if LINUX_VERSION_IS_LESS(4, 2, 0)
static int ipv6_mc_check_ip6hdr(struct sk_buff *skb) { @@ -186,4 +186,4 @@ int ipv6_mc_check_mld(struct sk_buff *skb) return __ipv6_mc_check_mld(skb); }
-#endif /* < KERNEL_VERSION(4, 2, 0) */ +#endif /* LINUX_VERSION_IS_LESS(4, 2, 0) */ diff --git a/compat.h b/compat.h index 980fca9f..b915d914 100644 --- a/compat.h +++ b/compat.h @@ -15,34 +15,34 @@
#include "compat-autoconf.h"
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0) +#if LINUX_VERSION_IS_LESS(4, 0, 0)
/* wild hack for batadv_getlink_net only */ #define get_link_net get_xstats_size || 1 ? fallback_net : (struct net*)netdev->rtnl_link_ops->get_xstats_size
-#endif /* < KERNEL_VERSION(4, 0, 0) */ +#endif /* LINUX_VERSION_IS_LESS(4, 0, 0) */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0) +#if LINUX_VERSION_IS_LESS(4, 3, 0)
#define IFF_NO_QUEUE 0; dev->tx_queue_len = 0
-#endif /* < KERNEL_VERSION(4, 3, 0) */ +#endif /* LINUX_VERSION_IS_LESS(4, 3, 0) */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0) +#if LINUX_VERSION_IS_LESS(4, 6, 0)
/* workaround for current issues with Debian's make-kpkg */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0) +#if LINUX_VERSION_IS_GEQ(4, 5, 0) #include <uapi/linux/pkt_cls.h> #endif
-#endif /* < KERNEL_VERSION(4, 6, 0) */ +#endif /* LINUX_VERSION_IS_LESS(4, 6, 0) */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) +#if LINUX_VERSION_IS_LESS(4, 15, 0)
#define batadv_softif_slave_add(__dev, __slave_dev, __extack) \ batadv_softif_slave_add(__dev, __slave_dev)
-#endif /* < KERNEL_VERSION(4, 15, 0) */ +#endif /* LINUX_VERSION_IS_LESS(4, 15, 0) */
#endif /* __KERNEL__ */