Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net/ipv6: Allow onlink routes to have a device mismatch if it is the default route

The intent of ip6_route_check_nh_onlink is to make sure the gateway
given for an onlink route is not actually on a connected route for
a different interface (e.g., 2001:db8:1::/64 is on dev eth1 and then
an onlink route has a via 2001:db8:1::1 dev eth2). If the gateway
lookup hits the default route then it most likely will be a different
interface than the onlink route which is ok.

Update ip6_route_check_nh_onlink to disregard the device mismatch
if the gateway lookup hits the default route. Turns out the existing
onlink tests are passing because there is no default route or it is
an unreachable default, so update the onlink tests to have a default
route other than unreachable.

Fixes: fc1e64e1092f6 ("net/ipv6: Add support for onlink flag")
Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

David Ahern and committed by
David S. Miller
4ed591c8 e72bde6b

+9 -7
+2
net/ipv6/route.c
··· 2745 2745 grt = ip6_nh_lookup_table(net, cfg, gw_addr, tbid, 0); 2746 2746 if (grt) { 2747 2747 if (!grt->dst.error && 2748 + /* ignore match if it is the default route */ 2749 + grt->from && !ipv6_addr_any(&grt->from->fib6_dst.addr) && 2748 2750 (grt->rt6i_flags & flags || dev != grt->dst.dev)) { 2749 2751 NL_SET_ERR_MSG(extack, 2750 2752 "Nexthop has invalid gateway or device mismatch");