Skip to content

Commit 19a9d13

Browse files
dsaherndavem330
authored andcommitted
ipv4: Flag fib_info with a fib_nh using IPv6 gateway
Until support is added to the offload drivers, they need to be able to reject routes with an IPv6 gateway. To that end add a flag to fib_info that indicates if any fib_nh has a v6 gateway. The flag allows the drivers to efficiently know the use of a v6 gateway without walking all fib_nh tied to a fib_info each time a route is added. Update mlxsw and rocker to reject the routes with extack message as to why. Signed-off-by: David Ahern <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1a38c43 commit 19a9d13

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c

+8
Original file line numberDiff line numberDiff line change
@@ -6092,6 +6092,14 @@ static int mlxsw_sp_router_fib_event(struct notifier_block *nb,
60926092
NL_SET_ERR_MSG_MOD(info->extack, "FIB offload was aborted. Not configuring route");
60936093
return notifier_from_errno(-EINVAL);
60946094
}
6095+
if (info->family == AF_INET) {
6096+
struct fib_entry_notifier_info *fen_info = ptr;
6097+
6098+
if (fen_info->fi->fib_nh_is_v6) {
6099+
NL_SET_ERR_MSG_MOD(info->extack, "IPv6 gateway with IPv4 route is not supported");
6100+
return notifier_from_errno(-EINVAL);
6101+
}
6102+
}
60956103
break;
60966104
}
60976105

drivers/net/ethernet/rocker/rocker_main.c

+9
Original file line numberDiff line numberDiff line change
@@ -2207,6 +2207,15 @@ static int rocker_router_fib_event(struct notifier_block *nb,
22072207
switch (event) {
22082208
case FIB_EVENT_ENTRY_ADD: /* fall through */
22092209
case FIB_EVENT_ENTRY_DEL:
2210+
if (info->family == AF_INET) {
2211+
struct fib_entry_notifier_info *fen_info = ptr;
2212+
2213+
if (fen_info->fi->fib_nh_is_v6) {
2214+
NL_SET_ERR_MSG_MOD(info->extack, "IPv6 gateway with IPv4 route is not supported");
2215+
return notifier_from_errno(-EINVAL);
2216+
}
2217+
}
2218+
22102219
memcpy(&fib_work->fen_info, ptr, sizeof(fib_work->fen_info));
22112220
/* Take referece on fib_info to prevent it from being
22122221
* freed while work is queued. Release it afterwards.

include/net/ip_fib.h

+1
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ struct fib_info {
147147
#define fib_rtt fib_metrics->metrics[RTAX_RTT-1]
148148
#define fib_advmss fib_metrics->metrics[RTAX_ADVMSS-1]
149149
int fib_nhs;
150+
bool fib_nh_is_v6;
150151
struct rcu_head rcu;
151152
struct fib_nh fib_nh[0];
152153
#define fib_dev fib_nh[0].fib_nh_dev

net/ipv4/fib_semantics.c

+2
Original file line numberDiff line numberDiff line change
@@ -1349,6 +1349,8 @@ struct fib_info *fib_create_info(struct fib_config *cfg,
13491349

13501350
change_nexthops(fi) {
13511351
fib_info_update_nh_saddr(net, nexthop_nh);
1352+
if (nexthop_nh->fib_nh_gw_family == AF_INET6)
1353+
fi->fib_nh_is_v6 = true;
13521354
} endfor_nexthops(fi)
13531355

13541356
fib_rebalance(fi);

0 commit comments

Comments
 (0)