Commit 536b2e92 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

ipv6: no more dev_put() in datagram_send_ctl()

Avoids touching device refcount in datagram_send_ctl(), thanks to RCU
Signed-off-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 16ba5e8e
...@@ -537,12 +537,17 @@ int datagram_send_ctl(struct net *net, ...@@ -537,12 +537,17 @@ int datagram_send_ctl(struct net *net,
addr_type = __ipv6_addr_type(&src_info->ipi6_addr); addr_type = __ipv6_addr_type(&src_info->ipi6_addr);
rcu_read_lock();
if (fl->oif) { if (fl->oif) {
dev = dev_get_by_index(net, fl->oif); dev = dev_get_by_index_rcu(net, fl->oif);
if (!dev) if (!dev) {
rcu_read_unlock();
return -ENODEV; return -ENODEV;
} else if (addr_type & IPV6_ADDR_LINKLOCAL) }
} else if (addr_type & IPV6_ADDR_LINKLOCAL) {
rcu_read_unlock();
return -EINVAL; return -EINVAL;
}
if (addr_type != IPV6_ADDR_ANY) { if (addr_type != IPV6_ADDR_ANY) {
int strict = __ipv6_addr_src_scope(addr_type) <= IPV6_ADDR_SCOPE_LINKLOCAL; int strict = __ipv6_addr_src_scope(addr_type) <= IPV6_ADDR_SCOPE_LINKLOCAL;
...@@ -553,8 +558,7 @@ int datagram_send_ctl(struct net *net, ...@@ -553,8 +558,7 @@ int datagram_send_ctl(struct net *net,
ipv6_addr_copy(&fl->fl6_src, &src_info->ipi6_addr); ipv6_addr_copy(&fl->fl6_src, &src_info->ipi6_addr);
} }
if (dev) rcu_read_unlock();
dev_put(dev);
if (err) if (err)
goto exit_f; goto exit_f;
......
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