Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: Jianbo Liu <jianbol@nvidia.com>
To: Changyul Lee <lcy8047@gmail.com>,
	Saeed Mahameed <saeedm@nvidia.com>,
	Leon Romanovsky <leon@kernel.org>,
	Tariq Toukan <tariqt@nvidia.com>, Mark Bloch <mbloch@nvidia.com>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	netdev@vger.kernel.org, linux-rdma@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net] net/mlx5e: IPsec, Fix RX mapped ID leak when adding a rule fails
Date: Wed, 18 Nov 2026 17:49:01 +0800	[thread overview]
Message-ID: <96a5ce67-89c8-4010-bfc4-4553e1aefe87@nvidia.com> (raw)
In-Reply-To: <20261118051247.3885308-1-lcy8047@gmail.com>



On 11/18/2026 1:12 PM, Changyul Lee wrote:
> In switchdev mode, rx_add_rule() calls
> mlx5_esw_ipsec_rx_setup_modify_header(), which allocates a mapped ID for
> the SA in ipsec->ipsec_obj_id_map. If a later step fails, the error path
> frees the modify header but leaves the ID in the XArray, and
> mlx5e_xfrm_add_state() then frees the SA entry. Each failed inbound
> packet offload SA leaks one of the 2047 IDs. Once they are used up, no
> new inbound SA can be offloaded until the IPsec context is cleaned up.

Thanks for the patch. The leak is real.

[...]

> @@ -2161,8 +2161,10 @@ static int rx_add_rule(struct mlx5e_ipsec_sa_entry *sa_entry)
>   	if (flow_act.pkt_reformat)
>   		mlx5_packet_reformat_dealloc(mdev, flow_act.pkt_reformat);
>   err_pkt_reformat:
> -	if (flow_act.modify_hdr)
> +	if (flow_act.modify_hdr) {
>   		mlx5_modify_header_dealloc(mdev, flow_act.modify_hdr);
> +		mlx5_esw_ipsec_rx_id_mapping_remove(sa_entry);
> +	}
>   err_mod_header:
We have a fix for this in our queue. It releases the ID under the same
condition that maps it, so the eswitch helper is only called for an SA
on the eswitch tables:

  err_pkt_reformat:
         if (flow_act.modify_hdr)
                 mlx5_modify_header_dealloc(mdev, flow_act.modify_hdr);
+       if (!attrs->drop && rx == ipsec->rx_esw)
+               mlx5_esw_ipsec_rx_id_mapping_remove(sa_entry);
  err_mod_header:

I prefer this form. Do you want to send a v2 with it? Then I will add
my Reviewed-by. If not, we will send our patch ourselves.

We tested it on ConnectX-7 in switchdev mode with fault injection on
one RX SA add: 46 of the 2047 IDs were lost without the fix, none with
it.

Thanks,
Jianbo

      parent reply	other threads:[~2026-11-18  9:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18  5:12 [PATCH net] net/mlx5e: IPsec, Fix RX mapped ID leak when adding a rule fails Changyul Lee
2026-11-18  5:24 ` sashiko-bot
2026-11-18  9:49 ` Jianbo Liu [this message]

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=96a5ce67-89c8-4010-bfc4-4553e1aefe87@nvidia.com \
    --to=jianbol@nvidia.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=kuba@kernel.org \
    --cc=lcy8047@gmail.com \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=mbloch@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=saeedm@nvidia.com \
    --cc=tariqt@nvidia.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