net: Fix up inet_addr_type checks
Currently inet_addr_type and inet_dev_addr_type expect local addresses to be in the local table. With the VRF device local routes for devices associated with a VRF will be in the table associated with the VRF. Provide an alternate inet_addr lookup to use a specific table rather than defaulting to the local table. inet_addr_type_dev_table keeps the same semantics as inet_addr_type but if the passed in device is enslaved to a VRF then the table for that VRF is used for the lookup. Signed-off-by: David Ahern <dsa@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
15be405eb2
commit
30bbaa1950
@@ -670,16 +670,18 @@ static int fib_check_nh(struct fib_config *cfg, struct fib_info *fi,
|
||||
struct fib_result res;
|
||||
|
||||
if (nh->nh_flags & RTNH_F_ONLINK) {
|
||||
unsigned int addr_type;
|
||||
|
||||
if (cfg->fc_scope >= RT_SCOPE_LINK)
|
||||
return -EINVAL;
|
||||
if (inet_addr_type(net, nh->nh_gw) != RTN_UNICAST)
|
||||
return -EINVAL;
|
||||
dev = __dev_get_by_index(net, nh->nh_oif);
|
||||
if (!dev)
|
||||
return -ENODEV;
|
||||
if (!(dev->flags & IFF_UP))
|
||||
return -ENETDOWN;
|
||||
addr_type = inet_addr_type_dev_table(net, dev, nh->nh_gw);
|
||||
if (addr_type != RTN_UNICAST)
|
||||
return -EINVAL;
|
||||
if (!netif_carrier_ok(dev))
|
||||
nh->nh_flags |= RTNH_F_LINKDOWN;
|
||||
nh->nh_dev = dev;
|
||||
|
Reference in New Issue
Block a user