From: Eric Dumazet Date: Fri, 4 Feb 2022 20:15:46 +0000 (-0800) Subject: ip6mr: ip6mr_sk_done() can exit early in common cases X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=f2f2325ec79970807012dfc9e716cdbb02d9b574;p=linux.git 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 Signed-off-by: David S. Miller --- diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c index 541cd08871293..8e483e14b5709 100644 --- a/net/ipv6/ip6mr.c +++ b/net/ipv6/ip6mr.c @@ -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)) {