]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drivers: use in_dev_for_each_ifa_rtnl/rcu
authorFlorian Westphal <fw@strlen.de>
Fri, 31 May 2019 16:27:08 +0000 (18:27 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 3 Jun 2019 01:06:26 +0000 (18:06 -0700)
Like previous patches, use the new iterator macros to avoid sparse
warnings once proper __rcu annotations are added.

Compile tested only.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/infiniband/core/roce_gid_mgmt.c
drivers/infiniband/hw/cxgb4/cm.c
drivers/infiniband/hw/i40iw/i40iw_cm.c
drivers/infiniband/hw/i40iw/i40iw_main.c
drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
drivers/net/wan/hdlc_cisco.c

index 558de0b9895cb979745b5002a623568bb5b21f7b..2860def84f4d3ec37bab4b2695056be65d01a413 100644 (file)
@@ -330,6 +330,7 @@ static void bond_delete_netdev_default_gids(struct ib_device *ib_dev,
 static void enum_netdev_ipv4_ips(struct ib_device *ib_dev,
                                 u8 port, struct net_device *ndev)
 {
+       const struct in_ifaddr *ifa;
        struct in_device *in_dev;
        struct sin_list {
                struct list_head        list;
@@ -349,7 +350,7 @@ static void enum_netdev_ipv4_ips(struct ib_device *ib_dev,
                return;
        }
 
-       for_ifa(in_dev) {
+       in_dev_for_each_ifa_rcu(ifa, in_dev) {
                struct sin_list *entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
 
                if (!entry)
@@ -359,7 +360,7 @@ static void enum_netdev_ipv4_ips(struct ib_device *ib_dev,
                entry->ip.sin_addr.s_addr = ifa->ifa_address;
                list_add_tail(&entry->list, &sin_list);
        }
-       endfor_ifa(in_dev);
+
        rcu_read_unlock();
 
        list_for_each_entry_safe(sin_iter, sin_temp, &sin_list, list) {
index 0f3b1193d5f8552b65f05a63f7016ba32a417ed3..09fcfc9e052d7a61b69c12e53688a39cc9b5f104 100644 (file)
@@ -3230,17 +3230,22 @@ static int pick_local_ipaddrs(struct c4iw_dev *dev, struct iw_cm_id *cm_id)
        int found = 0;
        struct sockaddr_in *laddr = (struct sockaddr_in *)&cm_id->m_local_addr;
        struct sockaddr_in *raddr = (struct sockaddr_in *)&cm_id->m_remote_addr;
+       const struct in_ifaddr *ifa;
 
        ind = in_dev_get(dev->rdev.lldi.ports[0]);
        if (!ind)
                return -EADDRNOTAVAIL;
-       for_primary_ifa(ind) {
+       rcu_read_lock();
+       in_dev_for_each_ifa_rcu(ifa, ind) {
+               if (ifa->ifa_flags & IFA_F_SECONDARY)
+                       continue;
                laddr->sin_addr.s_addr = ifa->ifa_address;
                raddr->sin_addr.s_addr = ifa->ifa_address;
                found = 1;
                break;
        }
-       endfor_ifa(ind);
+       rcu_read_unlock();
+
        in_dev_put(ind);
        return found ? 0 : -EADDRNOTAVAIL;
 }
index 8233f5a4e623d9a7d83b4d8f190ba3c016d66378..700a5d06b60cab92052001035582440c3a4ff5c4 100644 (file)
@@ -1773,8 +1773,11 @@ static enum i40iw_status_code i40iw_add_mqh_4(
                if ((((rdma_vlan_dev_vlan_id(dev) < I40IW_NO_VLAN) &&
                      (rdma_vlan_dev_real_dev(dev) == iwdev->netdev)) ||
                    (dev == iwdev->netdev)) && (dev->flags & IFF_UP)) {
+                       const struct in_ifaddr *ifa;
+
                        idev = in_dev_get(dev);
-                       for_ifa(idev) {
+
+                       in_dev_for_each_ifa_rtnl(ifa, idev) {
                                i40iw_debug(&iwdev->sc_dev,
                                            I40IW_DEBUG_CM,
                                            "Allocating child CM Listener forIP=%pI4, vlan_id=%d, MAC=%pM\n",
@@ -1819,7 +1822,7 @@ static enum i40iw_status_code i40iw_add_mqh_4(
                                        cm_parent_listen_node->cm_core->stats_listen_nodes_created--;
                                }
                        }
-                       endfor_ifa(idev);
+
                        in_dev_put(idev);
                }
        }
index 10932baee279e00288403012ce2ac0d14189bf4b..d44cf33df81aecf74b73cf133e329d6a8e23e3fb 100644 (file)
@@ -1222,8 +1222,10 @@ static void i40iw_add_ipv4_addr(struct i40iw_device *iwdev)
                if ((((rdma_vlan_dev_vlan_id(dev) < 0xFFFF) &&
                      (rdma_vlan_dev_real_dev(dev) == iwdev->netdev)) ||
                    (dev == iwdev->netdev)) && (dev->flags & IFF_UP)) {
+                       const struct in_ifaddr *ifa;
+
                        idev = in_dev_get(dev);
-                       for_ifa(idev) {
+                       in_dev_for_each_ifa_rtnl(ifa, idev) {
                                i40iw_debug(&iwdev->sc_dev, I40IW_DEBUG_CM,
                                            "IP=%pI4, vlan_id=%d, MAC=%pM\n", &ifa->ifa_address,
                                             rdma_vlan_dev_vlan_id(dev), dev->dev_addr);
@@ -1235,7 +1237,7 @@ static void i40iw_add_ipv4_addr(struct i40iw_device *iwdev)
                                                       true,
                                                       I40IW_ARP_ADD);
                        }
-                       endfor_ifa(idev);
+
                        in_dev_put(idev);
                }
        }
index 84cb624345567c7bf44a91104226b04179ae7295..58e2eaf770148d142480f77c704e7359f28a8ee2 100644 (file)
@@ -3248,6 +3248,7 @@ netxen_config_indev_addr(struct netxen_adapter *adapter,
                struct net_device *dev, unsigned long event)
 {
        struct in_device *indev;
+       struct in_ifaddr *ifa;
 
        if (!netxen_destip_supported(adapter))
                return;
@@ -3256,7 +3257,8 @@ netxen_config_indev_addr(struct netxen_adapter *adapter,
        if (!indev)
                return;
 
-       for_ifa(indev) {
+       rcu_read_lock();
+       in_dev_for_each_ifa_rcu(ifa, indev) {
                switch (event) {
                case NETDEV_UP:
                        netxen_list_config_ip(adapter, ifa, NX_IP_UP);
@@ -3267,8 +3269,8 @@ netxen_config_indev_addr(struct netxen_adapter *adapter,
                default:
                        break;
                }
-       } endfor_ifa(indev);
-
+       }
+       rcu_read_unlock();
        in_dev_put(indev);
 }
 
index 7a873002e6263d955c88775f1ee380d0fba98dae..c07438db30ba1b287639ce6f12d5d032f567d4f1 100644 (file)
@@ -4119,13 +4119,14 @@ static void
 qlcnic_config_indev_addr(struct qlcnic_adapter *adapter,
                        struct net_device *dev, unsigned long event)
 {
+       const struct in_ifaddr *ifa;
        struct in_device *indev;
 
        indev = in_dev_get(dev);
        if (!indev)
                return;
 
-       for_ifa(indev) {
+       in_dev_for_each_ifa_rtnl(ifa, indev) {
                switch (event) {
                case NETDEV_UP:
                        qlcnic_config_ipaddr(adapter,
@@ -4138,7 +4139,7 @@ qlcnic_config_indev_addr(struct qlcnic_adapter *adapter,
                default:
                        break;
                }
-       } endfor_ifa(indev);
+       }
 
        in_dev_put(indev);
 }
index 320039d329c7d17a5473d17d12e77e244a94a79b..4976ca3f30c74ef2649a07d7dd182554507060f2 100644 (file)
@@ -196,16 +196,15 @@ static int cisco_rx(struct sk_buff *skb)
                        mask = ~cpu_to_be32(0); /* is the mask correct? */
 
                        if (in_dev != NULL) {
-                               struct in_ifaddr **ifap = &in_dev->ifa_list;
+                               const struct in_ifaddr *ifa;
 
-                               while (*ifap != NULL) {
+                               in_dev_for_each_ifa_rcu(ifa, in_dev) {
                                        if (strcmp(dev->name,
-                                                  (*ifap)->ifa_label) == 0) {
-                                               addr = (*ifap)->ifa_local;
-                                               mask = (*ifap)->ifa_mask;
+                                                  ifa->ifa_label) == 0) {
+                                               addr = ifa->ifa_local;
+                                               mask = ifa->ifa_mask;
                                                break;
                                        }
-                                       ifap = &(*ifap)->ifa_next;
                                }
 
                                cisco_keepalive_send(dev, CISCO_ADDR_REPLY,