diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2009-11-01 20:31:03 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-11-02 08:55:10 +0100 |
commit | 685c7944055b9de51ff509719070afae92b3dbe1 (patch) | |
tree | 5aeb11059fbfd1d8dd70953d1d5f93501f246121 /net | |
parent | ipv4: inetdev_by_index() switch to RCU (diff) | |
download | linux-685c7944055b9de51ff509719070afae92b3dbe1.tar.xz linux-685c7944055b9de51ff509719070afae92b3dbe1.zip |
icmp: icmp_send() can avoid a dev_put()
We can avoid touching device refcount in icmp_send(),
using dev_get_by_index_rcu()
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/ipv4/icmp.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c index 84adb5754c96..fe11f60ce41b 100644 --- a/net/ipv4/icmp.c +++ b/net/ipv4/icmp.c @@ -501,15 +501,16 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info) if (!(rt->rt_flags & RTCF_LOCAL)) { struct net_device *dev = NULL; + rcu_read_lock(); if (rt->fl.iif && net->ipv4.sysctl_icmp_errors_use_inbound_ifaddr) - dev = dev_get_by_index(net, rt->fl.iif); + dev = dev_get_by_index_rcu(net, rt->fl.iif); - if (dev) { + if (dev) saddr = inet_select_addr(dev, 0, RT_SCOPE_LINK); - dev_put(dev); - } else + else saddr = 0; + rcu_read_unlock(); } tos = icmp_pointers[type].error ? ((iph->tos & IPTOS_TOS_MASK) | |