Skip to content

Commit 375f51e

Browse files
roidayandavem330
authored andcommitted
net/mlx5: E-Switch, Don't allow changing inline mode when flows are configured
Changing the eswitch inline mode can potentially cause already configured flows not to match the policy. E.g. set policy L4, add some L4 rules, set policy to L2 --> bad! Hence we disallow it. Keep track of how many offloaded rules are now set and refuse inline mode changes if this isn't zero. Fixes: bffaa91 ("net/mlx5: E-Switch, Add control for inline mode") Signed-off-by: Roi Dayan <[email protected]> Reviewed-by: Or Gerlitz <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d85cdcc commit 375f51e

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

drivers/net/ethernet/mellanox/mlx5/core/eswitch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ struct mlx5_esw_offload {
209209
struct mlx5_eswitch_rep *vport_reps;
210210
DECLARE_HASHTABLE(encap_tbl, 8);
211211
u8 inline_mode;
212+
u64 num_flows;
212213
};
213214

214215
struct mlx5_eswitch {

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw,
9393
spec, &flow_act, dest, i);
9494
if (IS_ERR(rule))
9595
mlx5_fc_destroy(esw->dev, counter);
96+
else
97+
esw->offloads.num_flows++;
9698

9799
return rule;
98100
}
@@ -108,6 +110,7 @@ mlx5_eswitch_del_offloaded_rule(struct mlx5_eswitch *esw,
108110
counter = mlx5_flow_rule_counter(rule);
109111
mlx5_del_flow_rules(rule);
110112
mlx5_fc_destroy(esw->dev, counter);
113+
esw->offloads.num_flows--;
111114
}
112115
}
113116

@@ -922,6 +925,11 @@ int mlx5_devlink_eswitch_inline_mode_set(struct devlink *devlink, u8 mode)
922925
MLX5_CAP_INLINE_MODE_VPORT_CONTEXT)
923926
return -EOPNOTSUPP;
924927

928+
if (esw->offloads.num_flows > 0) {
929+
esw_warn(dev, "Can't set inline mode when flows are configured\n");
930+
return -EOPNOTSUPP;
931+
}
932+
925933
err = esw_inline_mode_from_devlink(mode, &mlx5_mode);
926934
if (err)
927935
goto out;

0 commit comments

Comments
 (0)