Skip to content

Commit 7bcf45d

Browse files
q2venkuba-moo
authored andcommitted
ipv6: Convert inet6_rtm_deladdr() to per-netns RTNL.
Let's register inet6_rtm_deladdr() with RTNL_FLAG_DOIT_PERNET and hold rtnl_net_lock() before inet6_addr_del(). Now that inet6_addr_del() is always called under per-netns RTNL. Signed-off-by: Kuniyuki Iwashima <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 82a1e6a commit 7bcf45d

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

net/ipv6/addrconf.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3096,7 +3096,7 @@ static int inet6_addr_del(struct net *net, int ifindex, u32 ifa_flags,
30963096
return -ENODEV;
30973097
}
30983098

3099-
idev = __in6_dev_get(dev);
3099+
idev = __in6_dev_get_rtnl_net(dev);
31003100
if (!idev) {
31013101
NL_SET_ERR_MSG_MOD(extack, "IPv6 is disabled on this device");
31023102
return -ENXIO;
@@ -4792,8 +4792,12 @@ inet6_rtm_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh,
47924792
/* We ignore other flags so far. */
47934793
ifa_flags &= IFA_F_MANAGETEMPADDR;
47944794

4795-
return inet6_addr_del(net, ifm->ifa_index, ifa_flags, pfx,
4796-
ifm->ifa_prefixlen, extack);
4795+
rtnl_net_lock(net);
4796+
err = inet6_addr_del(net, ifm->ifa_index, ifa_flags, pfx,
4797+
ifm->ifa_prefixlen, extack);
4798+
rtnl_net_unlock(net);
4799+
4800+
return err;
47974801
}
47984802

47994803
static int modify_prefix_route(struct net *net, struct inet6_ifaddr *ifp,
@@ -7404,7 +7408,7 @@ static const struct rtnl_msg_handler addrconf_rtnl_msg_handlers[] __initconst_or
74047408
{.owner = THIS_MODULE, .protocol = PF_INET6, .msgtype = RTM_NEWADDR,
74057409
.doit = inet6_rtm_newaddr, .flags = RTNL_FLAG_DOIT_PERNET},
74067410
{.owner = THIS_MODULE, .protocol = PF_INET6, .msgtype = RTM_DELADDR,
7407-
.doit = inet6_rtm_deladdr},
7411+
.doit = inet6_rtm_deladdr, .flags = RTNL_FLAG_DOIT_PERNET},
74087412
{.owner = THIS_MODULE, .protocol = PF_INET6, .msgtype = RTM_GETADDR,
74097413
.doit = inet6_rtm_getaddr, .dumpit = inet6_dump_ifaddr,
74107414
.flags = RTNL_FLAG_DOIT_UNLOCKED | RTNL_FLAG_DUMP_UNLOCKED},

0 commit comments

Comments
 (0)