netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kuniyuki Iwashima <kuniyu@amazon.com>
To: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	David Ahern <dsahern@kernel.org>
Cc: Simon Horman <horms@kernel.org>,
	Kuniyuki Iwashima <kuniyu@amazon.com>,
	Kuniyuki Iwashima <kuni1840@gmail.com>, <netdev@vger.kernel.org>
Subject: [PATCH v2 net-next 04/11] ipv6: Hold rtnl_net_lock() in addrconf_dad_work().
Date: Wed, 15 Jan 2025 17:06:01 +0900	[thread overview]
Message-ID: <20250115080608.28127-5-kuniyu@amazon.com> (raw)
In-Reply-To: <20250115080608.28127-1-kuniyu@amazon.com>

addrconf_dad_work() is per-address work and holds RTNL internally.

We can fetch netns as dev_net(ifp->idev->dev).

Let's use rtnl_net_lock().

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
---
 net/ipv6/addrconf.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index fe85cb2d49c8..e297cd6f9fd2 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -4204,6 +4204,7 @@ static void addrconf_dad_work(struct work_struct *w)
 	struct inet6_dev *idev = ifp->idev;
 	bool bump_id, disable_ipv6 = false;
 	struct in6_addr mcaddr;
+	struct net *net;
 
 	enum {
 		DAD_PROCESS,
@@ -4211,7 +4212,9 @@ static void addrconf_dad_work(struct work_struct *w)
 		DAD_ABORT,
 	} action = DAD_PROCESS;
 
-	rtnl_lock();
+	net = dev_net(idev->dev);
+
+	rtnl_net_lock(net);
 
 	spin_lock_bh(&ifp->lock);
 	if (ifp->state == INET6_IFADDR_STATE_PREDAD) {
@@ -4221,7 +4224,7 @@ static void addrconf_dad_work(struct work_struct *w)
 		action = DAD_ABORT;
 		ifp->state = INET6_IFADDR_STATE_POSTDAD;
 
-		if ((READ_ONCE(dev_net(idev->dev)->ipv6.devconf_all->accept_dad) > 1 ||
+		if ((READ_ONCE(net->ipv6.devconf_all->accept_dad) > 1 ||
 		     READ_ONCE(idev->cnf.accept_dad) > 1) &&
 		    !idev->cnf.disable_ipv6 &&
 		    !(ifp->flags & IFA_F_STABLE_PRIVACY)) {
@@ -4303,7 +4306,7 @@ static void addrconf_dad_work(struct work_struct *w)
 		      ifp->dad_nonce);
 out:
 	in6_ifa_put(ifp);
-	rtnl_unlock();
+	rtnl_net_unlock(net);
 }
 
 /* ifp->idev must be at least read locked */
-- 
2.39.5 (Apple Git-154)


  parent reply	other threads:[~2025-01-15  8:08 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-15  8:05 [PATCH v2 net-next 00/11] ipv6: Convert RTM_{NEW,DEL}ADDR and more to per-netns RTNL Kuniyuki Iwashima
2025-01-15  8:05 ` [PATCH v2 net-next 01/11] ipv6: Add __in6_dev_get_rtnl_net() Kuniyuki Iwashima
2025-01-15  8:05 ` [PATCH v2 net-next 02/11] ipv6: Convert net.ipv6.conf.${DEV}.XXX sysctl to per-netns RTNL Kuniyuki Iwashima
2025-01-15  8:06 ` [PATCH v2 net-next 03/11] ipv6: Hold rtnl_net_lock() in addrconf_verify_work() Kuniyuki Iwashima
2025-01-15  8:06 ` Kuniyuki Iwashima [this message]
2025-01-15  8:06 ` [PATCH v2 net-next 05/11] ipv6: Hold rtnl_net_lock() in addrconf_init() and addrconf_cleanup() Kuniyuki Iwashima
2025-01-15  8:06 ` [PATCH v2 net-next 06/11] ipv6: Convert inet6_ioctl() to per-netns RTNL Kuniyuki Iwashima
2025-01-15  8:06 ` [PATCH v2 net-next 07/11] ipv6: Pass dev to inet6_addr_add() Kuniyuki Iwashima
2025-01-15  8:06 ` [PATCH v2 net-next 08/11] ipv6: Set cfg.ifa_flags before device lookup in inet6_rtm_newaddr() Kuniyuki Iwashima
2025-01-15  8:06 ` [PATCH v2 net-next 09/11] ipv6: Move lifetime validation to inet6_rtm_newaddr() Kuniyuki Iwashima
2025-01-20 20:29   ` Jakub Kicinski
2025-01-20 21:13     ` Kuniyuki Iwashima
2025-01-20 22:38       ` Jakub Kicinski
2025-01-15  8:06 ` [PATCH v2 net-next 10/11] ipv6: Convert inet6_rtm_newaddr() to per-netns RTNL Kuniyuki Iwashima
2025-01-15  8:06 ` [PATCH v2 net-next 11/11] ipv6: Convert inet6_rtm_deladdr() " Kuniyuki Iwashima
2025-01-20 22:40 ` [PATCH v2 net-next 00/11] ipv6: Convert RTM_{NEW,DEL}ADDR and more " 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=20250115080608.28127-5-kuniyu@amazon.com \
    --to=kuniyu@amazon.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kuni1840@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).