From: netdev-bot+sashiko@kernel.org
To: tariqt@nvidia.com
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
Subject: Re: [PATCH net 10/10] net/mlx5e: Create IPsec flow counters once per SA
Date: Fri, 27 Nov 2026 22:32:18 +0000 [thread overview]
Message-ID: <179581873809.3135.8819864252242771107@kernel.org> (raw)
In-Reply-To: <20261126215614.792598-11-tariqt@nvidia.com>
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
next prev parent reply other threads:[~2026-11-27 22:32 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 21:56 [PATCH net 00/10] net/mlx5e: Fix IPsec SA races and neighbour handling Tariq Toukan
2026-11-26 21:56 ` [PATCH net 01/10] net/mlx5e: Initialize IPsec XArrays with XA_FLAGS_LOCK_BH Tariq Toukan
2026-11-27 21:58 ` sashiko-bot
2026-11-27 22:32 ` netdev-bot+sashiko
2026-11-26 21:56 ` [PATCH net 02/10] net/mlx5e: Stop counting packets dropped by IPsec RX SA rules Tariq Toukan
2026-11-27 22:32 ` netdev-bot+sashiko
2026-11-26 21:56 ` [PATCH net 03/10] net/mlx5e: Fix IPsec SA modify/stats update race Tariq Toukan
2026-11-27 22:32 ` netdev-bot+sashiko
2026-11-26 21:56 ` [PATCH net 04/10] net/mlx5e: Drain pending hardware event work before freeing IPsec SA Tariq Toukan
2026-11-27 22:32 ` netdev-bot+sashiko
2026-11-26 21:56 ` [PATCH net 05/10] net/mlx5e: Drop IPsec tunnel traffic if the neigh cannot be created Tariq Toukan
2026-11-27 21:58 ` sashiko-bot
2026-11-27 22:32 ` netdev-bot+sashiko
2026-11-26 21:56 ` [PATCH net 08/10] net/mlx5e: Validate neighbour events before updating IPsec SAs Tariq Toukan
2026-11-27 22:32 ` netdev-bot+sashiko
2026-11-26 21:56 ` [PATCH net 10/10] net/mlx5e: Create IPsec flow counters once per SA Tariq Toukan
2026-11-27 22:32 ` netdev-bot+sashiko [this message]
2026-11-27 21:58 ` [PATCH net 00/10] net/mlx5e: Fix IPsec SA races and neighbour handling sashiko-bot
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=179581873809.3135.8819864252242771107@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=borisp@nvidia.com \
--cc=cratiu@nvidia.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=eedmunds@nvidia.com \
--cc=gal@nvidia.com \
--cc=horms@kernel.org \
--cc=jianbol@nvidia.com \
--cc=jmassar@nvidia.com \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=leon@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=mbloch@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=parri.andrea@gmail.com \
--cc=phaddad@nvidia.com \
--cc=raeds@nvidia.com \
--cc=saeedm@nvidia.com \
--cc=sridhar.samudrala@intel.com \
--cc=steffen.klassert@secunet.com \
--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