public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail•com>
To: "David S . Miller" <davem@davemloft•net>,
	Jakub Kicinski <kuba@kernel•org>
Cc: netdev <netdev@vger•kernel.org>, David Ahern <dsahern@kernel•org>,
	Eric Dumazet <edumazet@google•com>,
	Eric Dumazet <eric.dumazet@gmail•com>
Subject: [PATCH net-next 2/2] ip6mr: ip6mr_sk_done() can exit early in common cases
Date: Fri,  4 Feb 2022 12:15:46 -0800	[thread overview]
Message-ID: <20220204201546.2703267-3-eric.dumazet@gmail.com> (raw)
In-Reply-To: <20220204201546.2703267-1-eric.dumazet@gmail.com>

From: Eric Dumazet <edumazet@google•com>

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>
---
 net/ipv6/ip6mr.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
index 541cd08871293eb5702e47e0645ea16394621e97..8e483e14b5709b1b8a6e9dfd6616a5bde5c273ee 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)) {
-- 
2.35.0.263.gb82422642f-goog


  parent reply	other threads:[~2022-02-04 20:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-04 20:15 [PATCH net-next 0/2] ipv6: mc_forwarding changes Eric Dumazet
2022-02-04 20:15 ` [PATCH net-next 1/2] ipv6: make mc_forwarding atomic Eric Dumazet
2022-02-04 20:15 ` Eric Dumazet [this message]
2022-02-05 15:40 ` [PATCH net-next 0/2] ipv6: mc_forwarding changes patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220204201546.2703267-3-eric.dumazet@gmail.com \
    --to=eric.dumazet@gmail$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=dsahern@kernel$(echo .)org \
    --cc=edumazet@google$(echo .)com \
    --cc=kuba@kernel$(echo .)org \
    --cc=netdev@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox