Skip to content

Commit 145a362

Browse files
yoshfujidavem330
authored andcommitted
ipv6: Do not depend on rt->n in rt6_check_neigh().
CC: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent c440f16 commit 145a362

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

net/ipv6/route.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -546,20 +546,24 @@ static inline bool rt6_check_neigh(struct rt6_info *rt)
546546
struct neighbour *neigh;
547547
bool ret = false;
548548

549-
neigh = rt->n;
550549
if (rt->rt6i_flags & RTF_NONEXTHOP ||
551550
!(rt->rt6i_flags & RTF_GATEWAY))
552-
ret = true;
553-
else if (neigh) {
554-
read_lock_bh(&neigh->lock);
551+
return true;
552+
553+
rcu_read_lock_bh();
554+
neigh = __ipv6_neigh_lookup_noref(rt->dst.dev, &rt->rt6i_gateway);
555+
if (neigh) {
556+
read_lock(&neigh->lock);
555557
if (neigh->nud_state & NUD_VALID)
556558
ret = true;
557559
#ifdef CONFIG_IPV6_ROUTER_PREF
558560
else if (!(neigh->nud_state & NUD_FAILED))
559561
ret = true;
560562
#endif
561-
read_unlock_bh(&neigh->lock);
563+
read_unlock(&neigh->lock);
562564
}
565+
rcu_read_unlock_bh();
566+
563567
return ret;
564568
}
565569

0 commit comments

Comments
 (0)