]> git.karo-electronics.de Git - linux-beck.git/blobdiff - net/ipv6/addrconf.c
[IPV6]: Acquire addrconf_hash_lock for read in addrconf_verify(...)
[linux-beck.git] / net / ipv6 / addrconf.c
index b7a5f51238b3958f88bc18adfac17704d3aa0bf7..a16064ba0caf2bee3bcc87ffa111811d44927d60 100644 (file)
@@ -1022,6 +1022,7 @@ int ipv6_dev_get_saddr(struct net_device *daddr_dev,
                                        continue;
                        }
 
+#ifdef CONFIG_IPV6_PRIVACY
                        /* Rule 7: Prefer public address
                         * Note: prefer temprary address if use_tempaddr >= 2
                         */
@@ -1042,11 +1043,12 @@ int ipv6_dev_get_saddr(struct net_device *daddr_dev,
                                if (hiscore.attrs & IPV6_SADDR_SCORE_PRIVACY)
                                        continue;
                        }
-
+#endif
                        /* Rule 8: Use longest matching prefix */
-                       if (hiscore.rule < 8)
+                       if (hiscore.rule < 8) {
                                hiscore.matchlen = ipv6_addr_diff(&ifa_result->addr, daddr);
-                       score.rule++;
+                               hiscore.rule++;
+                       }
                        score.matchlen = ipv6_addr_diff(&ifa->addr, daddr);
                        if (score.matchlen > hiscore.matchlen) {
                                score.rule = 8;
@@ -2625,7 +2627,7 @@ static void addrconf_verify(unsigned long foo)
        for (i=0; i < IN6_ADDR_HSIZE; i++) {
 
 restart:
-               write_lock(&addrconf_hash_lock);
+               read_lock(&addrconf_hash_lock);
                for (ifp=inet6_addr_lst[i]; ifp; ifp=ifp->lst_next) {
                        unsigned long age;
 #ifdef CONFIG_IPV6_PRIVACY
@@ -2647,7 +2649,7 @@ restart:
                        if (age >= ifp->valid_lft) {
                                spin_unlock(&ifp->lock);
                                in6_ifa_hold(ifp);
-                               write_unlock(&addrconf_hash_lock);
+                               read_unlock(&addrconf_hash_lock);
                                ipv6_del_addr(ifp);
                                goto restart;
                        } else if (age >= ifp->prefered_lft) {
@@ -2666,7 +2668,7 @@ restart:
 
                                if (deprecate) {
                                        in6_ifa_hold(ifp);
-                                       write_unlock(&addrconf_hash_lock);
+                                       read_unlock(&addrconf_hash_lock);
 
                                        ipv6_ifa_notify(0, ifp);
                                        in6_ifa_put(ifp);
@@ -2684,7 +2686,7 @@ restart:
                                                in6_ifa_hold(ifp);
                                                in6_ifa_hold(ifpub);
                                                spin_unlock(&ifp->lock);
-                                               write_unlock(&addrconf_hash_lock);
+                                               read_unlock(&addrconf_hash_lock);
                                                ipv6_create_tempaddr(ifpub, ifp);
                                                in6_ifa_put(ifpub);
                                                in6_ifa_put(ifp);
@@ -2701,7 +2703,7 @@ restart:
                                spin_unlock(&ifp->lock);
                        }
                }
-               write_unlock(&addrconf_hash_lock);
+               read_unlock(&addrconf_hash_lock);
        }
 
        addr_chk_timer.expires = time_before(next, jiffies + HZ) ? jiffies + HZ : next;