net: dev_getfirstbyhwtype() optimization
Use RCU to avoid RTNL use in dev_getfirstbyhwtype() Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
ec733b15a3
commit
99fe3c391d
|
@ -772,14 +772,17 @@ EXPORT_SYMBOL(__dev_getfirstbyhwtype);
|
||||||
|
|
||||||
struct net_device *dev_getfirstbyhwtype(struct net *net, unsigned short type)
|
struct net_device *dev_getfirstbyhwtype(struct net *net, unsigned short type)
|
||||||
{
|
{
|
||||||
struct net_device *dev;
|
struct net_device *dev, *ret = NULL;
|
||||||
|
|
||||||
rtnl_lock();
|
rcu_read_lock();
|
||||||
dev = __dev_getfirstbyhwtype(net, type);
|
for_each_netdev_rcu(net, dev)
|
||||||
if (dev)
|
if (dev->type == type) {
|
||||||
dev_hold(dev);
|
dev_hold(dev);
|
||||||
rtnl_unlock();
|
ret = dev;
|
||||||
return dev;
|
break;
|
||||||
|
}
|
||||||
|
rcu_read_unlock();
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(dev_getfirstbyhwtype);
|
EXPORT_SYMBOL(dev_getfirstbyhwtype);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue