Skip to content

Commit 44750f8

Browse files
dsaherndavem330
authored andcommitted
net/ipv6: onlink nexthop checks should default to main table
Because of differences in how ipv4 and ipv6 handle fib lookups, verification of nexthops with onlink flag need to default to the main table rather than the local table used by IPv4. As it stands an address within a connected route on device 1 can be used with onlink on device 2. Updating the table properly rejects the route due to the egress device mismatch. Update the extack message as well to show it could be a device mismatch for the nexthop spec. Fixes: fc1e64e ("net/ipv6: Add support for onlink flag") Signed-off-by: David Ahern <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 58e354c commit 44750f8

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

net/ipv6/route.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2479,7 +2479,7 @@ static int ip6_route_check_nh_onlink(struct net *net,
24792479
struct net_device *dev,
24802480
struct netlink_ext_ack *extack)
24812481
{
2482-
u32 tbid = l3mdev_fib_table(dev) ? : RT_TABLE_LOCAL;
2482+
u32 tbid = l3mdev_fib_table(dev) ? : RT_TABLE_MAIN;
24832483
const struct in6_addr *gw_addr = &cfg->fc_gateway;
24842484
u32 flags = RTF_LOCAL | RTF_ANYCAST | RTF_REJECT;
24852485
struct rt6_info *grt;
@@ -2490,7 +2490,8 @@ static int ip6_route_check_nh_onlink(struct net *net,
24902490
if (grt) {
24912491
if (!grt->dst.error &&
24922492
(grt->rt6i_flags & flags || dev != grt->dst.dev)) {
2493-
NL_SET_ERR_MSG(extack, "Nexthop has invalid gateway");
2493+
NL_SET_ERR_MSG(extack,
2494+
"Nexthop has invalid gateway or device mismatch");
24942495
err = -EINVAL;
24952496
}
24962497

0 commit comments

Comments
 (0)