Skip to content

Commit 93a3319

Browse files
Chris MiSaeed Mahameed
Chris Mi
authored and
Saeed Mahameed
committed
net/mlx5e: Don't hold encap tbl lock if there is no encap action
The cited commit holds encap tbl lock unconditionally when setting up dests. But it may cause the following deadlock: PID: 1063722 TASK: ffffa062ca5d0000 CPU: 13 COMMAND: "handler8" #0 [ffffb14de05b7368] __schedule at ffffffffa1d5aa91 #1 [ffffb14de05b7410] schedule at ffffffffa1d5afdb #2 [ffffb14de05b7430] schedule_preempt_disabled at ffffffffa1d5b528 #3 [ffffb14de05b7440] __mutex_lock at ffffffffa1d5d6cb #4 [ffffb14de05b74e8] mutex_lock_nested at ffffffffa1d5ddeb #5 [ffffb14de05b74f8] mlx5e_tc_tun_encap_dests_set at ffffffffc12f2096 [mlx5_core] #6 [ffffb14de05b7568] post_process_attr at ffffffffc12d9fc5 [mlx5_core] #7 [ffffb14de05b75a0] mlx5e_tc_add_fdb_flow at ffffffffc12de877 [mlx5_core] #8 [ffffb14de05b75f0] __mlx5e_add_fdb_flow at ffffffffc12e0eef [mlx5_core] #9 [ffffb14de05b7660] mlx5e_tc_add_flow at ffffffffc12e12f7 [mlx5_core] #10 [ffffb14de05b76b8] mlx5e_configure_flower at ffffffffc12e1686 [mlx5_core] #11 [ffffb14de05b7720] mlx5e_rep_indr_offload at ffffffffc12e3817 [mlx5_core] #12 [ffffb14de05b7730] mlx5e_rep_indr_setup_tc_cb at ffffffffc12e388a [mlx5_core] #13 [ffffb14de05b7740] tc_setup_cb_add at ffffffffa1ab2ba8 #14 [ffffb14de05b77a0] fl_hw_replace_filter at ffffffffc0bdec2f [cls_flower] #15 [ffffb14de05b7868] fl_change at ffffffffc0be6caa [cls_flower] #16 [ffffb14de05b7908] tc_new_tfilter at ffffffffa1ab71f0 [1031218.028143] wait_for_completion+0x24/0x30 [1031218.028589] mlx5e_update_route_decap_flows+0x9a/0x1e0 [mlx5_core] [1031218.029256] mlx5e_tc_fib_event_work+0x1ad/0x300 [mlx5_core] [1031218.029885] process_one_work+0x24e/0x510 Actually no need to hold encap tbl lock if there is no encap action. Fix it by checking if encap action exists or not before holding encap tbl lock. Fixes: 37c3b9f ("net/mlx5e: Prevent encap offload when neigh update is running") Signed-off-by: Chris Mi <[email protected]> Reviewed-by: Vlad Buslov <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 0507f2c commit 93a3319

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c

-3
Original file line numberDiff line numberDiff line change
@@ -1030,9 +1030,6 @@ int mlx5e_tc_tun_encap_dests_set(struct mlx5e_priv *priv,
10301030
int out_index;
10311031
int err = 0;
10321032

1033-
if (!mlx5e_is_eswitch_flow(flow))
1034-
return 0;
1035-
10361033
parse_attr = attr->parse_attr;
10371034
esw_attr = attr->esw_attr;
10381035
*vf_tun = false;

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

+18-3
Original file line numberDiff line numberDiff line change
@@ -1725,6 +1725,19 @@ verify_attr_actions(u32 actions, struct netlink_ext_ack *extack)
17251725
return 0;
17261726
}
17271727

1728+
static bool
1729+
has_encap_dests(struct mlx5_flow_attr *attr)
1730+
{
1731+
struct mlx5_esw_flow_attr *esw_attr = attr->esw_attr;
1732+
int out_index;
1733+
1734+
for (out_index = 0; out_index < MLX5_MAX_FLOW_FWD_VPORTS; out_index++)
1735+
if (esw_attr->dests[out_index].flags & MLX5_ESW_DEST_ENCAP)
1736+
return true;
1737+
1738+
return false;
1739+
}
1740+
17281741
static int
17291742
post_process_attr(struct mlx5e_tc_flow *flow,
17301743
struct mlx5_flow_attr *attr,
@@ -1737,9 +1750,11 @@ post_process_attr(struct mlx5e_tc_flow *flow,
17371750
if (err)
17381751
goto err_out;
17391752

1740-
err = mlx5e_tc_tun_encap_dests_set(flow->priv, flow, attr, extack, &vf_tun);
1741-
if (err)
1742-
goto err_out;
1753+
if (mlx5e_is_eswitch_flow(flow) && has_encap_dests(attr)) {
1754+
err = mlx5e_tc_tun_encap_dests_set(flow->priv, flow, attr, extack, &vf_tun);
1755+
if (err)
1756+
goto err_out;
1757+
}
17431758

17441759
if (attr->action & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR) {
17451760
err = mlx5e_tc_attach_mod_hdr(flow->priv, flow, attr);

0 commit comments

Comments
 (0)