@@ -5032,12 +5032,6 @@ inet6_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh,
cfg.preferred_lft = ci->ifa_prefered;
}
- dev = __dev_get_by_index(net, ifm->ifa_index);
- if (!dev) {
- NL_SET_ERR_MSG_MOD(extack, "Unable to find the interface");
- return -ENODEV;
- }
-
cfg.ifa_flags = nla_get_u32_default(tb[IFA_FLAGS], ifm->ifa_flags);
/* We ignore other flags so far. */
@@ -5045,6 +5039,12 @@ inet6_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh,
IFA_F_MANAGETEMPADDR | IFA_F_NOPREFIXROUTE |
IFA_F_MCAUTOJOIN | IFA_F_OPTIMISTIC;
+ dev = __dev_get_by_index(net, ifm->ifa_index);
+ if (!dev) {
+ NL_SET_ERR_MSG_MOD(extack, "Unable to find the interface");
+ return -ENODEV;
+ }
+
idev = ipv6_find_idev(dev);
if (IS_ERR(idev))
return PTR_ERR(idev);
We will convert inet6_rtm_newaddr() to per-netns RTNL. Except for IFA_F_OPTIMISTIC, cfg.ifa_flags can be set before __dev_get_by_index(). Let's move __dev_get_by_index() down so that we can set ifa_flags without RTNL. Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com> --- net/ipv6/addrconf.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)