Commit 5d5780df authored by Yan Zheng's avatar Yan Zheng Committed by David S. Miller

[IPV6]: Acquire addrconf_hash_lock for read in addrconf_verify(...)

addrconf_verify(...) only traverse address hash table when
addrconf_hash_lock is held for writing, and it may hold
addrconf_hash_lock for a long time. So I think it's better to acquire
addrconf_hash_lock for reading instead of writing
Signed-off-by: default avatarYan Zheng <yanzheng@21cn.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4909724b
...@@ -2627,7 +2627,7 @@ static void addrconf_verify(unsigned long foo) ...@@ -2627,7 +2627,7 @@ static void addrconf_verify(unsigned long foo)
for (i=0; i < IN6_ADDR_HSIZE; i++) { for (i=0; i < IN6_ADDR_HSIZE; i++) {
restart: restart:
write_lock(&addrconf_hash_lock); read_lock(&addrconf_hash_lock);
for (ifp=inet6_addr_lst[i]; ifp; ifp=ifp->lst_next) { for (ifp=inet6_addr_lst[i]; ifp; ifp=ifp->lst_next) {
unsigned long age; unsigned long age;
#ifdef CONFIG_IPV6_PRIVACY #ifdef CONFIG_IPV6_PRIVACY
...@@ -2649,7 +2649,7 @@ static void addrconf_verify(unsigned long foo) ...@@ -2649,7 +2649,7 @@ static void addrconf_verify(unsigned long foo)
if (age >= ifp->valid_lft) { if (age >= ifp->valid_lft) {
spin_unlock(&ifp->lock); spin_unlock(&ifp->lock);
in6_ifa_hold(ifp); in6_ifa_hold(ifp);
write_unlock(&addrconf_hash_lock); read_unlock(&addrconf_hash_lock);
ipv6_del_addr(ifp); ipv6_del_addr(ifp);
goto restart; goto restart;
} else if (age >= ifp->prefered_lft) { } else if (age >= ifp->prefered_lft) {
...@@ -2668,7 +2668,7 @@ static void addrconf_verify(unsigned long foo) ...@@ -2668,7 +2668,7 @@ static void addrconf_verify(unsigned long foo)
if (deprecate) { if (deprecate) {
in6_ifa_hold(ifp); in6_ifa_hold(ifp);
write_unlock(&addrconf_hash_lock); read_unlock(&addrconf_hash_lock);
ipv6_ifa_notify(0, ifp); ipv6_ifa_notify(0, ifp);
in6_ifa_put(ifp); in6_ifa_put(ifp);
...@@ -2686,7 +2686,7 @@ static void addrconf_verify(unsigned long foo) ...@@ -2686,7 +2686,7 @@ static void addrconf_verify(unsigned long foo)
in6_ifa_hold(ifp); in6_ifa_hold(ifp);
in6_ifa_hold(ifpub); in6_ifa_hold(ifpub);
spin_unlock(&ifp->lock); spin_unlock(&ifp->lock);
write_unlock(&addrconf_hash_lock); read_unlock(&addrconf_hash_lock);
ipv6_create_tempaddr(ifpub, ifp); ipv6_create_tempaddr(ifpub, ifp);
in6_ifa_put(ifpub); in6_ifa_put(ifpub);
in6_ifa_put(ifp); in6_ifa_put(ifp);
...@@ -2703,7 +2703,7 @@ static void addrconf_verify(unsigned long foo) ...@@ -2703,7 +2703,7 @@ static void addrconf_verify(unsigned long foo)
spin_unlock(&ifp->lock); 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; addr_chk_timer.expires = time_before(next, jiffies + HZ) ? jiffies + HZ : next;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment