ip6mr: ip6mr_sk_done() can exit early in common cases

In many cases, ip6mr_sk_done() is called while no ipmr socket
has been registered.

This removes 4 rtnl acquisitions per netns dismantle,
with following callers:

igmp6_net_exit(), tcpv6_net_exit(), ndisc_net_exit()

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Eric Dumazet 2022-02-04 12:15:46 -08:00 committed by David S. Miller
parent 145c7a7938
commit f2f2325ec7
1 changed files with 3 additions and 0 deletions

View File

@ -1575,6 +1575,9 @@ int ip6mr_sk_done(struct sock *sk)
inet_sk(sk)->inet_num != IPPROTO_ICMPV6)
return err;
if (!atomic_read(&net->ipv6.devconf_all->mc_forwarding))
return err;
rtnl_lock();
ip6mr_for_each_table(mrt, net) {
if (sk == rtnl_dereference(mrt->mroute_sk)) {