Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 145a3621 authored by YOSHIFUJI Hideaki / 吉藤英明's avatar YOSHIFUJI Hideaki / 吉藤英明 Committed by David S. Miller
Browse files

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



CC: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: default avatarYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c440f160
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -546,20 +546,24 @@ 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))
		ret = true;
	else if (neigh) {
		read_lock_bh(&neigh->lock);
		return true;

	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();

	return ret;
}