๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
1 messages
1 total messages Started by netdev-bot+sashiko Fri, 27 Nov 2026 22:32
Re: [PATCH net 10/10] net/mlx5e: Create IPsec flow counters once per SA
#23757
Author: 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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads