提交 685c7944 编写于 作者: E Eric Dumazet 提交者: David S. Miller

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: NEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 c148fc2e
...@@ -501,15 +501,16 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info) ...@@ -501,15 +501,16 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
if (!(rt->rt_flags & RTCF_LOCAL)) { if (!(rt->rt_flags & RTCF_LOCAL)) {
struct net_device *dev = NULL; struct net_device *dev = NULL;
rcu_read_lock();
if (rt->fl.iif && if (rt->fl.iif &&
net->ipv4.sysctl_icmp_errors_use_inbound_ifaddr) 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); saddr = inet_select_addr(dev, 0, RT_SCOPE_LINK);
dev_put(dev); else
} else
saddr = 0; saddr = 0;
rcu_read_unlock();
} }
tos = icmp_pointers[type].error ? ((iph->tos & IPTOS_TOS_MASK) | tos = icmp_pointers[type].error ? ((iph->tos & IPTOS_TOS_MASK) |
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册