]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - net/ipv6/addrconf.c
ipv6: fix the bug of address check
[net-next-2.6.git] / net / ipv6 / addrconf.c
index 3984f52181f45018bca0bdf71af8a913a2adfca6..75d3b8c1e85674760fe539b529b810d460c7ea4b 100644 (file)
@@ -1274,7 +1274,7 @@ static int ipv6_count_addresses(struct inet6_dev *idev)
 int ipv6_chk_addr(struct net *net, struct in6_addr *addr,
                  struct net_device *dev, int strict)
 {
-       struct inet6_ifaddr *ifp = NULL;
+       struct inet6_ifaddr *ifp;
        struct hlist_node *node;
        unsigned int hash = ipv6_addr_hash(addr);
 
@@ -1283,15 +1283,16 @@ int ipv6_chk_addr(struct net *net, struct in6_addr *addr,
                if (!net_eq(dev_net(ifp->idev->dev), net))
                        continue;
                if (ipv6_addr_equal(&ifp->addr, addr) &&
-                   !(ifp->flags&IFA_F_TENTATIVE)) {
-                       if (dev == NULL || ifp->idev->dev == dev ||
-                           !(ifp->scope&(IFA_LINK|IFA_HOST) || strict))
-                               break;
+                   !(ifp->flags&IFA_F_TENTATIVE) &&
+                   (dev == NULL || ifp->idev->dev == dev ||
+                    !(ifp->scope&(IFA_LINK|IFA_HOST) || strict))) {
+                       rcu_read_unlock_bh();
+                       return 1;
                }
        }
-       rcu_read_unlock_bh();
 
-       return ifp != NULL;
+       rcu_read_unlock_bh();
+       return 0;
 }
 EXPORT_SYMBOL(ipv6_chk_addr);