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

Commit b0a1ba59 authored by Martin KaFai Lau's avatar Martin KaFai Lau Committed by David S. Miller
Browse files

ipv6: Fix __ip6_route_redirect



In my last commit (a3c00e46: ipv6: Remove BACKTRACK macro), the changes in
__ip6_route_redirect is incorrect.  The following case is missed:
1. The for loop tries to find a valid gateway rt. If it fails to find
   one, rt will be NULL.
2. When rt is NULL, it is set to the ip6_null_entry.
3. The newly added 'else if', from a3c00e46, will stop the backtrack from
   happening.

Signed-off-by: default avatarMartin KaFai Lau <kafai@fb.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 24df8986
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -1242,12 +1242,16 @@ static struct rt6_info *__ip6_route_redirect(struct net *net,
		rt = net->ipv6.ip6_null_entry;
	else if (rt->dst.error) {
		rt = net->ipv6.ip6_null_entry;
	} else if (rt == net->ipv6.ip6_null_entry) {
		goto out;
	}

	if (rt == net->ipv6.ip6_null_entry) {
		fn = fib6_backtrack(fn, &fl6->saddr);
		if (fn)
			goto restart;
	}

out:
	dst_hold(&rt->dst);

	read_unlock_bh(&table->tb6_lock);