Commit cb8f1478 authored by Florian Westphal's avatar Florian Westphal Committed by David S. Miller

drivers: use in_dev_for_each_ifa_rtnl/rcu

Like previous patches, use the new iterator macros to avoid sparse
warnings once proper __rcu annotations are added.

Compile tested only.
Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent cd5a411d
...@@ -330,6 +330,7 @@ static void bond_delete_netdev_default_gids(struct ib_device *ib_dev, ...@@ -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, static void enum_netdev_ipv4_ips(struct ib_device *ib_dev,
u8 port, struct net_device *ndev) u8 port, struct net_device *ndev)
{ {
const struct in_ifaddr *ifa;
struct in_device *in_dev; struct in_device *in_dev;
struct sin_list { struct sin_list {
struct list_head list; struct list_head list;
...@@ -349,7 +350,7 @@ static void enum_netdev_ipv4_ips(struct ib_device *ib_dev, ...@@ -349,7 +350,7 @@ static void enum_netdev_ipv4_ips(struct ib_device *ib_dev,
return; return;
} }
for_ifa(in_dev) { in_dev_for_each_ifa_rcu(ifa, in_dev) {
struct sin_list *entry = kzalloc(sizeof(*entry), GFP_ATOMIC); struct sin_list *entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
if (!entry) if (!entry)
...@@ -359,7 +360,7 @@ static void enum_netdev_ipv4_ips(struct ib_device *ib_dev, ...@@ -359,7 +360,7 @@ static void enum_netdev_ipv4_ips(struct ib_device *ib_dev,
entry->ip.sin_addr.s_addr = ifa->ifa_address; entry->ip.sin_addr.s_addr = ifa->ifa_address;
list_add_tail(&entry->list, &sin_list); list_add_tail(&entry->list, &sin_list);
} }
endfor_ifa(in_dev);
rcu_read_unlock(); rcu_read_unlock();
list_for_each_entry_safe(sin_iter, sin_temp, &sin_list, list) { list_for_each_entry_safe(sin_iter, sin_temp, &sin_list, list) {
......
...@@ -3230,17 +3230,22 @@ static int pick_local_ipaddrs(struct c4iw_dev *dev, struct iw_cm_id *cm_id) ...@@ -3230,17 +3230,22 @@ static int pick_local_ipaddrs(struct c4iw_dev *dev, struct iw_cm_id *cm_id)
int found = 0; int found = 0;
struct sockaddr_in *laddr = (struct sockaddr_in *)&cm_id->m_local_addr; struct sockaddr_in *laddr = (struct sockaddr_in *)&cm_id->m_local_addr;
struct sockaddr_in *raddr = (struct sockaddr_in *)&cm_id->m_remote_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]); ind = in_dev_get(dev->rdev.lldi.ports[0]);
if (!ind) if (!ind)
return -EADDRNOTAVAIL; 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; laddr->sin_addr.s_addr = ifa->ifa_address;
raddr->sin_addr.s_addr = ifa->ifa_address; raddr->sin_addr.s_addr = ifa->ifa_address;
found = 1; found = 1;
break; break;
} }
endfor_ifa(ind); rcu_read_unlock();
in_dev_put(ind); in_dev_put(ind);
return found ? 0 : -EADDRNOTAVAIL; return found ? 0 : -EADDRNOTAVAIL;
} }
......
...@@ -1773,8 +1773,11 @@ static enum i40iw_status_code i40iw_add_mqh_4( ...@@ -1773,8 +1773,11 @@ static enum i40iw_status_code i40iw_add_mqh_4(
if ((((rdma_vlan_dev_vlan_id(dev) < I40IW_NO_VLAN) && if ((((rdma_vlan_dev_vlan_id(dev) < I40IW_NO_VLAN) &&
(rdma_vlan_dev_real_dev(dev) == iwdev->netdev)) || (rdma_vlan_dev_real_dev(dev) == iwdev->netdev)) ||
(dev == iwdev->netdev)) && (dev->flags & IFF_UP)) { (dev == iwdev->netdev)) && (dev->flags & IFF_UP)) {
const struct in_ifaddr *ifa;
idev = in_dev_get(dev); idev = in_dev_get(dev);
for_ifa(idev) {
in_dev_for_each_ifa_rtnl(ifa, idev) {
i40iw_debug(&iwdev->sc_dev, i40iw_debug(&iwdev->sc_dev,
I40IW_DEBUG_CM, I40IW_DEBUG_CM,
"Allocating child CM Listener forIP=%pI4, vlan_id=%d, MAC=%pM\n", "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( ...@@ -1819,7 +1822,7 @@ static enum i40iw_status_code i40iw_add_mqh_4(
cm_parent_listen_node->cm_core->stats_listen_nodes_created--; cm_parent_listen_node->cm_core->stats_listen_nodes_created--;
} }
} }
endfor_ifa(idev);
in_dev_put(idev); in_dev_put(idev);
} }
} }
......
...@@ -1222,8 +1222,10 @@ static void i40iw_add_ipv4_addr(struct i40iw_device *iwdev) ...@@ -1222,8 +1222,10 @@ static void i40iw_add_ipv4_addr(struct i40iw_device *iwdev)
if ((((rdma_vlan_dev_vlan_id(dev) < 0xFFFF) && if ((((rdma_vlan_dev_vlan_id(dev) < 0xFFFF) &&
(rdma_vlan_dev_real_dev(dev) == iwdev->netdev)) || (rdma_vlan_dev_real_dev(dev) == iwdev->netdev)) ||
(dev == iwdev->netdev)) && (dev->flags & IFF_UP)) { (dev == iwdev->netdev)) && (dev->flags & IFF_UP)) {
const struct in_ifaddr *ifa;
idev = in_dev_get(dev); idev = in_dev_get(dev);
for_ifa(idev) { in_dev_for_each_ifa_rtnl(ifa, idev) {
i40iw_debug(&iwdev->sc_dev, I40IW_DEBUG_CM, i40iw_debug(&iwdev->sc_dev, I40IW_DEBUG_CM,
"IP=%pI4, vlan_id=%d, MAC=%pM\n", &ifa->ifa_address, "IP=%pI4, vlan_id=%d, MAC=%pM\n", &ifa->ifa_address,
rdma_vlan_dev_vlan_id(dev), dev->dev_addr); rdma_vlan_dev_vlan_id(dev), dev->dev_addr);
...@@ -1235,7 +1237,7 @@ static void i40iw_add_ipv4_addr(struct i40iw_device *iwdev) ...@@ -1235,7 +1237,7 @@ static void i40iw_add_ipv4_addr(struct i40iw_device *iwdev)
true, true,
I40IW_ARP_ADD); I40IW_ARP_ADD);
} }
endfor_ifa(idev);
in_dev_put(idev); in_dev_put(idev);
} }
} }
......
...@@ -3248,6 +3248,7 @@ netxen_config_indev_addr(struct netxen_adapter *adapter, ...@@ -3248,6 +3248,7 @@ netxen_config_indev_addr(struct netxen_adapter *adapter,
struct net_device *dev, unsigned long event) struct net_device *dev, unsigned long event)
{ {
struct in_device *indev; struct in_device *indev;
struct in_ifaddr *ifa;
if (!netxen_destip_supported(adapter)) if (!netxen_destip_supported(adapter))
return; return;
...@@ -3256,7 +3257,8 @@ netxen_config_indev_addr(struct netxen_adapter *adapter, ...@@ -3256,7 +3257,8 @@ netxen_config_indev_addr(struct netxen_adapter *adapter,
if (!indev) if (!indev)
return; return;
for_ifa(indev) { rcu_read_lock();
in_dev_for_each_ifa_rcu(ifa, indev) {
switch (event) { switch (event) {
case NETDEV_UP: case NETDEV_UP:
netxen_list_config_ip(adapter, ifa, NX_IP_UP); netxen_list_config_ip(adapter, ifa, NX_IP_UP);
...@@ -3267,8 +3269,8 @@ netxen_config_indev_addr(struct netxen_adapter *adapter, ...@@ -3267,8 +3269,8 @@ netxen_config_indev_addr(struct netxen_adapter *adapter,
default: default:
break; break;
} }
} endfor_ifa(indev); }
rcu_read_unlock();
in_dev_put(indev); in_dev_put(indev);
} }
......
...@@ -4119,13 +4119,14 @@ static void ...@@ -4119,13 +4119,14 @@ static void
qlcnic_config_indev_addr(struct qlcnic_adapter *adapter, qlcnic_config_indev_addr(struct qlcnic_adapter *adapter,
struct net_device *dev, unsigned long event) struct net_device *dev, unsigned long event)
{ {
const struct in_ifaddr *ifa;
struct in_device *indev; struct in_device *indev;
indev = in_dev_get(dev); indev = in_dev_get(dev);
if (!indev) if (!indev)
return; return;
for_ifa(indev) { in_dev_for_each_ifa_rtnl(ifa, indev) {
switch (event) { switch (event) {
case NETDEV_UP: case NETDEV_UP:
qlcnic_config_ipaddr(adapter, qlcnic_config_ipaddr(adapter,
...@@ -4138,7 +4139,7 @@ qlcnic_config_indev_addr(struct qlcnic_adapter *adapter, ...@@ -4138,7 +4139,7 @@ qlcnic_config_indev_addr(struct qlcnic_adapter *adapter,
default: default:
break; break;
} }
} endfor_ifa(indev); }
in_dev_put(indev); in_dev_put(indev);
} }
......
...@@ -196,16 +196,15 @@ static int cisco_rx(struct sk_buff *skb) ...@@ -196,16 +196,15 @@ static int cisco_rx(struct sk_buff *skb)
mask = ~cpu_to_be32(0); /* is the mask correct? */ mask = ~cpu_to_be32(0); /* is the mask correct? */
if (in_dev != NULL) { 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, if (strcmp(dev->name,
(*ifap)->ifa_label) == 0) { ifa->ifa_label) == 0) {
addr = (*ifap)->ifa_local; addr = ifa->ifa_local;
mask = (*ifap)->ifa_mask; mask = ifa->ifa_mask;
break; break;
} }
ifap = &(*ifap)->ifa_next;
} }
cisco_keepalive_send(dev, CISCO_ADDR_REPLY, cisco_keepalive_send(dev, CISCO_ADDR_REPLY,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment