From: sashiko-bot@kernel.org
To: "Ziyu Zhang" <ziyuzhang201@gmail.com>
Cc: linux-rdma@vger.kernel.org
Subject: Re: [PATCH net v3] net/mlx5e: Wait for flow setup outside encap_tbl_lock
Date: Tue, 01 Dec 2026 14:03:02 +0000 [thread overview]
Message-ID: <sashiko-outbox-243446@kernel.org> (raw)
In-Reply-To: <20261130140215.66953-1-ziyuzhang201@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] net/mlx5e: mismatched eswitch encap_flow_wait waitqueue across
peer eswitches
- [Medium] net/mlx5e: premature flow->init_done publication on multipath
retry
--
commit b29fecbbd509d028a51eb87566d082bb9f3fbba8
Author: Ziyu Zhang <ziyuzhang201@gmail.com>
net/mlx5e: Wait for flow setup outside encap_tbl_lock
This commit replaces the per-flow init_done completion with a boolean flag
and a per-eswitch waitqueue so neighbour and FIB updates drop
encap_tbl_lock while waiting for in-flight flow setup to finish. It also
retires post-action rules before signalling del_hw_done and processes
encap entries during FIB updates even when no flow reference is taken.
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c
> index e1ebc9b2d061d..1522458213bff 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c
> @@ -103,6 +103,9 @@ void mlx5e_rep_update_flows(struct mlx5e_priv *priv,
> if (encap_connected == neigh_connected && ether_addr_equal(e->h_dest, ha))
> goto unlock;
>
> + wait_event_cmd(esw->offloads.encap_flow_wait, mlx5e_encap_flows_ready(e),
> + mutex_unlock(&esw->offloads.encap_tbl_lock),
> + mutex_lock(&esw->offloads.encap_tbl_lock));
> mlx5e_take_all_encap_flows(e, &flow_list);
>
> if ((e->flags & MLX5_ENCAP_ENTRY_VALID) &&
[Severity: High]
Can waiting on esw->offloads.encap_flow_wait miss wakeups when the flow
and the encap or route entry belong to different eswitch instances?
In mlx5e_rep_neigh_update(), mlx5e_rep_update_flows() is called with
netdev_priv(e->out_dev), so it sleeps on the encap output device's
esw->offloads.encap_flow_wait while holding rtnl_lock(). In multiport
eswitch or LAG setups, get_route_and_out_devs() allows e->out_dev to be a
peer eswitch uplink representor, and mlx5e_tc_fib_event_work() similarly
sleeps on the uplink device's eswitch waitqueue. However,
__mlx5e_add_fdb_flow() and mlx5e_tc_del_fdb_flow() only wake
flow->priv->mdev->priv.eswitch->offloads.encap_flow_wait.
If a flow added on one eswitch attaches to an encap or route entry owned
by the peer eswitch (for example, in alloc_flow_post_acts()) and a
neighbour or FIB update sees flow->init_done == false, the wakeup fires on
the originating eswitch waitqueue and leaves the waiter hung in
TASK_UNINTERRUPTIBLE with rtnl_lock() held:
CPU0 CPU1 (neigh/FIB update)
__mlx5e_add_fdb_flow() [esw0]
parse_tc_fdb_actions()
alloc_flow_post_acts()
mlx5e_attach_encap()
/* attaches to e on esw1 */
rtnl_lock()
mlx5e_rep_update_flows() [esw1]
wait_event_cmd(
esw1->offloads.encap_flow_wait,
mlx5e_encap_flows_ready(e), ...)
/* setup fails or finishes */
wake_up_all(
&esw0->offloads.encap_flow_wait)
<-- never woken; hangs with RTNL
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> index 011741553f5b9..1688f8951581e 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
[ ... ]
> @@ -4584,7 +4601,6 @@ __mlx5e_add_fdb_flow(struct mlx5e_priv *priv,
> goto err_free;
>
> err = mlx5e_tc_add_fdb_flow(priv, flow, extack);
> - complete_all(&flow->init_done);
> if (err) {
> if (!(err == -ENETUNREACH && mlx5_lag_is_multipath(in_mdev)))
> goto err_free;
> @@ -4592,6 +4608,9 @@ __mlx5e_add_fdb_flow(struct mlx5e_priv *priv,
> add_unready_flow(flow);
> }
>
> + /* Publish the initialized attributes to neighbour and FIB updates. */
> + smp_store_release(&flow->init_done, true);
> + wake_up_all(&priv->mdev->priv.eswitch->offloads.encap_flow_wait);
> return flow;
>
> err_free:
[Severity: Medium]
Does setting flow->init_done = true when mlx5e_tc_add_fdb_flow() fails
with -ENETUNREACH under multipath LAG expose an uninitialized flow to
concurrent neighbour and FIB updates?
When a flow with a multi-table post-action encap hits -ENETUNREACH and is
queued via add_unready_flow(), alloc_flow_post_acts() has already attached
the flow to e->flows and offloaded the post-action rule using
e->pkt_reformat, while MLX5E_TC_FLOW_FLAG_OFFLOADED remains clear. Because
flow->init_done is published anyway, a concurrent
mlx5e_tc_encap_flows_del() or mlx5e_invalidate_encap() does not wait, sees
!mlx5e_is_offloaded_flow(flow), skips mlx5e_tc_unoffload_flow_post_acts(),
and frees e->pkt_reformat via mlx5_packet_reformat_dealloc() while the
post-action rule in hardware still references it.
In addition, when mlx5e_tc_reoffload_flows_work() later retries
mlx5e_tc_add_fdb_flow() on the unready flow, flow->init_done is already
true, so concurrent neighbour or FIB updates bypass wait_event_cmd() and
race with the retry while it modifies flow->attr.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261130140215.66953-1-ziyuzhang201@gmail.com?part=1
next prev parent reply other threads:[~2026-12-01 14:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 14:02 [PATCH net v3] net/mlx5e: Wait for flow setup outside encap_tbl_lock Ziyu Zhang
2026-11-30 14:03 ` netdev-bot+sinfo
2026-12-01 14:03 ` sashiko-bot [this message]
2026-12-01 14:27 ` netdev-bot+sashiko
2026-12-02 2:25 ` Jianbo Liu
2026-12-01 17:14 ` Tariq Toukan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-243446@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=ziyuzhang201@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.