Commit 9e917dca authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

net: avoid a dev refcount in ip_mc_find_dev()

We hold RTNL in ip_mc_find_dev(), no need to touch device refcount.
Signed-off-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5d6076bb
...@@ -153,7 +153,7 @@ static void fib_flush(struct net *net) ...@@ -153,7 +153,7 @@ static void fib_flush(struct net *net)
* @addr: the source address * @addr: the source address
* @devref: if true, take a reference on the found device * @devref: if true, take a reference on the found device
* *
* If a caller uses devref=false, it should be protected by RCU * If a caller uses devref=false, it should be protected by RCU, or RTNL
*/ */
struct net_device *__ip_dev_find(struct net *net, __be32 addr, bool devref) struct net_device *__ip_dev_find(struct net *net, __be32 addr, bool devref)
{ {
......
...@@ -1418,6 +1418,7 @@ void ip_mc_destroy_dev(struct in_device *in_dev) ...@@ -1418,6 +1418,7 @@ void ip_mc_destroy_dev(struct in_device *in_dev)
write_unlock_bh(&in_dev->mc_list_lock); write_unlock_bh(&in_dev->mc_list_lock);
} }
/* RTNL is locked */
static struct in_device *ip_mc_find_dev(struct net *net, struct ip_mreqn *imr) static struct in_device *ip_mc_find_dev(struct net *net, struct ip_mreqn *imr)
{ {
struct flowi fl = { .nl_u = { .ip4_u = struct flowi fl = { .nl_u = { .ip4_u =
...@@ -1433,10 +1434,9 @@ static struct in_device *ip_mc_find_dev(struct net *net, struct ip_mreqn *imr) ...@@ -1433,10 +1434,9 @@ static struct in_device *ip_mc_find_dev(struct net *net, struct ip_mreqn *imr)
return idev; return idev;
} }
if (imr->imr_address.s_addr) { if (imr->imr_address.s_addr) {
dev = ip_dev_find(net, imr->imr_address.s_addr); dev = __ip_dev_find(net, imr->imr_address.s_addr, false);
if (!dev) if (!dev)
return NULL; return NULL;
dev_put(dev);
} }
if (!dev && !ip_route_output_key(net, &rt, &fl)) { if (!dev && !ip_route_output_key(net, &rt, &fl)) {
......
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