netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH]IPv6: Acquire addrconf_hash_lock for reading instead of writing in addrconf_verify(...)
@ 2005-11-17  2:14 Yan Zheng
  2005-11-18 23:51 ` David S. Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Yan Zheng @ 2005-11-17  2:14 UTC (permalink / raw)
  To: netdev; +Cc: linux-kernel, yoshfuji

Hi.

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: Yan Zheng <yanzheng@21cn.com>

============================================================
--- a/net/ipv6/addrconf.c	2005-11-17 09:27:54.000000000 +0800
+++ b/net/ipv6/addrconf.c	2005-11-17 09:25:42.000000000 +0800
@@ -2627,7 +2627,7 @@ static void addrconf_verify(unsigned lon
 	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
@@ -2649,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) {
@@ -2668,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);
@@ -2686,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);
@@ -2703,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;

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH]IPv6: Acquire addrconf_hash_lock for reading instead of writing in addrconf_verify(...)
  2005-11-17  2:14 [PATCH]IPv6: Acquire addrconf_hash_lock for reading instead of writing in addrconf_verify(...) Yan Zheng
@ 2005-11-18 23:51 ` David S. Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David S. Miller @ 2005-11-18 23:51 UTC (permalink / raw)
  To: yanzheng; +Cc: netdev, linux-kernel, yoshfuji

From: Yan Zheng <yanzheng@21cn.com>
Date: Thu, 17 Nov 2005 10:14:11 +0800

> 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: Yan Zheng <yanzheng@21cn.com>

Applied, thanks Yan.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-11-18 23:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-17  2:14 [PATCH]IPv6: Acquire addrconf_hash_lock for reading instead of writing in addrconf_verify(...) Yan Zheng
2005-11-18 23:51 ` David S. Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).