Skip to content

Commit 02cdd78

Browse files
q2venkuba-moo
authored andcommitted
ipv6: Hold rtnl_net_lock() in addrconf_dad_work().
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 <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 6550ba0 commit 02cdd78

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

net/ipv6/addrconf.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4204,14 +4204,17 @@ static void addrconf_dad_work(struct work_struct *w)
42044204
struct inet6_dev *idev = ifp->idev;
42054205
bool bump_id, disable_ipv6 = false;
42064206
struct in6_addr mcaddr;
4207+
struct net *net;
42074208

42084209
enum {
42094210
DAD_PROCESS,
42104211
DAD_BEGIN,
42114212
DAD_ABORT,
42124213
} action = DAD_PROCESS;
42134214

4214-
rtnl_lock();
4215+
net = dev_net(idev->dev);
4216+
4217+
rtnl_net_lock(net);
42154218

42164219
spin_lock_bh(&ifp->lock);
42174220
if (ifp->state == INET6_IFADDR_STATE_PREDAD) {
@@ -4221,7 +4224,7 @@ static void addrconf_dad_work(struct work_struct *w)
42214224
action = DAD_ABORT;
42224225
ifp->state = INET6_IFADDR_STATE_POSTDAD;
42234226

4224-
if ((READ_ONCE(dev_net(idev->dev)->ipv6.devconf_all->accept_dad) > 1 ||
4227+
if ((READ_ONCE(net->ipv6.devconf_all->accept_dad) > 1 ||
42254228
READ_ONCE(idev->cnf.accept_dad) > 1) &&
42264229
!idev->cnf.disable_ipv6 &&
42274230
!(ifp->flags & IFA_F_STABLE_PRIVACY)) {
@@ -4303,7 +4306,7 @@ static void addrconf_dad_work(struct work_struct *w)
43034306
ifp->dad_nonce);
43044307
out:
43054308
in6_ifa_put(ifp);
4306-
rtnl_unlock();
4309+
rtnl_net_unlock(net);
43074310
}
43084311

43094312
/* ifp->idev must be at least read locked */

0 commit comments

Comments
 (0)