[PATCH batadv 1/2] batman-adv: compat: drop support for pre-C11 kernels

Sven Eckelmann <[email protected]>
Newsgroups org.open-mesh.lists.batman
Message-ID <[email protected]>
batman-adv will rely on C99/C11 features but the kernel enabled it only
since Linux 5.18. The support for Linux 5.10-5.17 is therefore no longer
possible. But these LTS kernels will be EoL at the end of the year anyway.

Signed-off-by: Sven Eckelmann <[email protected]>
---
 README.external.rst                   |  2 +-
 compat-include/linux/array_size.h     |  3 +-
 compat-include/linux/container_of.h   | 13 -----
 compat-include/linux/etherdevice.h    | 20 --------
 compat-include/linux/if_bridge.h      | 51 -------------------
 compat-include/linux/if_vlan.h        |  2 -
 compat-include/linux/kstrtox.h        | 14 ------
 compat-include/linux/netdevice.h      | 49 +-----------------
 compat-include/linux/stdarg.h         | 13 -----
 compat-include/linux/string_choices.h | 12 -----
 compat-include/linux/timer.h          |  1 -
 compat-include/net/addrconf.h         | 94 -----------------------------------
 net/batman-adv/multicast.c            |  7 ---
 13 files changed, 4 insertions(+), 277 deletions(-)

diff --git a/README.external.rst b/README.external.rst
index f988986f..fb4eaae0 100644
--- a/README.external.rst
+++ b/README.external.rst
@@ -12,7 +12,7 @@ and as an external module. The external  module   allows  to  get
 new    features without  upgrading  to  a  newer  kernel  version
 and to get batman-adv specific bug fixes for  kernels  that   are
 not   supported   anymore.  It compiles  against  and should work
-with  Linux 5.10  -   7.2.  Supporting  older  versions  is   not
+with  Linux 5.18  -   7.2.  Supporting  older  versions  is   not
 planned,  but it's probably easy to backport it. If you work on a
 backport, feel free to contact us.  :-)
 
diff --git a/compat-include/linux/array_size.h b/compat-include/linux/array_size.h
index 418deb68..9cb8d6c2 100644
--- a/compat-include/linux/array_size.h
+++ b/compat-include/linux/array_size.h
@@ -4,8 +4,7 @@
 #define _NET_BATMAN_ADV_COMPAT_LINUX_ARRAY_SIZE_H_
 
 #include <linux/version.h>
-#if (LINUX_VERSION_IS_GEQ(5, 15, 197) && LINUX_VERSION_IS_LESS(5, 16, 0)) || \
-    (LINUX_VERSION_IS_GEQ(6, 1, 159) && LINUX_VERSION_IS_LESS(6, 2, 0)) || \
+#if (LINUX_VERSION_IS_GEQ(6, 1, 159) && LINUX_VERSION_IS_LESS(6, 2, 0)) || \
     (LINUX_VERSION_IS_GEQ(6, 6, 118) && LINUX_VERSION_IS_LESS(6, 7, 0)) || \
     LINUX_VERSION_IS_GEQ(6, 7, 0)
 #include_next <linux/array_size.h>
diff --git a/compat-include/linux/container_of.h b/compat-include/linux/container_of.h
deleted file mode 100644
index 771c979c..00000000
--- a/compat-include/linux/container_of.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-
-#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_CONTAINER_OF_H_
-#define _NET_BATMAN_ADV_COMPAT_LINUX_CONTAINER_OF_H_
-
-#include <linux/version.h>
-#if LINUX_VERSION_IS_GEQ(5, 16, 0)
-#include_next <linux/container_of.h>
-#else
-#include <linux/kernel.h>
-#endif
-
-#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_CONTAINER_OF_H_ */
diff --git a/compat-include/linux/etherdevice.h b/compat-include/linux/etherdevice.h
deleted file mode 100644
index 1e2fdafb..00000000
--- a/compat-include/linux/etherdevice.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-
-#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_ETHERDEVICE_H_
-#define _NET_BATMAN_ADV_COMPAT_LINUX_ETHERDEVICE_H_
-
-#include <linux/version.h>
-#include_next <linux/etherdevice.h>
-
-#if LINUX_VERSION_IS_LESS(5, 15, 0)
-
-static inline void batadv_eth_hw_addr_set(struct net_device *dev,
-					  const u8 *addr)
-{
-	ether_addr_copy(dev->dev_addr, addr);
-}
-#define eth_hw_addr_set batadv_eth_hw_addr_set
-
-#endif /* LINUX_VERSION_IS_LESS(5, 15, 0) */
-
-#endif	/* _NET_BATMAN_ADV_COMPAT_LINUX_ETHERDEVICE_H_ */
diff --git a/compat-include/linux/if_bridge.h b/compat-include/linux/if_bridge.h
deleted file mode 100644
index 50aa0608..00000000
--- a/compat-include/linux/if_bridge.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-
-#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_IF_BRIDGE_H_
-#define _NET_BATMAN_ADV_COMPAT_LINUX_IF_BRIDGE_H_
-
-#include <linux/version.h>
-#include_next <linux/if_bridge.h>
-
-#if LINUX_VERSION_IS_LESS(5, 14, 0)
-
-#include <net/addrconf.h>
-
-#if IS_ENABLED(CONFIG_IPV6)
-static inline bool
-br_multicast_has_router_adjacent(struct net_device *dev, int proto)
-{
-	struct list_head bridge_mcast_list = LIST_HEAD_INIT(bridge_mcast_list);
-	struct br_ip_list *br_ip_entry, *tmp;
-	int ret;
-
-	if (proto != ETH_P_IPV6)
-		return true;
-
-	ret = br_multicast_list_adjacent(dev, &bridge_mcast_list);
-	if (ret < 0)
-		return true;
-
-	ret = false;
-
-	list_for_each_entry_safe(br_ip_entry, tmp, &bridge_mcast_list, list) {
-		if (br_ip_entry->addr.proto == htons(ETH_P_IPV6) &&
-		    ipv6_addr_is_ll_all_routers(&br_ip_entry->addr.dst.ip6))
-			ret = true;
-
-		list_del(&br_ip_entry->list);
-		kfree(br_ip_entry);
-	}
-
-	return ret;
-}
-#else
-static inline bool
-br_multicast_has_router_adjacent(struct net_device *dev, int proto)
-{
-	return true;
-}
-#endif
-
-#endif /* LINUX_VERSION_IS_LESS(5, 14, 0) */
-
-#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_IF_BRIDGE_H_ */
diff --git a/compat-include/linux/if_vlan.h b/compat-include/linux/if_vlan.h
index b56b2ac1..7b1dab12 100644
--- a/compat-include/linux/if_vlan.h
+++ b/compat-include/linux/if_vlan.h
@@ -7,8 +7,6 @@
 #include_next <linux/if_vlan.h>
 
 #if LINUX_VERSION_IS_LESS(6, 4, 0) && \
-    !(LINUX_VERSION_IS_GEQ(5, 10, 205) && LINUX_VERSION_IS_LESS(5, 11, 0)) && \
-    !(LINUX_VERSION_IS_GEQ(5, 15, 144) && LINUX_VERSION_IS_LESS(5, 16, 0)) && \
     !(LINUX_VERSION_IS_GEQ(6, 1, 69) && LINUX_VERSION_IS_LESS(6, 2, 0))
 
 /* Prefer this version in TX path, instead of
diff --git a/compat-include/linux/kstrtox.h b/compat-include/linux/kstrtox.h
deleted file mode 100644
index 800341a8..00000000
--- a/compat-include/linux/kstrtox.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-
-#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_KSTRTOX_H_
-#define _NET_BATMAN_ADV_COMPAT_LINUX_KSTRTOX_H_
-
-#include <linux/version.h>
-#if (LINUX_VERSION_IS_GEQ(5, 10, 185) && LINUX_VERSION_IS_LESS(5, 11, 0)) || \
-    LINUX_VERSION_IS_GEQ(5, 14, 0)
-#include_next <linux/kstrtox.h>
-#else
-#include <linux/kernel.h>
-#endif
-
-#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_KSTRTOX_H_ */
diff --git a/compat-include/linux/netdevice.h b/compat-include/linux/netdevice.h
index 6963e12d..45df743e 100644
--- a/compat-include/linux/netdevice.h
+++ b/compat-include/linux/netdevice.h
@@ -6,39 +6,7 @@
 #include <linux/version.h>
 #include_next <linux/netdevice.h>
 
-#if LINUX_VERSION_IS_LESS(5, 15, 0)
-
-static inline void batadv_dev_put(struct net_device *dev)
-{
-	if (!dev)
-		return;
-
-	dev_put(dev);
-}
-#define dev_put batadv_dev_put
-
-static inline void batadv_dev_hold(struct net_device *dev)
-{
-	if (!dev)
-		return;
-
-	dev_hold(dev);
-}
-#define dev_hold batadv_dev_hold
-
-#endif /* LINUX_VERSION_IS_LESS(5, 15, 0) */
-
-#if LINUX_VERSION_IS_LESS(5, 17, 0)
-
-typedef struct {} netdevice_tracker;
-
-#define netdev_hold(__dev, __tracker, __gfp) \
-	dev_hold(__dev)
-
-#define netdev_put(__dev, __tracker) \
-	dev_put(__dev)
-
-#elif LINUX_VERSION_IS_LESS(6, 0, 0)
+#if LINUX_VERSION_IS_LESS(6, 0, 0)
 
 #define netdev_hold(__dev, __tracker, __gfp) \
 	dev_hold_track(__dev, __tracker, __gfp)
@@ -46,19 +14,6 @@ typedef struct {} netdevice_tracker;
 #define netdev_put(__dev, __tracker) \
 	dev_put_track(__dev, __tracker)
 
-#endif /* LINUX_VERSION_IS_LESS(5, 17, 0) */
-
-#if LINUX_VERSION_IS_LESS(5, 18, 0)
-
-static inline int batadv_netif_rx(struct sk_buff *skb)
-{
-	if (in_interrupt())
-		return netif_rx(skb);
-	else
-		return netif_rx_ni(skb);
-}
-#define netif_rx batadv_netif_rx
-
-#endif /* LINUX_VERSION_IS_LESS(5, 18, 0) */
+#endif /* LINUX_VERSION_IS_LESS(6, 0, 0) */
 
 #endif	/* _NET_BATMAN_ADV_COMPAT_LINUX_NETDEVICE_H_ */
diff --git a/compat-include/linux/stdarg.h b/compat-include/linux/stdarg.h
deleted file mode 100644
index 3137c428..00000000
--- a/compat-include/linux/stdarg.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-
-#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_STDARG_H_
-#define _NET_BATMAN_ADV_COMPAT_LINUX_STDARG_H_
-
-#include <linux/version.h>
-#if LINUX_VERSION_IS_GEQ(5, 15, 0)
-#include_next <linux/stdarg.h>
-#else
-#include <stdarg.h>
-#endif
-
-#endif
diff --git a/compat-include/linux/string_choices.h b/compat-include/linux/string_choices.h
index 3c6dcf54..ff9783d0 100644
--- a/compat-include/linux/string_choices.h
+++ b/compat-include/linux/string_choices.h
@@ -8,18 +8,6 @@
 #include_next <linux/string_choices.h>
 #elif LINUX_VERSION_IS_GEQ(5, 18, 0)
 #include <linux/string_helpers.h>
-#else
-
-static inline const char *str_yes_no(bool v)
-{
-	return v ? "yes" : "no";
-}
-
-static inline const char *str_on_off(bool v)
-{
-	return v ? "on" : "off";
-}
-
 #endif
 
 #endif /* _NET_BATMAN_ADV_COMPAT_LINUX_STRING_CHOICES_H_ */
diff --git a/compat-include/linux/timer.h b/compat-include/linux/timer.h
index add50f58..659a2575 100644
--- a/compat-include/linux/timer.h
+++ b/compat-include/linux/timer.h
@@ -7,7 +7,6 @@
 #include_next <linux/timer.h>
 
 #if LINUX_VERSION_IS_LESS(6, 2, 0) && \
-    !(LINUX_VERSION_IS_GEQ(5, 15, 200) && LINUX_VERSION_IS_LESS(5, 16, 0)) && \
     !(LINUX_VERSION_IS_GEQ(6, 1, 158) && LINUX_VERSION_IS_LESS(6, 2, 0))
 
 #define timer_delete_sync(_timer) del_timer_sync(_timer)
diff --git a/compat-include/net/addrconf.h b/compat-include/net/addrconf.h
deleted file mode 100644
index 7b166c80..00000000
--- a/compat-include/net/addrconf.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-
-#ifndef _NET_BATMAN_ADV_COMPAT_NET_ADDRCONF_H_
-#define _NET_BATMAN_ADV_COMPAT_NET_ADDRCONF_H_
-
-#include <linux/version.h>
-#include_next <net/addrconf.h>
-
-#if LINUX_VERSION_IS_LESS(5, 13, 0)
-
-static bool batadv_mcast_mla_is_duplicate(u8 *mcast_addr,
-					  struct hlist_head *mcast_list);
-
-static inline int
-compat_batadv_mcast_mla_meshif_get_ipv6(struct net_device *dev,
-				 struct hlist_head *mcast_list,
-				 struct batadv_mcast_mla_flags *flags,
-				 u8 *mcast_addr,
-				struct batadv_hw_addr *new,
-				struct inet6_dev *in6_dev)
-
-{
-	struct ifmcaddr6 *pmc6;
-	int ret = 0;
-
-	if (flags->tvlv_flags & BATADV_MCAST_WANT_ALL_IPV6)
-		return 0;
-
-	rcu_read_lock();
-
-	in6_dev = __in6_dev_get(dev);
-	if (!in6_dev) {
-		rcu_read_unlock();
-		return 0;
-	}
-
-	read_lock_bh(&in6_dev->lock);
-	for (pmc6 = in6_dev->mc_list; pmc6; pmc6 = pmc6->next) {
-		if (IPV6_ADDR_MC_SCOPE(&pmc6->mca_addr) <
-		    IPV6_ADDR_SCOPE_LINKLOCAL)
-			continue;
-
-		if (flags->tvlv_flags & BATADV_MCAST_WANT_ALL_UNSNOOPABLES &&
-		    ipv6_addr_is_ll_all_nodes(&pmc6->mca_addr))
-			continue;
-
-		if (!(flags->tvlv_flags & BATADV_MCAST_WANT_NO_RTR6) &&
-		    IPV6_ADDR_MC_SCOPE(&pmc6->mca_addr) >
-		    IPV6_ADDR_SCOPE_LINKLOCAL)
-			continue;
-
-		ipv6_eth_mc_map(&pmc6->mca_addr, mcast_addr);
-
-		if (batadv_mcast_mla_is_duplicate(mcast_addr, mcast_list))
-			continue;
-
-		new = kmalloc_obj(*new, GFP_ATOMIC);
-		if (!new) {
-			ret = -ENOMEM;
-			break;
-		}
-
-		ether_addr_copy(new->addr, mcast_addr);
-		hlist_add_head(&new->list, mcast_list);
-		ret++;
-	}
-	read_unlock_bh(&in6_dev->lock);
-	rcu_read_unlock();
-
-	return ret;
-}
-
-#define ifmcaddr6 \
-		net_device *orig_dev = dev; \
-		return compat_batadv_mcast_mla_meshif_get_ipv6(orig_dev, \
-							       mcast_list, \
-							       flags, \
-							       mcast_addr, \
-							       new = NULL, \
-							       in6_dev = NULL); \
-	} \
-	static inline int \
-	__unused_batadv_mcast_mla_meshif_get_ipv6(struct net_device *dev, \
-					     struct hlist_head *mcast_list, \
-					     struct batadv_mcast_mla_flags *flags) \
-	{ \
-		struct batadv_hw_addr *new; \
-		struct inet6_dev *in6_dev; \
-		u8 mcast_addr[ETH_ALEN]; \
-		struct ifmcaddr6
-
-#endif /* LINUX_VERSION_IS_LESS(5, 13, 0) */
-
-#endif	/* _NET_BATMAN_ADV_COMPAT_NET_ADDRCONF_H_ */
diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c
index 61410364..82fd527b 100644
--- a/net/batman-adv/multicast.c
+++ b/net/batman-adv/multicast.c
@@ -133,14 +133,7 @@ static u8 batadv_mcast_mla_rtr_flags_meshif_get_ipv6(struct net_device *dev)
 {
 	struct inet6_dev *in6_dev = __in6_dev_get(dev);
 
-#if (LINUX_VERSION_IS_GEQ(5, 10, 111) && LINUX_VERSION_IS_LESS(5, 11, 0)) || /* UGLY_HACK */ \
-    (LINUX_VERSION_IS_GEQ(5, 15, 34) && LINUX_VERSION_IS_LESS(5, 16, 0)) || /* UGLY_HACK */ \
-    (LINUX_VERSION_IS_GEQ(5, 16, 20) && LINUX_VERSION_IS_LESS(5, 17, 0)) || /* UGLY_HACK */ \
-    LINUX_VERSION_IS_GEQ(5, 17, 3) // UGLY_HACK_NEW
 	if (in6_dev && atomic_read(&in6_dev->cnf.mc_forwarding))
-#else // UGLY_HACK_OLD
-	if (in6_dev && in6_dev->cnf.mc_forwarding)
-#endif // UGLY_HACK_STOP
 		return BATADV_NO_FLAGS;
 	else
 		return BATADV_MCAST_WANT_NO_RTR6;

-- 
2.47.3
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.