net: Introduce for_each_netdev_rcu() iterator
Adds RCU management to the list of netdevices. Convert some for_each_netdev() users to RCU version, if it can avoid read_lock-ing dev_base_lock Ie: read_lock(&dev_base_loack); for_each_netdev(net, dev) some_action(); read_unlock(&dev_base_lock); becomes : rcu_read_lock(); for_each_netdev_rcu(net, dev) some_action(); rcu_read_unlock(); Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
d0075634cf
commit
c6d14c8456
@@ -481,9 +481,8 @@ static void addrconf_forward_change(struct net *net, __s32 newf)
|
||||
struct net_device *dev;
|
||||
struct inet6_dev *idev;
|
||||
|
||||
read_lock(&dev_base_lock);
|
||||
for_each_netdev(net, dev) {
|
||||
rcu_read_lock();
|
||||
rcu_read_lock();
|
||||
for_each_netdev_rcu(net, dev) {
|
||||
idev = __in6_dev_get(dev);
|
||||
if (idev) {
|
||||
int changed = (!idev->cnf.forwarding) ^ (!newf);
|
||||
@@ -491,9 +490,8 @@ static void addrconf_forward_change(struct net *net, __s32 newf)
|
||||
if (changed)
|
||||
dev_forward_change(idev);
|
||||
}
|
||||
rcu_read_unlock();
|
||||
}
|
||||
read_unlock(&dev_base_lock);
|
||||
rcu_read_unlock();
|
||||
}
|
||||
|
||||
static int addrconf_fixup_forwarding(struct ctl_table *table, int *p, int old)
|
||||
@@ -1137,10 +1135,9 @@ int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
|
||||
hiscore->rule = -1;
|
||||
hiscore->ifa = NULL;
|
||||
|
||||
read_lock(&dev_base_lock);
|
||||
rcu_read_lock();
|
||||
|
||||
for_each_netdev(net, dev) {
|
||||
for_each_netdev_rcu(net, dev) {
|
||||
struct inet6_dev *idev;
|
||||
|
||||
/* Candidate Source Address (section 4)
|
||||
@@ -1235,7 +1232,6 @@ try_nextdev:
|
||||
read_unlock_bh(&idev->lock);
|
||||
}
|
||||
rcu_read_unlock();
|
||||
read_unlock(&dev_base_lock);
|
||||
|
||||
if (!hiscore->ifa)
|
||||
return -EADDRNOTAVAIL;
|
||||
@@ -4052,9 +4048,8 @@ static void addrconf_disable_change(struct net *net, __s32 newf)
|
||||
struct net_device *dev;
|
||||
struct inet6_dev *idev;
|
||||
|
||||
read_lock(&dev_base_lock);
|
||||
for_each_netdev(net, dev) {
|
||||
rcu_read_lock();
|
||||
rcu_read_lock();
|
||||
for_each_netdev_rcu(net, dev) {
|
||||
idev = __in6_dev_get(dev);
|
||||
if (idev) {
|
||||
int changed = (!idev->cnf.disable_ipv6) ^ (!newf);
|
||||
@@ -4062,9 +4057,8 @@ static void addrconf_disable_change(struct net *net, __s32 newf)
|
||||
if (changed)
|
||||
dev_disable_change(idev);
|
||||
}
|
||||
rcu_read_unlock();
|
||||
}
|
||||
read_unlock(&dev_base_lock);
|
||||
rcu_read_unlock();
|
||||
}
|
||||
|
||||
static int addrconf_disable_ipv6(struct ctl_table *table, int *p, int old)
|
||||
|
Reference in New Issue
Block a user