๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #23757

Re: [PATCH net 10/10] net/mlx5e: Create IPsec flow counters once per SA

#23757
From: netdev-bot+sashiko
Date: Fri, 27 Nov 2026 22:32
111 lines
12041 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The patch leaves dead per-SA counter fields behind.

--

net/mlx5e: Create IPsec flow counters once per SA

The IPsec flow counters used to be created and destroyed together with
the flow rules, so every rule update (for example after a neighbour
update) recreated them and lost the earlier counter values. This patch
creates the counters once when the SA is added, frees them when the SA
is freed, and moves them into a new sa_entry->fcs[] array.

> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.h b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.h
> index e70189f81ffb9..2e8c6fc216de3 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.h
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.h
> @@ -216,13 +216,20 @@ struct mlx5e_ipsec_drop {
>  	struct mlx5_fc *fc;
>  };
>  
> +enum {
> +	MLX5_IPSEC_FC_RULE,
> +	MLX5_IPSEC_FC_REPLAY,
> +	MLX5_IPSEC_FC_AUTH,
> +	MLX5_IPSEC_FC_TRAILER,
> +	MLX5_IPSEC_FC_NUM,
> +};
> +
>  struct mlx5e_ipsec_rule {
>  	struct mlx5_flow_handle *rule;
>  	struct mlx5_flow_handle *status_pass;
>  	struct mlx5_flow_handle *sa_sel;
>  	struct mlx5_modify_hdr *modify_hdr;
>  	struct mlx5_pkt_reformat *pkt_reformat;
> -	struct mlx5_fc *fc;
>  	struct mlx5e_ipsec_drop replay;
>  	struct mlx5e_ipsec_drop auth;
>  	struct mlx5e_ipsec_drop trailer;

[Severity: Low]
This isn't a bug, but should replay, auth and trailer here still be
struct mlx5e_ipsec_drop?

After this patch nothing reads or writes
sa_entry->ipsec_rule.{replay,auth,trailer}.fc:

  rx_add_rule_drop_auth_trailer() and rx_add_rule_drop_replay() set
  only .rule.

  mlx5e_accel_ipsec_fs_del_rule() and the rx_add_rule() error path
  delete only .rule.

  mlx5e_xfrm_update_stats() now reads sa_entry->fcs[].

The only remaining user of mlx5e_ipsec_drop::fc is the shared
rx->status_checks.all rule in rx_create_status_checks(). That rule is
not per-SA.

As a result, every SA carries three counter pointers that are always
NULL, next to the real counters in sa_entry->fcs[]. A later change
that reads ipsec_rule.auth.fc, as mlx5e_xfrm_update_stats() did
before this patch, would still compile. It would then pass NULL to
mlx5_fc_query_cached(), which dereferences the counter without a
check.

Could these three members become plain struct mlx5_flow_handle
pointers, or use a rule-only type?

[ ... ]

> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c
> index d0f738fdeff3d..df90ae327f23f 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c

[ ... ]

> @@ -212,19 +244,10 @@ static int rx_add_rule_drop_auth_trailer(struct mlx5e_ipsec_sa_entry *sa_entry,
>  	if (!spec)
>  		return -ENOMEM;
>  
> -	flow_counter = mlx5_fc_create(mdev, true);
> -	if (IS_ERR(flow_counter)) {
> -		err = PTR_ERR(flow_counter);
> -		mlx5_core_err(mdev,
> -			      "Failed to add ipsec rx status drop rule counter, err=%d\n", err);
> -		goto err_cnt;
> -	}
> -	sa_entry->ipsec_rule.auth.fc = flow_counter;
> -
>  	flow_act.action = MLX5_FLOW_CONTEXT_ACTION_DROP | MLX5_FLOW_CONTEXT_ACTION_COUNT;
>  	flow_act.flags = FLOW_ACT_NO_APPEND;
>  	dest.type = MLX5_FLOW_DESTINATION_TYPE_COUNTER;
> -	dest.counter = flow_counter;
> +	dest.counter = sa_entry->fcs[MLX5_IPSEC_FC_AUTH];

This is where the last write to ipsec_rule.auth.fc is removed. The same
happens to trailer.fc later in this function and to replay.fc in
rx_add_rule_drop_replay().

[ ... ]

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261126215614.792598-1-tariqt%40nvidia.com
Technical Details
Message-ID: <179581873809.3135.8819864252242771107@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-372971-linux-kernel-netdev=dewy.ru
References: <20261126215614.792598-11-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-372971-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net 10/10] net/mlx5e: Create IPsec flow counters once per SA
Date: Fri, 27 Nov 2026 22:32:18 +0000
Organization: Usenet Network
Message-ID: <179581873809.3135.8819864252242771107@kernel.org>
References: <20261126215614.792598-11-tariqt@nvidia.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="834317"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:nI969KHaJzvVji8B4YtW+NYlyRE= sha256:whXLVGBFd3y10X+zgoPYQyIQFJzwTR0zaAREl1ubFCM=
	sha1:vzStNzBwg0Boa1sT+IwW2sjeKXE= sha256:xclZKykYLSJVs8+MY2Kwi8IzOso38jldtJ9t/jnFwrc=
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 CC427125F69; Sat, 28 Nov 2026 01:32:41 +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 DPs_u0tugJfQ;
	Sat, 28 Nov 2026 01:32:38 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-372971-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id 19356125F65; Sat, 28 Nov 2026 01:32:29 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id 45C9527B9C; Fri, 27 Nov 2026 22:32:22 +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=1795818741;
	b=g+KaxzsS1odZ3aVLvMhqgHs2xwxamQZjKELoLRiBMvTX8o+VuGpAuOGQWT2ITj9sJn6K
	 Lfkur5wSOQ97QymTOqvg65oWUZxz7VS1Ad5mLwbPChozbEq65vWkKcdm0jKabahL1rMKh
	 sAlF6cFnBPB6joa6kvCQNIu6sWjkqtQCbftNjBu6g4xh+0eAU0L+Mk9ufugpcW3HcOUl5
	 YQxxL3vx9XR+lV8s34GFdrte8n9W5zzWnb0/+CZRYbotETFFLqSglrU0CeMTSw7KS/EcF
	 zemQKcvlG23soRxZXFIeMB/89pqNKq+Dt6gJioLEOgsI6BxyvIalf2OF7ZBKWmv0Lqg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795818741;
	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=nAJBQ8MIZaqTPQTUXwwLjElZiVs8zGff5Ry4tR4iEs8=;
	b=GkWJr0PmZPnSMSTixmZC5ccDwdBDY1+PJLWje+0Obb8WCIw3ctyunmGuRErcMvpoqKlT
	 UpvuhIEvaHRRRMw86mtnennXpybHst6luXwt0pbnDFcjCvFct+Mk9MjvvUP9RRLNHtG5P
	 4VAuhMt5wgXKpaCHDZTsCZ6Wmj/8noMcq40YNjmJcNfUXH6WTB/Vn0ucTDK5yC0RW2RKP
	 4GZ1Qxai83dzUGKRdZyEfxcng1BJINZjOs84gksdH3Wyu9JgWSuDv3I0gAvpama8EMyiC
	 5KmWs3atxFC7Mf8zCETvnRZi12Q8zdhx00lJrVJN4wet/qRLDrfFdGC23NFd/MhUmlg==
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=O6wCdCIk;
	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 EED36606A31F;
	Fri, 27 Nov 2026 22:32:20 +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=O6wCdCIk
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=1795818740;
	b=PzUOC1pQdbnxaUV6Z8Wsy52Emdn+QJkH2t8zgIh2VmfSqFq1WnYVcn6MOjw7OXu8BkIr
	 ijHeFF5SqqNl8uRBPIUzg6h1zPYu0a6OzSKbOnoFQCGlLqv/XR8q0CIWqPtCsexdiE4gb
	 ipjDQQZ29LlzHTn88G/DSHQ5k1Sb66JHrDilBfFiMjfqxQ027hSWhAM8f9vH5SKsaQDyb
	 T1SE0SOaWxlxsu2A5EDcFFVxAiykEId/baqPshSZoaq+JJ+g1TJatUFSKEt4bYjb9aUDV
	 MG35xJCCKhuoVjiraHBtmQZzocmdhpezX6EkGtQIaTKDpvLmOvb0mTFfeA1xxyUU7iQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795818740;
	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=nAJBQ8MIZaqTPQTUXwwLjElZiVs8zGff5Ry4tR4iEs8=;
	b=ola58XciaFMyTdMjhfsK/IXDifE7v+nXk3uA9WvvkYA+Fu21xwSUk4GwCFGzhBvPWzGG
	 v5wfGhEoOu/EggUiWJ0dDFsNrU3b8CeNxOEwwx8LZoe8T/DY39SNX44xiBG4Ou4DP+cvH
	 9DAkPpMINb2MkQgsQGHRfVXfsXwbC2xzHboBHtWJuHfUY+yP7j2iuFrOUl8advtsTK3It
	 lzlGYzcBdbOfPOzVzSJWe+HxehnHsAXUJq05PCHxsD5QxOLzPSf7mB9q/c0b81jJ/dcnI
	 xvTVk58haPZZ4H+Igxh85Yl7JpsR5WcraEXylhqAt69ycTpIn/uqRVipCVHXfg0Dj+g==
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=O6wCdCIk;
	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 1C2C1606A323;
	Fri, 27 Nov 2026 22:32:19 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D9B91F0089C;
	Fri, 27 Nov 2026 22:32:18 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795818739;
	bh=nAJBQ8MIZaqTPQTUXwwLjElZiVs8zGff5Ry4tR4iEs8=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=O6wCdCIkjKpZGBkfK7+DnaI2/7sQIWJ/Ha5R1/FxHgG7ftY71DXI0iUmMdec6nonB
	 sAjHhNfKPGEfyjV1hyarAIQTl8c4Q6t2ApIRoyATXhUteqzp8TB3Jk4RZgat6+D7RN
	 lhXMlas90qf+Q9OJPkvMxaksIEbpvnlWKgwQKDxpVyDuwRVj3xBDa5SVfr+Kulf6TR
	 MBRVPUybMjxxsx2mdKias70gBI6R9m97zVOdYzlqjQ8blALJdyvqJOVR4Ut2cBbghh
	 8zUEWiQeCV4oUgaXkWPIRV20L4vygbSxu2wckzxtTdcVibb6+WRYW6tb8n1DnqPIo/
	 2VyajjiJjpFYQ==
X-Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
 kuba@kernel.org, netdev@vger.kernel.org, pabeni@redhat.com,
 willemb@google.com, parri.andrea@gmail.com, borisp@nvidia.com,
 cratiu@nvidia.com, eedmunds@nvidia.com, gal@nvidia.com, jmassar@nvidia.com,
 jianbol@nvidia.com, kuniyu@google.com, leon@kernel.org,
 linux-rdma@vger.kernel.org, mbloch@nvidia.com, phaddad@nvidia.com,
 raeds@nvidia.com, saeedm@nvidia.com, horms@kernel.org,
 sridhar.samudrala@intel.com, steffen.klassert@secunet.com
X-In-Reply-To: <20261126215614.792598-11-tariqt@nvidia.com>
X-sashiko-severity: Low
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