Skip to contentSkip to conversation

ipv6: replace write lock with read lock in addrconf_permanent_addr

PATCH In review [email protected] 2 participants 3 messages Mar 14, 2016 – Mar 15, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipv6: replace write lock with read lock in addrconf_permanent_addr

From: Li RongQing <[email protected]>

nothing of idev is changed, so read lock is enough

---
 net/ipv6/addrconf.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
net/ipv6/addrconf.c +4 -4
index 8c0dab2..d3f0d87 100644
@@ -3228,21 +3228,21 @@ static void addrconf_permanent_addr(struct net_device *dev)
 	if (!idev)
 		return;
 
-	write_lock_bh(&idev->lock);
+	read_lock_bh(&idev->lock);
 
 	list_for_each_entry_safe(ifp, tmp, &idev->addr_list, if_list) {
 		if ((ifp->flags & IFA_F_PERMANENT) &&
 		    fixup_permanent_addr(idev, ifp) < 0) {
-			write_unlock_bh(&idev->lock);
+			read_unlock_bh(&idev->lock);
 			ipv6_del_addr(ifp);
-			write_lock_bh(&idev->lock);
+			read_lock_bh(&idev->lock);
 
 			net_info_ratelimited("%s: Failed to add prefix route for address %pI6c; dropping\n",
 					     idev->dev->name, &ifp->addr);
 		}
 	}
 
-	write_unlock_bh(&idev->lock);
+	read_unlock_bh(&idev->lock);
 }
 
 static int addrconf_notify(struct notifier_block *this, unsigned long event,
Signature · 1 line
2.1.4
#2 lore raw
Quoted 2 lines · David Miller

We need it for the modifications made by fixup_permanent_addr().

fixup_permanent_addr should be protected by ifp->lock, not by idev->lock write lock, since ifp is modified,

-Roy