Skip to contentSkip to conversation

ipv6: Do not depend on rt->n in rt6_check_neigh().

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

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

PATCH 9/13 ipv6: Do not depend on rt->n in rt6_check_neigh().

---
 net/ipv6/route.c |   15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
net/ipv6/route.c +10 -5
index e16a483..ffdc8a6 100644
@@ -552,20 +552,25 @@ static inline bool rt6_check_neigh(struct rt6_info *rt)
 	struct neighbour *neigh;
 	bool ret = false;
 
-	neigh = rt->n;
 	if (rt->rt6i_flags & RTF_NONEXTHOP ||
-	    !(rt->rt6i_flags & RTF_GATEWAY))
+	    !(rt->rt6i_flags & RTF_GATEWAY)) {
 		ret = true;
-	else if (neigh) {
-		read_lock_bh(&neigh->lock);
+		goto out;
+	}
+	rcu_read_lock_bh();
+	neigh = __ipv6_neigh_lookup_noref(rt->dst.dev, &rt->rt6i_gateway);
+	if (neigh) {
+		read_lock(&neigh->lock);
 		if (neigh->nud_state & NUD_VALID)
 			ret = true;
 #ifdef CONFIG_IPV6_ROUTER_PREF
 		else if (!(neigh->nud_state & NUD_FAILED))
 			ret = true;
 #endif
-		read_unlock_bh(&neigh->lock);
+		read_unlock(&neigh->lock);
 	}
+	rcu_read_unlock_bh();
+out:
 	return ret;
 }
 
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 12 lines · YOSHIFUJI Hideaki
---
  net/ipv6/route.c |   15 ++++++++++-----
  1 file changed, 10 insertions(+), 5 deletions(-)
net/ipv6/route.c +0 -0
index e16a483..ffdc8a6 100644
@@ -552,20 +552,25 @@ static inline bool rt6_check_neigh(struct rt6_info *rt)
  	struct neighbour *neigh;
  	bool ret = false;

net/ipv6/route.c static inline bool rt6_check_neigh(struct rt6_info *rt) · line 559

Quoted 10 lines
net/ipv6/route.c +3 -4
 
-	neigh = rt->n;
  	if (rt->rt6i_flags & RTF_NONEXTHOP ||
-	    !(rt->rt6i_flags & RTF_GATEWAY))
+	    !(rt->rt6i_flags & RTF_GATEWAY)) {
  		ret = true;
-	else if (neigh) {
-		read_lock_bh(&neigh->lock);
+		goto out;
+	}

Just return true here...