Skip to contentSkip to conversation

mlxsw: spectrum_router: Do not allow ipv6 gateway with v4 route via replace

PATCH Superseded David Ahern 2 participants 2 messages Apr 22, 2019 – Apr 23, 2019

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mlxsw: spectrum_router: Do not allow ipv6 gateway with v4 route via replace

From: David Ahern <[email protected]>

mlxsw currently does not support v6 gateways with v4 routes. Commit 19a9d136f198 ("ipv4: Flag fib_info with a fib_nh using IPv6 gateway") prevents a route from being added, but nothing stops the replace. Add a catch for it too.

    $ ip  ro add 172.16.2.0/24 via 10.99.1.2
    $ ip  ro replace 172.16.2.0/24 via inet6 fe80::202:ff:fe00:b dev swp1s0
    Error: mlxsw_spectrum: IPv6 gateway with IPv4 route is not supported.
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +2 -0
index 34d9053e5cf0..d21b73236971 100644
@@ -6109,6 +6109,8 @@ static int mlxsw_sp_router_fib_event(struct notifier_block *nb,
 			NL_SET_ERR_MSG_MOD(info->extack, "FIB offload was aborted. Not configuring route");
 			return notifier_from_errno(-EINVAL);
 		}
+		/* fall through */
+	case FIB_EVENT_ENTRY_REPLACE:
 		if (info->family == AF_INET) {
 			struct fib_entry_notifier_info *fen_info = ptr;
 
Signature · 1 line
2.11.0
#1 lore raw
Quoted 20 lines · David Ahern

From: David Ahern <[email protected]>

mlxsw currently does not support v6 gateways with v4 routes. Commit 19a9d136f198 ("ipv4: Flag fib_info with a fib_nh using IPv6 gateway") prevents a route from being added, but nothing stops the replace. Add a catch for it too.

    $ ip  ro add 172.16.2.0/24 via 10.99.1.2
    $ ip  ro replace 172.16.2.0/24 via inet6 fe80::202:ff:fe00:b dev swp1s0
    Error: mlxsw_spectrum: IPv6 gateway with IPv4 route is not supported.
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +0 -0
index 34d9053e5cf0..d21b73236971 100644

drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c static int mlxsw_sp_router_fib_event(struct notifier_block *nb, · line 6113

Quoted 5 lines
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +2 -0
@@ -6109,6 +6109,8 @@ static int mlxsw_sp_router_fib_event(struct notifier_block *nb,
 			NL_SET_ERR_MSG_MOD(info->extack, "FIB offload was aborted. Not configuring route");
 			return notifier_from_errno(-EINVAL);
 		}
+		/* fall through */
+	case FIB_EVENT_ENTRY_REPLACE:

Good catch!

I think we need to have FIB_EVENT_ENTRY_REPLACE and FIB_EVENT_ENTRY_APPEND right after FIB_EVENT_ENTRY_ADD. We want to prevent route replace and append in case of abort and also prevent replace/append of IPv4 routes with IPv6 nexthop.

Quoted 6 lines
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +0 -0
 		if (info->family == AF_INET) {
 			struct fib_entry_notifier_info *fen_info = ptr;
 
Signature · 1 line
2.11.0