Skip to content

Commit

Permalink
ipv6: no more dev_put() in datagram_send_ctl()
Browse files Browse the repository at this point in the history
Avoids touching device refcount in datagram_send_ctl(), thanks to RCU

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Nov 2, 2009
1 parent 16ba5e8 commit 536b2e9
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions net/ipv6/datagram.c
Original file line number Diff line number Diff line change
Expand Up @@ -537,12 +537,17 @@ int datagram_send_ctl(struct net *net,

addr_type = __ipv6_addr_type(&src_info->ipi6_addr);

rcu_read_lock();
if (fl->oif) {
dev = dev_get_by_index(net, fl->oif);
if (!dev)
dev = dev_get_by_index_rcu(net, fl->oif);
if (!dev) {
rcu_read_unlock();
return -ENODEV;
} else if (addr_type & IPV6_ADDR_LINKLOCAL)
}
} else if (addr_type & IPV6_ADDR_LINKLOCAL) {
rcu_read_unlock();
return -EINVAL;
}

if (addr_type != IPV6_ADDR_ANY) {
int strict = __ipv6_addr_src_scope(addr_type) <= IPV6_ADDR_SCOPE_LINKLOCAL;
Expand All @@ -553,8 +558,7 @@ int datagram_send_ctl(struct net *net,
ipv6_addr_copy(&fl->fl6_src, &src_info->ipi6_addr);
}

if (dev)
dev_put(dev);
rcu_read_unlock();

if (err)
goto exit_f;
Expand Down

0 comments on commit 536b2e9

Please sign in to comment.