summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2009-11-01 20:51:22 +0100
committerDavid S. Miller <davem@davemloft.net>2009-11-02 08:55:13 +0100
commit1178f66eaea968d093cafd37c226ebeaa70d56cf (patch)
tree928b540a54d4a8486a73d9a1387cda326dcedef1
parentifb: RCU locking avoids touching dev refcount (diff)
downloadlinux-1178f66eaea968d093cafd37c226ebeaa70d56cf.tar.xz
linux-1178f66eaea968d093cafd37c226ebeaa70d56cf.zip
pppoe: RCU locking in get_item_by_addr()
Use dev_get_by_name_rcu() instead of dev_get_by_name(), to avoid touching device refcount in hotpath. Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/pppoe.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/drivers/net/pppoe.c b/drivers/net/pppoe.c
index 2559991eea6a..60c8d233209f 100644
--- a/drivers/net/pppoe.c
+++ b/drivers/net/pppoe.c
@@ -250,20 +250,19 @@ static inline struct pppox_sock *get_item_by_addr(struct net *net,
{
struct net_device *dev;
struct pppoe_net *pn;
- struct pppox_sock *pppox_sock;
+ struct pppox_sock *pppox_sock = NULL;
int ifindex;
- dev = dev_get_by_name(net, sp->sa_addr.pppoe.dev);
- if (!dev)
- return NULL;
-
- ifindex = dev->ifindex;
- pn = net_generic(net, pppoe_net_id);
- pppox_sock = get_item(pn, sp->sa_addr.pppoe.sid,
+ rcu_read_lock();
+ dev = dev_get_by_name_rcu(net, sp->sa_addr.pppoe.dev);
+ if (dev) {
+ ifindex = dev->ifindex;
+ pn = net_generic(net, pppoe_net_id);
+ pppox_sock = get_item(pn, sp->sa_addr.pppoe.sid,
sp->sa_addr.pppoe.remote, ifindex);
- dev_put(dev);
-
+ }
+ rcu_read_unlock();
return pppox_sock;
}