Skip to content

Commit 95435ad

Browse files
w1ldptrSaeed Mahameed
authored and
Saeed Mahameed
committed
net/mlx5e: Only access fully initialized flows in neigh update
To remove dependency on rtnl lock and prevent neigh update code from accessing uninitialized flows when executing concurrently with tc, extend mlx5e_tc_flow with 'init_done' completion. Modify helper mlx5e_take_all_encap_flows() to wait for flow completion after obtaining reference to it. Modify mlx5e_tc_encap_flows_del() and mlx5e_tc_encap_flows_add() to skip flows that don't have OFFLOADED flag set, which can happen if concurrent flow initialization failed. This commit finishes neigh update refactoring for concurrent execution started in previous change in this series. Signed-off-by: Vlad Buslov <[email protected]> Reviewed-by: Roi Dayan <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 2a1f176 commit 95435ad

File tree

1 file changed

+8
-0
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core

1 file changed

+8
-0
lines changed

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

+8
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ struct mlx5e_tc_flow {
130130
struct list_head tmp_list; /* temporary flow list used by neigh update */
131131
refcount_t refcnt;
132132
struct rcu_head rcu_head;
133+
struct completion init_done;
133134
union {
134135
struct mlx5_esw_flow_attr esw_attr[0];
135136
struct mlx5_nic_flow_attr nic_attr[0];
@@ -1319,6 +1320,8 @@ void mlx5e_tc_encap_flows_add(struct mlx5e_priv *priv,
13191320
bool all_flow_encaps_valid = true;
13201321
int i;
13211322

1323+
if (!mlx5e_is_offloaded_flow(flow))
1324+
continue;
13221325
esw_attr = flow->esw_attr;
13231326
spec = &esw_attr->parse_attr->spec;
13241327

@@ -1367,6 +1370,8 @@ void mlx5e_tc_encap_flows_del(struct mlx5e_priv *priv,
13671370
int err;
13681371

13691372
list_for_each_entry(flow, flow_list, tmp_list) {
1373+
if (!mlx5e_is_offloaded_flow(flow))
1374+
continue;
13701375
spec = &flow->esw_attr->parse_attr->spec;
13711376

13721377
/* update from encap rule to slow path rule */
@@ -1412,6 +1417,7 @@ void mlx5e_take_all_encap_flows(struct mlx5e_encap_entry *e, struct list_head *f
14121417
flow = container_of(efi, struct mlx5e_tc_flow, encaps[efi->index]);
14131418
if (IS_ERR(mlx5e_flow_get(flow)))
14141419
continue;
1420+
wait_for_completion(&flow->init_done);
14151421

14161422
flow->tmp_efi_index = efi->index;
14171423
list_add(&flow->tmp_list, flow_list);
@@ -3492,6 +3498,7 @@ mlx5e_alloc_flow(struct mlx5e_priv *priv, int attr_size,
34923498
INIT_LIST_HEAD(&flow->mod_hdr);
34933499
INIT_LIST_HEAD(&flow->hairpin);
34943500
refcount_set(&flow->refcnt, 1);
3501+
init_completion(&flow->init_done);
34953502

34963503
*__flow = flow;
34973504
*__parse_attr = parse_attr;
@@ -3564,6 +3571,7 @@ __mlx5e_add_fdb_flow(struct mlx5e_priv *priv,
35643571
goto err_free;
35653572

35663573
err = mlx5e_tc_add_fdb_flow(priv, flow, extack);
3574+
complete_all(&flow->init_done);
35673575
if (err) {
35683576
if (!(err == -ENETUNREACH && mlx5_lag_is_multipath(in_mdev)))
35693577
goto err_free;

0 commit comments

Comments
 (0)