Re: [PATCH net] net/mlx5e: IPsec, Fix RX mapped ID leak when adding a rule fails
From: Jianbo Liu
Date: Wed Nov 18 2026 - 04:49:29 EST
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)We have a fix for this in our queue. It releases the ID under the same
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:
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