ipv4: Prepare fib_config for IPv6 gateway
Similar to rtable, fib_config needs to allow the gateway to be either an IPv4 or an IPv6 address. To that end, rename fc_gw to fc_gw4 to mean an IPv4 address and add fc_gw_family. Checks on 'is a gateway set' are changed to see if fc_gw_family is set. In the process prepare the code for a fc_gw_family == AF_INET6. Signed-off-by: David Ahern <dsahern@gmail.com> Reviewed-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
1550c17193
commit
f35b794b3b
@@ -558,7 +558,8 @@ static int rtentry_to_fib_config(struct net *net, int cmd, struct rtentry *rt,
|
||||
if (rt->rt_gateway.sa_family == AF_INET && addr) {
|
||||
unsigned int addr_type;
|
||||
|
||||
cfg->fc_gw = addr;
|
||||
cfg->fc_gw4 = addr;
|
||||
cfg->fc_gw_family = AF_INET;
|
||||
addr_type = inet_addr_type_table(net, addr, cfg->fc_table);
|
||||
if (rt->rt_flags & RTF_GATEWAY &&
|
||||
addr_type == RTN_UNICAST)
|
||||
@@ -568,7 +569,7 @@ static int rtentry_to_fib_config(struct net *net, int cmd, struct rtentry *rt,
|
||||
if (cmd == SIOCDELRT)
|
||||
return 0;
|
||||
|
||||
if (rt->rt_flags & RTF_GATEWAY && !cfg->fc_gw)
|
||||
if (rt->rt_flags & RTF_GATEWAY && !cfg->fc_gw_family)
|
||||
return -EINVAL;
|
||||
|
||||
if (cfg->fc_scope == RT_SCOPE_NOWHERE)
|
||||
@@ -708,7 +709,8 @@ static int rtm_to_fib_config(struct net *net, struct sk_buff *skb,
|
||||
cfg->fc_oif = nla_get_u32(attr);
|
||||
break;
|
||||
case RTA_GATEWAY:
|
||||
cfg->fc_gw = nla_get_be32(attr);
|
||||
cfg->fc_gw_family = AF_INET;
|
||||
cfg->fc_gw4 = nla_get_be32(attr);
|
||||
break;
|
||||
case RTA_VIA:
|
||||
NL_SET_ERR_MSG(extack, "IPv4 does not support RTA_VIA attribute");
|
||||
|
Reference in New Issue
Block a user