mlxsw: Two small updates
Subsystems (3)
cover mlxsw: Two small updates
From: Ido Schimmel <[email protected]>
Patch #1 from Petr handles a corner case in GRE tunnel offload.
Patch #2 from Amit fixes a recent issue where the driver was programming the device to use an adjacency index (for a nexthop) that was not properly initialized.
Amit Cohen (1):
mlxsw: spectrum_router: Fix use of uninitialized adjacency index
Petr Machata (1):
mlxsw: spectrum_router: After underlay moves, demote conflicting
tunnels
.../ethernet/mellanox/mlxsw/spectrum_router.c | 44 +++++++++++++++++-- 1 file changed, 40 insertions(+), 4 deletions(-)
Signature · 1 line
2.21.0
PATCH 1/2 mlxsw: spectrum_router: After underlay moves, demote conflicting tunnels
From: Petr Machata <[email protected]>
When a GRE tunnel is bound to an underlay netdevice and that netdevice is moved to a different VRF, that could cause two tunnels to have the same underlay local address in the same VRF. Linux in this situation dispatches the traffic according to the tunnel key (or lack thereof), but that cannot be offloaded to Spectrum devices.
Detect this situation and unoffload the two impacted tunnels when it happens.
--- .../ethernet/mellanox/mlxsw/spectrum_router.c | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +38 -1
@@ -1614,8 +1614,25 @@ static int mlxsw_sp_netdevice_ipip_ul_vrf_event(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_ipip_entry *ipip_entry, struct net_device *ul_dev, + bool *demote_this, struct netlink_ext_ack *extack) { + u32 ul_tb_id = l3mdev_fib_table(ul_dev) ? : RT_TABLE_MAIN; +enum mlxsw_sp_l3proto ul_proto; +union mlxsw_sp_l3addr saddr; + +/* Moving underlay to a different VRF might cause local address +* conflict, and the conflicting tunnels need to be demoted. +*/ + ul_proto = mlxsw_sp->router->ipip_ops_arr[ipip_entry->ipipt]->ul_proto; + saddr =mlxsw_sp_ipip_netdev_saddr (ul_proto, ipip_entry->ol_dev); +if (mlxsw_sp_ipip_demote_tunnel_by_saddr (mlxsw_sp, ul_proto, + saddr, ul_tb_id, + ipip_entry)) { + *demote_this = true; +return 0 ; + } +return __mlxsw_sp_ipip_entry_update_tunnel (mlxsw_sp, ipip_entry, true, true, false, extack); }
@@ -1766,6 +1783,7 @@ static int __mlxsw_sp_netdevice_ipip_ul_event(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_ipip_entry *ipip_entry, struct net_device *ul_dev, + bool *demote_this, unsigned long event, struct netdev_notifier_info *info) {
@@ -1780,6 +1798,7 @@ __mlxsw_sp_netdevice_ipip_ul_event(struct mlxsw_sp *mlxsw_sp,return mlxsw_sp_netdevice_ipip_ul_vrf_event (mlxsw_sp, ipip_entry, ul_dev, + demote_this, extack);break ;
@@ -1806,13 +1825,31 @@ mlxsw_sp_netdevice_ipip_ul_event(struct mlxsw_sp *mlxsw_sp,while ((ipip_entry =mlxsw_sp_ipip_entry_find_by_ul_dev (mlxsw_sp, ul_dev, ipip_entry))) { +struct mlxsw_sp_ipip_entry *prev; +bool demote_this = false; + err =__mlxsw_sp_netdevice_ipip_ul_event (mlxsw_sp, ipip_entry, - ul_dev, event, info); + ul_dev, &demote_this, + event, info);if (err) {mlxsw_sp_ipip_demote_tunnel_by_ul_netdev (mlxsw_sp, ul_dev);return err; } + +if (demote_this) { +if (list_is_first (&ipip_entry->ipip_list_node, + &mlxsw_sp->router->ipip_list)) + prev =NULL ; +else +/* This can't be cached from previous iteration, +* because that entry could be gone now. +*/ + prev =list_prev_entry (ipip_entry, + ipip_list_node); +mlxsw_sp_ipip_entry_demote_tunnel (mlxsw_sp, ipip_entry); + ipip_entry = prev; + } }return 0 ;
Signature · 1 line
2.21.0
PATCH 2/2 mlxsw: spectrum_router: Fix use of uninitialized adjacency index
In reply to Ido SchimmelFrom: Amit Cohen <[email protected]>
When mlxsw_sp_adj_discard_write() is called for the first time, the value stored in 'mlxsw_sp->router->adj_discard_index' is invalid, as indicated by 'mlxsw_sp->router->adj_discard_index_valid' being set to 'false'.
In this case, we should not use the value initially stored in 'mlxsw_sp->router->adj_discard_index' (0) and instead use the value allocated later in the function.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +2 -3
@@ -4221,7 +4221,6 @@ mlxsw_sp_fib_entry_ralue_pack(char *ralue_pl,static int mlxsw_sp_adj_discard_write (struct mlxsw_sp *mlxsw_sp,u16 rif_index) { -u32 adj_discard_index = mlxsw_sp->router->adj_discard_index;enum mlxsw_reg_ratr_trap_action trap_action;char ratr_pl[MLXSW_REG_RATR_LEN ];int err;
@@ -4236,8 +4235,8 @@ static int mlxsw_sp_adj_discard_write(struct mlxsw_sp *mlxsw_sp, u16 rif_index) trap_action =MLXSW_REG_RATR_TRAP_ACTION_DISCARD_ERRORS ;mlxsw_reg_ratr_pack (ratr_pl,MLXSW_REG_RATR_OP_WRITE_WRITE_ENTRY , true, -MLXSW_REG_RATR_TYPE_ETHERNET , adj_discard_index, - rif_index); +MLXSW_REG_RATR_TYPE_ETHERNET , + mlxsw_sp->router->adj_discard_index, rif_index);mlxsw_reg_ratr_trap_action_set (ratr_pl, trap_action); err =mlxsw_reg_write (mlxsw_sp->core,MLXSW_REG (ratr), ratr_pl);if (err)
Signature · 1 line
2.21.0
Jakub Kicinski
AppliedQuoted 7 lines · Ido Schimmel
From: Ido Schimmel <[email protected]>
Patch #1 from Petr handles a corner case in GRE tunnel offload.
Patch #2 from Amit fixes a recent issue where the driver was programming the device to use an adjacency index (for a nexthop) that was not properly initialized.
Applied, thank you!