net/ipv6: onlink nexthop checks should default to main table

"Linux Kernel Mailing List" <[email protected]>
Newsgroups gmane.linux.kernel.commits.head
Message-ID <[email protected]>
Web:        https://git.kernel.org/torvalds/c/44750f8483a1bc4bda58ec4f7b7af5b053833d49
Commit:     44750f8483a1bc4bda58ec4f7b7af5b053833d49
Parent:     58e354c01b1906b603dcdb28ec35250b09eac625
Refname:    refs/heads/master
Author:     David Ahern <[email protected]>
AuthorDate: Tue Feb 6 13:17:06 2018 -0800
Committer:  David S. Miller <[email protected]>
CommitDate: Wed Feb 7 21:52:42 2018 -0500

    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: fc1e64e1092f ("net/ipv6: Add support for onlink flag")
    Signed-off-by: David Ahern <[email protected]>
    Signed-off-by: David S. Miller <[email protected]>
---
 net/ipv6/route.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 69c43d289c69..9dcfadddd800 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -2479,7 +2479,7 @@ static int ip6_route_check_nh_onlink(struct net *net,
 				     struct net_device *dev,
 				     struct netlink_ext_ack *extack)
 {
-	u32 tbid = l3mdev_fib_table(dev) ? : RT_TABLE_LOCAL;
+	u32 tbid = l3mdev_fib_table(dev) ? : RT_TABLE_MAIN;
 	const struct in6_addr *gw_addr = &cfg->fc_gateway;
 	u32 flags = RTF_LOCAL | RTF_ANYCAST | RTF_REJECT;
 	struct rt6_info *grt;
@@ -2490,7 +2490,8 @@ static int ip6_route_check_nh_onlink(struct net *net,
 	if (grt) {
 		if (!grt->dst.error &&
 		    (grt->rt6i_flags & flags || dev != grt->dst.dev)) {
-			NL_SET_ERR_MSG(extack, "Nexthop has invalid gateway");
+			NL_SET_ERR_MSG(extack,
+				       "Nexthop has invalid gateway or device mismatch");
 			err = -EINVAL;
 		}
 
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.