Article View: linux.kernel.netdev
Article #23755Re: [PATCH net 02/10] net/mlx5e: Stop counting packets dropped by IPsec RX SA rules
From: netdev-bot+sashiko
Date: Fri, 27 Nov 2026 22:32
Date: Fri, 27 Nov 2026 22:32
130 lines
13475 bytes
13475 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] In rx_add_rule()
(drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c), the…
--
net/mlx5e: Stop counting packets dropped by IPsec RX SA rules
This patch removes the COUNT action and the counter destination from the
RX SA rule used when attrs->drop is set. Packets dropped in hardware are
then no longer added to x->curlft.packets for packet offload. The goal is
to match crypto offload accounting, and the rule keeps CRYPTO_DECRYPT so
ESN state keeps updating.
> 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 502d89a18f9ec..0facc54771558 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
[ ... ]
> @@ -2103,17 +2102,24 @@ static int rx_add_rule(struct mlx5e_ipsec_sa_entry *sa_entry)
> flow_act.crypto.type = MLX5_FLOW_CONTEXT_ENCRYPT_DECRYPT_TYPE_IPSEC;
> flow_act.crypto.obj_id = sa_entry->ipsec_obj_id;
> flow_act.flags |= FLOW_ACT_NO_APPEND;
> - flow_act.action |= MLX5_FLOW_CONTEXT_ACTION_CRYPTO_DECRYPT |
> - MLX5_FLOW_CONTEXT_ACTION_COUNT;
> - if (attrs->drop)
> + /* Keep decrypting packets even when dropped, to allow ESN state
> + * updates.
> + */
> + flow_act.action |= MLX5_FLOW_CONTEXT_ACTION_CRYPTO_DECRYPT;
> + if (attrs->drop) {
> flow_act.action |= MLX5_FLOW_CONTEXT_ACTION_DROP;
> - else
> - flow_act.action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
> - dest[0].type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE;
> - dest[0].ft = rx->ft.status;
> - dest[1].type = MLX5_FLOW_DESTINATION_TYPE_COUNTER;
> - dest[1].counter = counter;
> - rule = mlx5_add_flow_rules(rx->ft.sa, spec, &flow_act, dest, 2);
> + rule = mlx5_add_flow_rules(rx->ft.sa, spec, &flow_act, NULL, 0);
[Severity: Medium]
Could this cause x->curlft.packets to drift away from the hardware ASO
packet-lifetime counter for packet offload RX SAs?
The drop rule still decrypts against sa_entry->ipsec_obj_id, so the ASO
context for that object keeps being processed. For any finite packet limit,
mlx5e_ipsec_packet_setup() in ipsec_offload.c arms the lifetime counter in
the same ASO context without checking the direction:
if (attrs->lft.hard_packet_limit != XFRM_INF) {
MLX5_SET(ipsec_aso, aso_ctx, remove_flow_pkt_cnt,
attrs->lft.hard_packet_limit);
MLX5_SET(ipsec_aso, aso_ctx, hard_lft_arm, 1);
MLX5_SET(ipsec_aso, aso_ctx, remove_flow_enable, 1);
}
x->curlft.packets, however, is derived only from the SA rule flow counter
in mlx5e_xfrm_update_stats():
mlx5_fc_query_cached(ipsec_rule->fc, &bytes, &packets, &lastuse);
success_packets = packets - auth_packets - trailer_packets - replay_packets;
x->curlft.packets += success_packets;
Before this patch, both counts included packets received in the drop
state. After it, only the hardware counter would, assuming the device
decrements remove_flow_pkt_cnt for packets that are decrypted and then
dropped by the same FTE. The code does not show whether the device does
this. Keeping DECRYPT so the ASO state keeps updating suggests that it
might.
If so, when the hardware soft lifetime event fires,
mlx5e_ipsec_handle_limits() checks curlft once and marks the soft limit
as handled:
sa_entry->limits.soft_limit_hit = true;
/* Notify about soft limit */
xfrm_state_check_expire(sa_entry->x);
At that point curlft can be short by the number of packets received while
attrs->drop was set. The soft expiry (rekey) would then be missed on this
path.
In the final round, attrs->lft.soft_packet_limit is set to XFRM_INF, so
mlx5e_ipsec_handle_event() no longer calls mlx5e_ipsec_handle_limits(). Since
remove_flow_enable is set, can the hardware retire the SA while the xfrm
state is still valid, and drop traffic until curlft catches up?
The software poller mlx5e_ipsec_handle_sw_limits() returns early without
requeueing whenever attrs.drop is set. So the catch-up might also not happen.
The commit message says:
Remove the count action and counter destination from the drop rule
so these dropped packets stay out of the lifetime, matching crypto
offload accounting.
Crypto offload does not arm the ASO lifetime counter. Is it intended that
the hardware lifetime for packet offload RX SAs still counts these drops
while curlft no longer does?
> + } else {
> + struct mlx5_flow_destination dest[2];
> +
> + flow_act.action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST |
> + MLX5_FLOW_CONTEXT_ACTION_COUNT;
> + dest[0].type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE;
> + dest[0].ft = rx->ft.status;
> + dest[1].type = MLX5_FLOW_DESTINATION_TYPE_COUNTER;
> + dest[1].counter = counter;
> + rule = mlx5_add_flow_rules(rx->ft.sa, spec, &flow_act, dest, 2);
> + }
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261126215614.792598-1-tariqt%40nvidia.com
Technical Details
Message-ID:
<179581872594.3135.1501113897778355076@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-372965-linux-kernel-netdev=dewy.ruReferences:
<20261126215614.792598-3-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-372965-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net 02/10] net/mlx5e: Stop counting packets dropped by IPsec RX SA rules Date: Fri, 27 Nov 2026 22:32:05 +0000 Organization: Usenet Network Message-ID: <179581872594.3135.1501113897778355076@kernel.org> References: <20261126215614.792598-3-tariqt@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="834212"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:XMK97k8QnAxloQ5V9AmCusJk6Kg= sha256:AKE+Ho1Z36Hh31nfEOHyYYoIfax3RzNXivSTRPwH7gI= sha1:WAbHhm98NrBSUUSeskBJmL+UA5g= sha256:A+Y9v8xuI52xQiNFASykq32HGfVc5s4rexoIPN1Qcdk= 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 48D3F125F6B; Sat, 28 Nov 2026 01:32:31 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.501 X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31 tests=[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 edwoRAzKo8Jn; Sat, 28 Nov 2026 01:32:28 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-372965-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 F3D6E125F65; Sat, 28 Nov 2026 01:32:18 +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 8C61F2DC66; Fri, 27 Nov 2026 22:32:16 +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=1795818734; b=N+rkV7rhfzdQm6kxzyIR/ed8dt8lSKoc1S8fFnyMcJeKq3Pj07+ZWnhhEmh6c2luTSed 3Aoy7ORceshfem/L1WwgI3pZOPCe2bop/olNLMgeOqS+Omxndy/VXfCJE5jbF/XAwXCjR veI+/QvW0sRrgGec5yd8HwB44pXRBp8sQuhhte+v/mPH4OO/blxHQzPD546GsWtZnrtqf GI1fWIOI3Srg9fluw5u0+FZXU3NxXSI3GVWbL6jN9c+s05Bl5IsTOuxswcVWN/CMudXdy IWUcWb2T5FBjgrEgOUbC2y5zOEd+cmBg/BwRb+okCS3cOh+VSQNR9xY6vGTlVnHxieQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795818734; 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=xWeuXFNJEh/jiSDnxzK517P8HlQSiTzBLoh84vujaF0=; b=CjebIVKkGQi2gvI2AuDm15wq8RxeFv+nmun0nzP9KmbaYyngZjncQzZeT4tCXI2XpjLy jhQHN/Fg7YsuzG4LWPfLfiqaCenKENuCTPja9h4JBsokxzc79lyef9wiS2H/K+U6nOxAd Aa1lq6Wkum1ITkl1ThcOkmWkeovZPAFqQj87JDaT3aAOQ4rFuE7mFD70QNj4a4sIfiJxn dI6f3X4z26eCIIZ5wRxmRM3DcphdYI+WXfKWjyVvzdbhqpC0sDqyPHDF2wrIErq2jMA30 rgROOdHaojQkAV7HaLDL+2EjCjZHxgRiS81LzNV36iVwsg5s2Jy7wbMN1EGJ9+ku8Pg== 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=UUR9vJV1; 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 EB261606A33B; Fri, 27 Nov 2026 22:32:13 +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=UUR9vJV1 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=1795818728; b=ApyW2IMbsbVswARturWGNB1Fjt5e/2tMLRazHz4qj83+8rigT+R1G/4W+wUU+pvVkq7d /5DCAe6mmZ5fBtF7q9xb+X6Fd7GEoaOdzb5gvTnvY9jJIofLvTag+KNYAAluF+TaCXwbX 8ELMZR3h7J/LmyyPcuXHU/8ftDwk/aX66T1S5sbAo5TffxY+q214WWb08rqakcNyRseFQ YQJQpThMO8eek/UxtiYj0BBHhefcSr+UAqczKCkoKQc/JCTG01r4zuIOG/Pd9qzopQgSF jlDdH5hXxudNVmNpIR6Z2Q9zY0mxMVMpf8VM+0OqQnvLDXrDEzM6CijyR4wIeBp32kQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795818728; 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=xWeuXFNJEh/jiSDnxzK517P8HlQSiTzBLoh84vujaF0=; b=m1DQF9v8uJlNkjcDsRkbdYNL5MEWoZQo+m/iAjmWpKn7gOvEfaILyxcd/mpnklMRduAx xjkWUAyZRr1ixkvA0LWdK94QdXRAzeSwBIgatPZytVfQn/qkY4N1b2pWlG1SR07XAhhPj v9j7NdnE/60kQKTwNMtOKsxO1f9a/h4KGetxp9KvyDuUx8ULU3MdHaTfK/K+fGRsH6EgT 0LMOnUkgJSo43qYbwhcYHJLgUr6aNWKqoPJZC5ZiWRgQ0WH/dQPJEyM22NQs+ozY3BVzd ToJBkHljxJ5WTrtoH9ioi7tvHhJtZMrVexPS6WJ7ttjxf7BxNWiE3HAHhRBkNFaNI7Q== 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=UUR9vJV1; 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 17667606A31C; Fri, 27 Nov 2026 22:32:08 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61FB71F000C1; Fri, 27 Nov 2026 22:32:06 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795818727; bh=xWeuXFNJEh/jiSDnxzK517P8HlQSiTzBLoh84vujaF0=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=UUR9vJV1FHwKwPTjfB8sKjNThc/9dq9eWGfiz6h2BtiM5LkLgwIfzjA9YaL0HbB+n JH5mkEyQz2aZFT/nhuCQdjCyX1xHSe0pNVBKbQ4YtKmaWtIyeVuzyTc/FMxRqT+vkY fqdE5NMjtle7HZ9f0iOX8EZDDLeztx2w6PWJsie9EEO5T8LCw/SE/oTngRaogVBJge xVVYc01nGpcq/8Th2eGkCitpqyZ3sKxLxrlux6GfF9IPddUfoQdqhz3mYDcwUR6TGw EzEikFcxpd7pO+upHxkq7j2EsXGncObnnG9M/yCBMgV5StJ7O3odhq2h0+SC6EAzIu kVXtYqOd1tYSw== 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-3-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