Skip to content

Commit 9508634

Browse files
idoschgregkh
authored andcommitted
mlxsw: spectrum_mr: Update egress RIF list before route's action
commit cbaf3f6 upstream. Each multicast route that is forwarding packets (as opposed to trapping them) points to a list of egress router interfaces (RIFs) through which packets are replicated. A route's action can transition from trap to forward when a RIF is created for one of the route's egress virtual interfaces (eVIF). When this happens, the route's action is first updated and only later the list of egress RIFs is committed to the device. This results in the route pointing to an invalid list. In case the list pointer is out of range (due to uninitialized memory), the device will complain: mlxsw_spectrum2 0000:06:00.0: EMAD reg access failed (tid=5733bf490000905c,reg_id=300f(pefa),type=write,status=7(bad parameter)) Fix this by first committing the list of egress RIFs to the device and only later update the route's action. Note that a fix is not needed in the reverse function (i.e., mlxsw_sp_mr_route_evif_unresolve()), as there the route's action is first updated and only later the RIF is removed from the list. Cc: [email protected] Fixes: c011ec1 ("mlxsw: spectrum: Add the multicast routing offloading logic") Signed-off-by: Ido Schimmel <[email protected]> Reviewed-by: Petr Machata <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 27a1306 commit 9508634

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,16 @@ mlxsw_sp_mr_route_evif_resolve(struct mlxsw_sp_mr_table *mr_table,
524524
u16 erif_index = 0;
525525
int err;
526526

527+
/* Add the eRIF */
528+
if (mlxsw_sp_mr_vif_valid(rve->mr_vif)) {
529+
erif_index = mlxsw_sp_rif_index(rve->mr_vif->rif);
530+
err = mr->mr_ops->route_erif_add(mlxsw_sp,
531+
rve->mr_route->route_priv,
532+
erif_index);
533+
if (err)
534+
return err;
535+
}
536+
527537
/* Update the route action, as the new eVIF can be a tunnel or a pimreg
528538
* device which will require updating the action.
529539
*/
@@ -533,17 +543,7 @@ mlxsw_sp_mr_route_evif_resolve(struct mlxsw_sp_mr_table *mr_table,
533543
rve->mr_route->route_priv,
534544
route_action);
535545
if (err)
536-
return err;
537-
}
538-
539-
/* Add the eRIF */
540-
if (mlxsw_sp_mr_vif_valid(rve->mr_vif)) {
541-
erif_index = mlxsw_sp_rif_index(rve->mr_vif->rif);
542-
err = mr->mr_ops->route_erif_add(mlxsw_sp,
543-
rve->mr_route->route_priv,
544-
erif_index);
545-
if (err)
546-
goto err_route_erif_add;
546+
goto err_route_action_update;
547547
}
548548

549549
/* Update the minimum MTU */
@@ -561,14 +561,14 @@ mlxsw_sp_mr_route_evif_resolve(struct mlxsw_sp_mr_table *mr_table,
561561
return 0;
562562

563563
err_route_min_mtu_update:
564-
if (mlxsw_sp_mr_vif_valid(rve->mr_vif))
565-
mr->mr_ops->route_erif_del(mlxsw_sp, rve->mr_route->route_priv,
566-
erif_index);
567-
err_route_erif_add:
568564
if (route_action != rve->mr_route->route_action)
569565
mr->mr_ops->route_action_update(mlxsw_sp,
570566
rve->mr_route->route_priv,
571567
rve->mr_route->route_action);
568+
err_route_action_update:
569+
if (mlxsw_sp_mr_vif_valid(rve->mr_vif))
570+
mr->mr_ops->route_erif_del(mlxsw_sp, rve->mr_route->route_priv,
571+
erif_index);
572572
return err;
573573
}
574574

0 commit comments

Comments
 (0)