Netdev List
 help / color / mirror / Atom feed
From: Cosmin Ratiu <cratiu@nvidia.com>
To: Tariq Toukan <tariqt@nvidia.com>,
	"netdev-bot+sashiko@kernel.org" <netdev-bot+sashiko@kernel.org>
Cc: "parri.andrea@gmail.com" <parri.andrea@gmail.com>,
	"doruk@0sec.ai" <doruk@0sec.ai>,
	Boris Pismenny <borisp@nvidia.com>,
	"andrew+netdev@lunn.ch" <andrew+netdev@lunn.ch>,
	"daniel.zahka@gmail.com" <daniel.zahka@gmail.com>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"davem@davem-thinkpadp1gen8.ibmlond.csb"
	<davem@davem-thinkpadp1gen8.ibmlond.csb>,
	"sd@queasysnail.net" <sd@queasysnail.net>,
	"edumazet@kernel.org" <edumazet@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"pabeni@redhat.com" <pabeni@redhat.com>,
	"willemb@google.com" <willemb@google.com>,
	"joasantonio108@gmail.com" <joasantonio108@gmail.com>,
	"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
	Jianbo Liu <jianbol@nvidia.com>,
	Carolina Jubran <cjubran@nvidia.com>,
	Dragos Tatulea <dtatulea@nvidia.com>,
	"lcy8047@gmail.com" <lcy8047@gmail.com>,
	"kuba@kernel.org" <kuba@kernel.org>,
	"leon@kernel.org" <leon@kernel.org>,
	"ralf@mandelbit.com" <ralf@mandelbit.com>,
	Mark Bloch <mbloch@nvidia.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"aleksandr.loktionov@intel.com" <aleksandr.loktionov@intel.com>,
	Gal Pressman <gal@nvidia.com>, Saeed Mahameed <saeedm@nvidia.com>,
	"horms@kernel.org" <horms@kernel.org>,
	Patrisious Haddad <phaddad@nvidia.com>
Subject: Re: [PATCH net-next V5 1/7] net/mlx5e: Generalize TC <-> IPsec mutual exclusion
Date: Tue, 1 Dec 2026 14:57:47 +0000	[thread overview]
Message-ID: <ddf085eabe017852d1aa59128d90876be2ef5204.camel@nvidia.com> (raw)
In-Reply-To: <179604045242.3146.11465224103483791527@kernel.org>

On Mon, 2026-11-30 at 12:07 +0000, netdev-bot+sashiko@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue(s) to consider.
> 
> Critical: 0 · High: 0 · Medium: 1 · Low: 0
> 
> If you believe none of the issues are legitimate, please reply to
> each
> issue of Medium severity or higher and explain why the AI is wrong.
> If any of them are legitimate and you plan to respin, please let
> patchwork
> know by including "pw-bot: cr" as a separate line at the end of your
> reply
> (one such reply per series is enough).
> 
> - [Medium] The num_block_accel count leaks on PM suspend/resume while
> TC
>   flower rules are installed on the PF netdev in NIC (legacy) mode.
> 
> --
> 
> net/mlx5e: Generalize TC <-> IPsec mutual exclusion
> 
> This commit moves the TC/IPsec mutual exclusion helpers to en_accel.h
> as
> mlx5e_accel_{,un}block_tc_offload() and renames num_block_ipsec to
> num_block_accel. It also drops the CONFIG_MLX5_EN_IPSEC check from
> is_tc_accel_check_needed(), so that follow-up patches can use the
> same gate
> for PSP and MACsec.
> 
> > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> > b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> > index 615af3acdb9eb..03bade86c38c2 100644
> > --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> > +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> > @@ -4821,14 +4821,15 @@ static bool
> > is_flow_rule_duplicate_allowed(struct net_device *dev,
> 
> [ ... ]
> 
> > -static bool is_tc_ipsec_order_check_needed(struct net_device
> > *filter, struct mlx5e_priv *priv)
> > +static bool is_tc_accel_check_needed(struct net_device *filter,
> > +				     struct mlx5e_priv *priv)
> >  {
> > -	if (!IS_ENABLED(CONFIG_MLX5_EN_IPSEC))
> > -		return false;
> > -
> >  	if (filter != priv->netdev)
> >  		return false;
> 
> [Severity: Medium]
> Without the IS_ENABLED(CONFIG_MLX5_EN_IPSEC) check, every successful
> mlx5e_configure_flower() on the PF netdev now increments
> num_block_accel in
> every build. That count is becoming the gate for IPsec, PSP and
> MACsec. Can
> it leak across PM suspend/resume in NIC (legacy) mode?
> 
> The only decrement is in mlx5e_delete_flower(). It only runs when the
> flow's cookie is still in the driver's tc hashtable.
> 
> On system suspend the netdev stays registered, so the TC core keeps
> its
> filters. The driver still frees its flows, though:
> 
> mlx5_suspend()
>   mlx5_unload_one(dev, true)
>     mlx5_detach_device(dev, true)
>       mlx5e_suspend()
>         _mlx5e_suspend()
>           mlx5e_detach_netdev()
>             profile->cleanup_rx() == mlx5e_cleanup_nic_rx()
>               mlx5e_tc_nic_cleanup()
>                 rhashtable_free_and_destroy(&tc->ht,
> _mlx5e_tc_del_flow, NULL);
> 
> The destroy callback does not drop the count:
> 
> drivers/net/ethernet/mellanox/mlx5/core/en_tc.c:_mlx5e_tc_del_flow()
> {
> 	...
> 	mlx5e_tc_del_flow(priv, flow);
> 	kfree(flow);
> }
> 
> On resume, mlx5e_attach_netdev() creates a new, empty hashtable. When
> the
> user later deletes the filters, mlx5e_delete_flower() misses the
> lookup.
> It returns before it reaches mlx5e_tc_unblock_accel_offload():
> 
> 	flow = rhashtable_lookup(tc_ht, &f->cookie, tc_ht_params);
> 	if (!flow || !same_flow_direction(flow, flags)) {
> 		err = -EINVAL;
> 		goto errout;
> 	}
> 
> offload_block is set up only once, in mlx5_mdev_init(), and is never
> reset.
> esw->user_count, by contrast, is reset on the legacy and offloads
> init
> paths. So num_block_accel would stay non-zero for the life of the
> mdev.
> 
> Wouldn't every later mlx5e_accel_block_tc_offload() call on this mdev
> then
> return -EBUSY until the driver is reloaded?
> 
> 	if (mdev->offload_block.num_block_accel)
> 		ret = -EBUSY;
> 
> The leaking teardown path dates from commit c8e350e62fc5, where it
> only
> affected IPsec packet offload in CONFIG_MLX5_EN_IPSEC builds. With
> this
> patch and the follow-ups, one leaked TC count would block IPsec SA
> and
> policy add, PSP RX enable and MACsec RX SA add. That includes builds
> without IPsec. At the end of the series, the _mlx5e_tc_del_flow() and
> mlx5e_tc_nic_cleanup() path still has no unblock.
> 
> The other teardown paths look fine:
> 
> - Health recovery, fw reset, devlink reload and driver unload use
>   suspend=false.
> - _mlx5e_remove() calls unregister_netdev() before _mlx5e_suspend(),
> so
>   the TC core flushes the filters through mlx5e_delete_flower()
> first.
> - In switchdev mode, mlx5e_vport_uplink_rep_unload() unregisters the
>   netdev before the profile change.
> 
> So this appears specific to PM suspend in NIC mode.
> 
> Should mlx5e_tc_nic_cleanup() also drop the num_block_accel count for
> each
> flow it frees?
> 

This is a preexisting bug introduced by commit c8e350e62fc5
("net/mlx5e: Make TC and IPsec offloads mutually exclusive on a
netdev"). I have a fix prepared for net for this, will submit it
separately to not block this series.

Cosmin.


  reply	other threads:[~2026-12-01 14:57 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-29 12:03 [PATCH net-next V5 0/7] net/mlx5e: Prepare for PSP decapsulation Tariq Toukan
2026-11-29 12:03 ` [PATCH net-next V5 1/7] net/mlx5e: Generalize TC <-> IPsec mutual exclusion Tariq Toukan
2026-11-30 12:07   ` netdev-bot+sashiko
2026-12-01 14:57     ` Cosmin Ratiu [this message]
2026-11-29 12:03 ` [PATCH net-next V5 2/7] net/mlx5e: ipsec: Block TC offload when IPsec is enabled Tariq Toukan
2026-11-29 12:03 ` [PATCH net-next V5 3/7] net/mlx5e: psp: Block TC offload when PSP " Tariq Toukan
2026-11-29 12:03 ` [PATCH net-next V5 4/7] net/mlx5e: macsec: Block TC offload when MACsec " Tariq Toukan
2026-11-30 12:07   ` netdev-bot+sashiko
2026-12-01 15:05     ` Cosmin Ratiu
2026-11-29 12:03 ` [PATCH net-next V5 5/7] net/mlx5e: psp: Move RX marker from ft_metadata to flow_tag Tariq Toukan
2026-11-30 12:07   ` netdev-bot+sashiko
2026-12-01 15:20     ` Cosmin Ratiu
2026-11-29 12:03 ` [PATCH net-next V5 6/7] net/mlx5e: ipsec: " Tariq Toukan
2026-11-29 12:03 ` [PATCH net-next V5 7/7] net/mlx5e: macsec: " 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=ddf085eabe017852d1aa59128d90876be2ef5204.camel@nvidia.com \
    --to=cratiu@nvidia.com \
    --cc=aleksandr.loktionov@intel.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=borisp@nvidia.com \
    --cc=cjubran@nvidia.com \
    --cc=daniel.zahka@gmail.com \
    --cc=davem@davem-thinkpadp1gen8.ibmlond.csb \
    --cc=davem@davemloft.net \
    --cc=doruk@0sec.ai \
    --cc=dtatulea@nvidia.com \
    --cc=edumazet@kernel.org \
    --cc=gal@nvidia.com \
    --cc=horms@kernel.org \
    --cc=jianbol@nvidia.com \
    --cc=joasantonio108@gmail.com \
    --cc=kuba@kernel.org \
    --cc=lcy8047@gmail.com \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=mbloch@nvidia.com \
    --cc=netdev-bot+sashiko@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=parri.andrea@gmail.com \
    --cc=phaddad@nvidia.com \
    --cc=ralf@mandelbit.com \
    --cc=saeedm@nvidia.com \
    --cc=sd@queasysnail.net \
    --cc=tariqt@nvidia.com \
    --cc=willemb@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox