๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #24597

Re: [PATCH net-next V5 1/7] net/mlx5e: Generalize TC <-> IPsec mutual exclusion

#24597
From: netdev-bot+sashiko
Date: Mon, 30 Nov 2026 12:07
118 lines
12775 bytes
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?

[ ... ]

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261129120331.1910180-1-tariqt%40nvidia.com
Technical Details
Message-ID: <179604045242.3146.11465224103483791527@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374156-linux-kernel-netdev=dewy.ru
References: <20261129120331.1910180-2-tariqt@nvidia.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374156-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next V5 1/7] net/mlx5e: Generalize TC <-> IPsec mutual
 exclusion
Date: Mon, 30 Nov 2026 12:07:32 +0000
Organization: Usenet Network
Message-ID: <179604045242.3146.11465224103483791527@kernel.org>
References: <20261129120331.1910180-2-tariqt@nvidia.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1419790"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:ztB+Lq0eMu20+a8srFZqyUQ+otw= sha256:bmsbPNRM09IyvBOMDuSpnTWZJZkNX/dBHEsgnFHH0uI=
	sha1:S1wkOZPV7B1yJ4cIwLrsUx0uxf8= sha256:dQtXvsHSm0MY/GXoLw9SehFrv9cJgoctn+2laVisUmo=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 301DF125FE1; Mon, 30 Nov 2026 15:07:55 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id XF6jV8BF-KEu;
	Mon, 30 Nov 2026 15:07:51 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-374156-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 45967125FDF; Mon, 30 Nov 2026 15:07:43 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 98BA1259BF; Mon, 30 Nov 2026 12:07:41 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796040460;
	b=H9DrvcITOs6GuMK2jouJXdAHky99uTfre/v2NhCEVp6AOo9jfhIJTEn69p0+gKJ/fSlT
	 P5xWNCpiF7rXVGh4nJ9VnEVeMCbexd9CxbVkLHQs7IkHdAfgl2ENplfVCXQki5EachbYN
	 rIfHkzuJu5n6hmcmmZ50KRg2clvh657ADiipT22UIXHRz9hk+i3MzPBVIfbocyWnLz62z
	 EXOm9O8K+5QngCUXxsIsnLk+s1ioYBqtzQ2x3jQQktG8Sjb1CPKnZBSyIQdxWyJNbeJQq
	 tyCfGYB/2+o83v3RkUvwtHLeUm9bzw6oziSXjWqnzWRfpj/tNQr8+otN2T0A0lBB2TA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796040460;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=vIvmBum3nzOJEscENG3kF3HxAfKoZPxPl+lvO1fN9b4=;
	b=BRnRxZJ2WmLLDKkLH+nf7zRNM1ZagJ04/RDjr9MYFa0+TAYPXkObpc1/xcMtH5QFgI2r
	 S3aS0sIk86TTJ6bggRK4JIiE4R1+U8nUat4Hf/x/MyXrAXLaq6Ea+/Me5ot3vx8XJrJ3M
	 kRZ+pJ9pIiROuUJWFI3V2jWoZpsOheC0y+XLn+j3p2Fp3QRdSGtsoD08uQbTbgQqZ9BPI
	 bPGcONM2KLiCN5OaUzHALumEAGSa4SmK1gehoi+tqgeuLscmwDcpbKDbvBgQS52fHhZnj
	 DY03zNp6l2dd/kgiOwuYOquaFE5uNUgHuWdXKRY3LXZ6ZcbZZhd21bYo60CzvkMNHvg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=g2yLQEto;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id A88B9606A33A;
	Mon, 30 Nov 2026 12:07:40 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=g2yLQEto
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796040454;
	b=ap9ARZB97dflAuyuWVuaH1hNGT+Ws7HA+yPxvKnYbUjM5K95H2avfjuxj0lK1WUp0wZE
	 V2Kf4WPJ3PYqSiCnq507v47k3fypJhRRdfBRQ4OLFHvtx/Ntdua8RsuaO4QuRfHstbUOl
	 iYrR84my7H3FKkDEMuoLkyDULm9/cz7dEeyhQ+v+nH8xFbFWvOoYtvLR8gIZK+T2keJlf
	 hYTfL3kjIy0hQHt5lqUviA/YHPWSbA0SKVs5t4dGorqpY4P/qG5B3iiZKTvhSk693F0Ao
	 xfekpyWqCI+feadbiC8GhN4GRnwOZQEALAMhKeuC4Ot8k2uet9lRXYzITTJqhjgvlHw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796040454;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=vIvmBum3nzOJEscENG3kF3HxAfKoZPxPl+lvO1fN9b4=;
	b=KhMXF9DHIPMKjxg+l/dvAaEhX2DilPmThx+EFwcqt4uN+R0VgTGjClYOqQCKhjWX17yE
	 nLS1cQ4XsB8wfq+KTjgYMPlm3PKKpHZcnwARB3tiX9OlMGRFIftnwDOz+TGeQBS7A0rZW
	 +sA8Kna5F56bmGE9Fvm0ZtIl9bTczt7dVfg0u1QsDvI32ptmCnay07Bs+P+wRM3g+i1kV
	 yS/wkdMjRIdpMRi5lEzb7JKdkGwfZNGqGI9hcHIcNUSrNTHtYXq9ZUgCOt8POysUMquCi
	 H16MGOW7JImspRQMKbtURYK65Oz+Vt4SvtI3XE7qVVHa/8aRRbcU2k/taHF1Q2Q5kww==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=g2yLQEto;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id C6DE4606A31C;
	Mon, 30 Nov 2026 12:07:34 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id DFF371F0089A;
	Mon, 30 Nov 2026 12:07:32 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796040454;
	bh=vIvmBum3nzOJEscENG3kF3HxAfKoZPxPl+lvO1fN9b4=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=g2yLQEtobONA7AGJEuKr+b2xPzvP31TGUdJ9xyecNXkDEJgE1mnrIaCkIlbKBgjv2
	 4lj5y5GT2cMzE3JnqyGbjsIMllADZMY6/hALNy5f64yJFPM3p5KKmPoah7eVna+514
	 zJLXrfd1hE4Of2GVWHT1Ycz7XSr/UpR5g4jG+52aMFHUq6ME3MX++C9viLkfVYP2rP
	 kyUlEs4RzVCFr4jh7WX+4hVTNX2Zrl3Ql6mrpeF3MCRuQinp8Cev760mHMScS+TfFa
	 zQYfsQaxlmLIlBhmEOSXo3pEzz0tYXa3XUUkXHJ0TJ9VcTIe2Zq/HCsK+jcMPO+z/U
	 RwKcA31GbwXGQ==
X-Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
 kuba@kernel.org, netdev@vger.kernel.org, pabeni@redhat.com,
 sd@queasysnail.net, willemb@google.com, aleksandr.loktionov@intel.com,
 parri.andrea@gmail.com, borisp@nvidia.com, cjubran@nvidia.com,
 lcy8047@gmail.com, cratiu@nvidia.com, daniel.zahka@gmail.com,
 davem@davem-thinkpadp1gen8.ibmlond.csb, doruk@0sec.ai, dtatulea@nvidia.com,
 gal@nvidia.com, jianbol@nvidia.com, joasantonio108@gmail.com, leon@kernel.org,
 linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, mbloch@nvidia.com,
 phaddad@nvidia.com, ralf@mandelbit.com, saeedm@nvidia.com, horms@kernel.org
X-In-Reply-To: <20261129120331.1910180-2-tariqt@nvidia.com>
X-sashiko-severity: Medium
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list