Skip to content

Commit cbaf3f6

Browse files
idoschkuba-moo
authored andcommitted
mlxsw: spectrum_mr: Update egress RIF list before route's action
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]>
1 parent 6a780f5 commit cbaf3f6

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
@@ -535,6 +535,16 @@ mlxsw_sp_mr_route_evif_resolve(struct mlxsw_sp_mr_table *mr_table,
535535
u16 erif_index = 0;
536536
int err;
537537

538+
/* Add the eRIF */
539+
if (mlxsw_sp_mr_vif_valid(rve->mr_vif)) {
540+
erif_index = mlxsw_sp_rif_index(rve->mr_vif->rif);
541+
err = mr->mr_ops->route_erif_add(mlxsw_sp,
542+
rve->mr_route->route_priv,
543+
erif_index);
544+
if (err)
545+
return err;
546+
}
547+
538548
/* Update the route action, as the new eVIF can be a tunnel or a pimreg
539549
* device which will require updating the action.
540550
*/
@@ -544,17 +554,7 @@ mlxsw_sp_mr_route_evif_resolve(struct mlxsw_sp_mr_table *mr_table,
544554
rve->mr_route->route_priv,
545555
route_action);
546556
if (err)
547-
return err;
548-
}
549-
550-
/* Add the eRIF */
551-
if (mlxsw_sp_mr_vif_valid(rve->mr_vif)) {
552-
erif_index = mlxsw_sp_rif_index(rve->mr_vif->rif);
553-
err = mr->mr_ops->route_erif_add(mlxsw_sp,
554-
rve->mr_route->route_priv,
555-
erif_index);
556-
if (err)
557-
goto err_route_erif_add;
557+
goto err_route_action_update;
558558
}
559559

560560
/* Update the minimum MTU */
@@ -572,14 +572,14 @@ mlxsw_sp_mr_route_evif_resolve(struct mlxsw_sp_mr_table *mr_table,
572572
return 0;
573573

574574
err_route_min_mtu_update:
575-
if (mlxsw_sp_mr_vif_valid(rve->mr_vif))
576-
mr->mr_ops->route_erif_del(mlxsw_sp, rve->mr_route->route_priv,
577-
erif_index);
578-
err_route_erif_add:
579575
if (route_action != rve->mr_route->route_action)
580576
mr->mr_ops->route_action_update(mlxsw_sp,
581577
rve->mr_route->route_priv,
582578
rve->mr_route->route_action);
579+
err_route_action_update:
580+
if (mlxsw_sp_mr_vif_valid(rve->mr_vif))
581+
mr->mr_ops->route_erif_del(mlxsw_sp, rve->mr_route->route_priv,
582+
erif_index);
583583
return err;
584584
}
585585

0 commit comments

Comments
 (0)