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 4/7] net/mlx5e: macsec: Block TC offload when MACsec is enabled
Date: Tue, 1 Dec 2026 15:05:45 +0000	[thread overview]
Message-ID: <d317b9161243e477eb4d3393577ba795d2c76312.camel@nvidia.com> (raw)
In-Reply-To: <179604045496.3146.10459707437454849888@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] This patch makes every installed MACsec RX decrypt rule
> take a
>   device-wide TC block.
> 
> --
> 
> net/mlx5e: macsec: Block TC offload when MACsec is enabled
> 
> This patch makes each installed MACsec RX decrypt rule hold a device-
> wide
> TC offload block. The block is taken in mlx5e_macsec_init_sa_fs() and
> released in mlx5e_macsec_cleanup_sa_fs().
> macsec_upd_secy_hw_address()
> also keeps TC blocked while it rebuilds the RX rules.
> 
> > diff --git
> > a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
> > b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
> > index 13896e9c1d331..146f1036dba42 100644
> > --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
> > +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
> 
> [ ... ]
> 
> > @@ -325,6 +326,8 @@ static void mlx5e_macsec_cleanup_sa_fs(struct
> > mlx5e_macsec *macsec,
> >  	mlx5_macsec_fs_del_rule(macsec->mdev->macsec_fs, sa-
> > >macsec_rule, action, netdev,
> >  				fs_id);
> >  	sa->macsec_rule = NULL;
> > +	if (!is_tx)
> > +		mlx5e_accel_unblock_tc_offload(macsec->mdev);
> >  }
> 
> [ ... ]
> 
> > @@ -354,13 +358,26 @@ static int mlx5e_macsec_init_sa_fs(struct
> > macsec_context *ctx,
> >  	rule_attrs.action = (is_tx) ?
> > MLX5_ACCEL_MACSEC_ACTION_ENCRYPT :
> >  				     
> > MLX5_ACCEL_MACSEC_ACTION_DECRYPT;
> >  
> > +	if (!is_tx) {
> > +		err = mlx5e_accel_block_tc_offload(priv->mdev);
> > +		if (err)
> > +			return err;
> > +	}
> > +
> 
> [Severity: Medium]
> Can mdev->offload_block.num_block_tc leak here when the NIC profile
> is
> torn down while RX SAs are still installed?
> 
> The only place this block is released is
> mlx5e_macsec_cleanup_sa_fs().
> When the eswitch moves from legacy to switchdev, the path is:
> 
> mlx5e_vport_uplink_rep_load()
>   mlx5e_netdev_change_profile()
>     priv->profile->cleanup(priv) == mlx5e_nic_cleanup()
>       mlx5e_macsec_cleanup()
> 
> mlx5e_macsec_cleanup() tears everything down without walking the RX
> SAs:
> 
> 	mlx5_notifier_unregister(mdev, &macsec->nb);
> 	mlx5_macsec_fs_cleanup(mdev->macsec_fs);
> 	destroy_workqueue(macsec->wq);
> 	mlx5e_macsec_aso_cleanup(&macsec->aso, mdev);
> 	mutex_destroy(&macsec->lock);
> 	kfree(macsec);
> 
> The netdev stays registered during a profile change. The MACsec core
> (macsec_notify() in drivers/net/macsec.c) only deletes secys on
> NETDEV_UNREGISTER, so mdo_del_secy is never called either.
> 
> Unlike IPsec, MACsec does not call mlx5_eswitch_block_mode(), so
> nothing
> prevents this mode change.
> 
> After the switch, num_block_tc stays above zero in struct
> mlx5_core_dev.
> It is only initialized at mdev init and is never reset. The uplink
> representor reuses the same netdev, and is_tc_accel_check_needed()
> returns true for it. Every mlx5e_configure_flower() on the uplink
> would
> then fail in mlx5e_tc_block_accel_offload():
> 
> 	if (mdev->offload_block.num_block_tc)
> 		ret = -EBUSY;
> 
> Going back to legacy mode doesn't seem to recover either.
> mlx5e_macsec_init() allocates a fresh, empty context, so a later
> mdo_del_secy can't find the device and never unblocks. TC offload on
> the
> uplink/NIC netdev would stay disabled until the mlx5_core_dev is
> re-probed.
> 
> Dropping SA rules during profile teardown is an older problem. The
> persistent device-level TC block is what turns it into a lasting TC
> offload outage. Later patches in the series don't seem to touch
> mlx5e_macsec_cleanup() or the profile-change path.
> 
> Should mlx5e_macsec_cleanup() release the TC blocks held by installed
> RX
> rules? Alternatively, should MACsec RX offload block the eswitch mode
> change?
> 

This is preexisting, and that's not the only scenario this can be
triggered in. mlx5e_detach_netdev() also invokes mlx5e_macsec_cleanup()
which doesn't fully release the RX resources.
I have a series of macsec patches to address this (and several other
mlx5 macsec issues), we will send this to the ML when finalized.

Cosmin.
> 

  reply	other threads:[~2026-12-01 15:05 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
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 [this message]
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=d317b9161243e477eb4d3393577ba795d2c76312.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