summaryrefslogtreecommitdiff
path: root/net/core/dev.c
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2010-03-18 14:27:25 +0300
committerDavid S. Miller <davem@davemloft.net>2010-03-22 06:33:36 +0300
commit99fe3c391d50d381687fd84ed0ab22d57079e41f (patch)
tree5e7e88d73d0d96e60c3471ab4812b847a413645d /net/core/dev.c
parentec733b15a3ef0b5759141a177f8044a2f40c41e7 (diff)
downloadlinux-99fe3c391d50d381687fd84ed0ab22d57079e41f.tar.xz
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>
Diffstat (limited to 'net/core/dev.c')
-rw-r--r--net/core/dev.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index 2d01f18f303a..a03aab45e84f 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -772,14 +772,17 @@ EXPORT_SYMBOL(__dev_getfirstbyhwtype);
struct net_device *dev_getfirstbyhwtype(struct net *net, unsigned short type)
{
- struct net_device *dev;
+ struct net_device *dev, *ret = NULL;
- rtnl_lock();
- dev = __dev_getfirstbyhwtype(net, type);
- if (dev)
- dev_hold(dev);
- rtnl_unlock();
- return dev;
+ rcu_read_lock();
+ for_each_netdev_rcu(net, dev)
+ if (dev->type == type) {
+ dev_hold(dev);
+ ret = dev;
+ break;
+ }
+ rcu_read_unlock();
+ return ret;
}
EXPORT_SYMBOL(dev_getfirstbyhwtype);