Whamcloud - gitweb
LU-12634 lnet: for_ifa removed. Use in_dev_for_each_ifa_rtnl 87/38487/3
authorShaun Tancheff <stancheff@cray.com>
Mon, 4 May 2020 21:59:47 +0000 (14:59 -0700)
committerOleg Drokin <green@whamcloud.com>
Wed, 27 May 2020 02:40:18 +0000 (02:40 +0000)
Linux 5.3 removed for_ifa and replaced it with an _rntl and _rcu
versions for use with their respective locking primitives.

kernel-commit: ef11db3310e272d3d8dbe8739e0770820dd20e52

This patch is back-ported from the following one:
Lustre-commit: 6e0d0146276353559c821916e193c90d167b14e0
Lustre-change: https://review.whamcloud.com/35744

Test-Parameters: trivial
Cray-bug-id: LUS-7689
Signed-off-by: Shaun Tancheff <stancheff@cray.com>
Change-Id: Iea07222b9abb3f9c219d28fe2c660d9eaf21af80
Reviewed-on: https://review.whamcloud.com/38487
Reviewed-by: Petros Koutoupis <petros.koutoupis@hpe.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/lnet/config.c

index 4e2e13d..f0ba35b 100644 (file)
@@ -1604,6 +1604,19 @@ lnet_match_networks (char **networksp, char *ip2nets, __u32 *ipaddrs, int nip)
        *networksp = networks;
        return count;
 }
+/*
+ * kernel 5.3: commit ef11db3310e272d3d8dbe8739e0770820dd20e52
+ * added in_dev_for_each_ifa_rtnl and in_dev_for_each_ifa_rcu
+ * and removed for_ifa and endfor_ifa.
+ * Use the _rntl variant as the current locking is rtnl.
+ */
+#ifdef in_dev_for_each_ifa_rtnl
+#define DECLARE_CONST_IN_IFADDR(ifa)           const struct in_ifaddr *ifa
+#define endfor_ifa(in_dev)
+#else
+#define DECLARE_CONST_IN_IFADDR(ifa)
+#define in_dev_for_each_ifa_rtnl(ifa, in_dev)  for_ifa((in_dev))
+#endif
 
 int lnet_inet_enumerate(struct lnet_inetdev **dev_list, struct net *ns)
 {
@@ -1611,6 +1624,7 @@ int lnet_inet_enumerate(struct lnet_inetdev **dev_list, struct net *ns)
        struct net_device *dev;
        int nalloc = 0;
        int nip = 0;
+       DECLARE_CONST_IN_IFADDR(ifa);
 
        rtnl_lock();
        for_each_netdev(ns, dev) {
@@ -1638,7 +1652,7 @@ int lnet_inet_enumerate(struct lnet_inetdev **dev_list, struct net *ns)
                node_id = dev_to_node(&dev->dev);
                cpt = cfs_cpt_of_node(lnet_cpt_table(), node_id);
 
-               for_ifa(in_dev) {
+               in_dev_for_each_ifa_rtnl(ifa, in_dev) {
                        if (nip >= nalloc) {
                                struct lnet_inetdev *tmp;