Skip to contentSkip to conversation

ndisc: Refer/Update neigh->updated with write lock.

PATCH In review YOSHIFUJI Hideaki 2 participants 3 messages Jan 15, 2013 – Jan 16, 2013

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

PATCH 1/13 ndisc: Refer/Update neigh->updated with write lock.

---
 net/ipv6/route.c |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
net/ipv6/route.c +8 -4
index 7c34c01..1341f68 100644
@@ -499,22 +499,26 @@ static void rt6_probe(struct rt6_info *rt)
 	 * to no more than one per minute.
 	 */
 	neigh = rt ? rt->n : NULL;
-	if (!neigh || (neigh->nud_state & NUD_VALID))
+	if (!neigh)
+		return;
+	write_lock_bh(&neigh->lock);
+	if (neigh->nud_state & NUD_VALID) {
+		write_unlock_bh(&neigh->lock);
 		return;
-	read_lock_bh(&neigh->lock);
+	}
 	if (!(neigh->nud_state & NUD_VALID) &&
 	    time_after(jiffies, neigh->updated + rt->rt6i_idev->cnf.rtr_probe_interval)) {
 		struct in6_addr mcaddr;
 		struct in6_addr *target;
 
 		neigh->updated = jiffies;
-		read_unlock_bh(&neigh->lock);
+		write_unlock_bh(&neigh->lock);
 
 		target = (struct in6_addr *)&neigh->primary_key;
 		addrconf_addr_solict_mult(target, &mcaddr);
 		ndisc_send_ns(rt->dst.dev, NULL, target, &mcaddr, NULL);
 	} else {
-		read_unlock_bh(&neigh->lock);
+		write_unlock_bh(&neigh->lock);
 	}
 }
 #else
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 20 lines · YOSHIFUJI Hideaki
---
  net/ipv6/route.c |   12 ++++++++----
  1 file changed, 8 insertions(+), 4 deletions(-)
net/ipv6/route.c +5 -1
index 7c34c01..1341f68 100644
@@ -499,22 +499,26 @@ static void rt6_probe(struct rt6_info *rt)
  	 * to no more than one per minute.
  	 */
  	neigh = rt ? rt->n : NULL;
-	if (!neigh || (neigh->nud_state & NUD_VALID))
+	if (!neigh)
+		return;
+	write_lock_bh(&neigh->lock);
+	if (neigh->nud_state & NUD_VALID) {
+		write_unlock_bh(&neigh->lock);
  		return;

net/ipv6/route.c static void rt6_probe(struct rt6_info *rt) · line 515

Quoted 10 lines
net/ipv6/route.c +2 -2
-	read_lock_bh(&neigh->lock);
+	}
  	if (!(neigh->nud_state & NUD_VALID) &&
  	    time_after(jiffies, neigh->updated + rt->rt6i_idev->cnf.rtr_probe_interval)) {
  		struct in6_addr mcaddr;
  		struct in6_addr *target;
 
  		neigh->updated = jiffies;
-		read_unlock_bh(&neigh->lock);
+		write_unlock_bh(&neigh->lock);

This looks like a bug fix, which deserves a separated patch rather than in this rt->n removal series.

#2 lore raw
Quoted 28 lines · Cong Wang
Quoted 27 lines · YOSHIFUJI Hideaki
---
  net/ipv6/route.c |   12 ++++++++----
  1 file changed, 8 insertions(+), 4 deletions(-)
net/ipv6/route.c +6 -2
index 7c34c01..1341f68 100644
@@ -499,22 +499,26 @@ static void rt6_probe(struct rt6_info *rt)
  	 * to no more than one per minute.
  	 */
  	neigh = rt ? rt->n : NULL;
-	if (!neigh || (neigh->nud_state & NUD_VALID))
+	if (!neigh)
+		return;
+	write_lock_bh(&neigh->lock);
+	if (neigh->nud_state & NUD_VALID) {
+		write_unlock_bh(&neigh->lock);
  		return;
-	read_lock_bh(&neigh->lock);
+	}
  	if (!(neigh->nud_state & NUD_VALID) &&
  	    time_after(jiffies, neigh->updated + rt->rt6i_idev->cnf.rtr_probe_interval)) {
  		struct in6_addr mcaddr;
  		struct in6_addr *target;
 
Quoted 6 lines

net/ipv6/route.c static void rt6_probe(struct rt6_info *rt) · line 515

Quoted 3 lines
net/ipv6/route.c +1 -1
  		neigh->updated = jiffies;
-		read_unlock_bh(&neigh->lock);
+		write_unlock_bh(&neigh->lock);

This looks like a bug fix, which deserves a separated patch rather than in this rt->n removal series.

Because the series depends on this, it is included here so far.

--yoshfuji