🚀 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 02/10] net/mlx5e: Stop counting packets dropped by IPsec RX SA rules
#23755
Author: netdev-bot+sashiko
Date: Fri, 27 Nov 2026 22:32
130 lines
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
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