ipv6: addrconf: don't use rtnl mutex in RTM_GETADDR
authorFlorian Westphal <fw@strlen.de>
Wed, 11 Oct 2017 08:28:01 +0000 (10:28 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 12 Oct 2017 03:17:03 +0000 (20:17 -0700)
Similar to the previous patch, use the device lookup functions
that bump device refcount and flag this as DOIT_UNLOCKED to avoid
rtnl mutex.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv6/addrconf.c

index 5207f56..4603aa4 100644 (file)
@@ -4890,17 +4890,15 @@ static int inet6_rtm_getaddr(struct sk_buff *in_skb, struct nlmsghdr *nlh,
        err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFA_MAX, ifa_ipv6_policy,
                          extack);
        if (err < 0)
-               goto errout;
+               return err;
 
        addr = extract_addr(tb[IFA_ADDRESS], tb[IFA_LOCAL], &peer);
-       if (!addr) {
-               err = -EINVAL;
-               goto errout;
-       }
+       if (!addr)
+               return -EINVAL;
 
        ifm = nlmsg_data(nlh);
        if (ifm->ifa_index)
-               dev = __dev_get_by_index(net, ifm->ifa_index);
+               dev = dev_get_by_index(net, ifm->ifa_index);
 
        ifa = ipv6_get_ifaddr(net, addr, dev, 1);
        if (!ifa) {
@@ -4926,6 +4924,8 @@ static int inet6_rtm_getaddr(struct sk_buff *in_skb, struct nlmsghdr *nlh,
 errout_ifa:
        in6_ifa_put(ifa);
 errout:
+       if (dev)
+               dev_put(dev);
        return err;
 }
 
@@ -6568,7 +6568,7 @@ int __init addrconf_init(void)
        __rtnl_register(PF_INET6, RTM_NEWADDR, inet6_rtm_newaddr, NULL, 0);
        __rtnl_register(PF_INET6, RTM_DELADDR, inet6_rtm_deladdr, NULL, 0);
        __rtnl_register(PF_INET6, RTM_GETADDR, inet6_rtm_getaddr,
-                       inet6_dump_ifaddr, 0);
+                       inet6_dump_ifaddr, RTNL_FLAG_DOIT_UNLOCKED);
        __rtnl_register(PF_INET6, RTM_GETMULTICAST, NULL,
                        inet6_dump_ifmcaddr, 0);
        __rtnl_register(PF_INET6, RTM_GETANYCAST, NULL,