Commit 99fe3c39 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

net: dev_getfirstbyhwtype() optimization

Use RCU to avoid RTNL use in dev_getfirstbyhwtype()
Signed-off-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ec733b15
...@@ -772,14 +772,17 @@ EXPORT_SYMBOL(__dev_getfirstbyhwtype); ...@@ -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);
......
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