Skip to contentSkip to conversation

ipv6: Do not deoend on rt->n in ip6_dst_lookup_tail().

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 8/13 ipv6: Do not deoend on rt->n in ip6_dst_lookup_tail().

---
 net/ipv6/ip6_output.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
net/ipv6/ip6_output.c +6 -2
index 9fc5d1d..b2fe048 100644
@@ -921,8 +921,12 @@ static int ip6_dst_lookup_tail(struct sock *sk,
 	 * dst entry of the nexthop router
 	 */
 	rt = (struct rt6_info *) *dst;
-	n = rt->n;
-	if (n && !(n->nud_state & NUD_VALID)) {
+	rcu_read_lock_bh();
+	n = __ipv6_neigh_lookup_noref(rt->dst.dev, rt6_nexthop(rt, &fl6->daddr));
+	err = n && !(n->nud_state & NUD_VALID) ? -EINVAL : 0;
+	rcu_read_unlock_bh();
+
+	if (err) {
 		struct inet6_ifaddr *ifp;
 		struct flowi6 fl_gw6;
 		int redirect;
Signature · 1 line
1.7.9.5
#1 lore raw

s/deoend/depend/ in $subject...

Quoted 11 lines · YOSHIFUJI Hideaki
---
  net/ipv6/ip6_output.c |    8 ++++++--
  1 file changed, 6 insertions(+), 2 deletions(-)
net/ipv6/ip6_output.c +0 -0
index 9fc5d1d..b2fe048 100644
@@ -921,8 +921,12 @@ static int ip6_dst_lookup_tail(struct sock *sk,
  	 * dst entry of the nexthop router

net/ipv6/ip6_output.c static int ip6_dst_lookup_tail(struct sock *sk, · line 929

Quoted 10 lines
net/ipv6/ip6_output.c +6 -2
  	 */
  	rt = (struct rt6_info *) *dst;
-	n = rt->n;
-	if (n && !(n->nud_state & NUD_VALID)) {
+	rcu_read_lock_bh();
+	n = __ipv6_neigh_lookup_noref(rt->dst.dev, rt6_nexthop(rt, &fl6->daddr));
+	err = n && !(n->nud_state & NUD_VALID) ? -EINVAL : 0;
+	rcu_read_unlock_bh();
+
+	if (err) {

Are you sure the logic here equals?

In the original code, we could return 0 even we enter this if branch, but after your patch, it seems it will return -EINVAL?

#2 lore raw
Quoted 27 lines · Cong Wang

s/deoend/depend/ in $subject...

Quoted 11 lines · YOSHIFUJI Hideaki
---
  net/ipv6/ip6_output.c |    8 ++++++--
  1 file changed, 6 insertions(+), 2 deletions(-)
net/ipv6/ip6_output.c +0 -0
index 9fc5d1d..b2fe048 100644
@@ -921,8 +921,12 @@ static int ip6_dst_lookup_tail(struct sock *sk,
  	 * dst entry of the nexthop router

net/ipv6/ip6_output.c static int ip6_dst_lookup_tail(struct sock *sk, · line 929

Quoted 10 lines
net/ipv6/ip6_output.c +6 -2
  	 */
  	rt = (struct rt6_info *) *dst;
-	n = rt->n;
-	if (n && !(n->nud_state & NUD_VALID)) {
+	rcu_read_lock_bh();
+	n = __ipv6_neigh_lookup_noref(rt->dst.dev, rt6_nexthop(rt, &fl6->daddr));
+	err = n && !(n->nud_state & NUD_VALID) ? -EINVAL : 0;
+	rcu_read_unlock_bh();
+
+	if (err) {

Are you sure the logic here equals?

Quoted 3 lines

In the original code, we could return 0 even we enter this if branch, but after your patch, it seems it will return -EINVAL?

err is always updated after the branch, or return 0;

--yoshfuji