Skip to content

Commit

Permalink
[IPV6]: Acquire addrconf_hash_lock for read in addrconf_verify(...)
Browse files Browse the repository at this point in the history
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Yan Zheng authored and David S. Miller committed Nov 20, 2005
1 parent 4909724 commit 5d5780d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions net/ipv6/addrconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -2627,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
Expand All @@ -2649,7 +2649,7 @@ static void addrconf_verify(unsigned long foo)
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) {
Expand All @@ -2668,7 +2668,7 @@ static void addrconf_verify(unsigned long foo)

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);
Expand All @@ -2686,7 +2686,7 @@ static void addrconf_verify(unsigned long foo)
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);
Expand All @@ -2703,7 +2703,7 @@ static void addrconf_verify(unsigned long foo)
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;
Expand Down

0 comments on commit 5d5780d

Please sign in to comment.