Subject: Re: [PATCH net 2/4] bonding: call xfrm state xdo_dev_state_free after deletion

From: Hangbin Liu <[email-masked]>
Date: Wed, 31 Jul 2024 11:36:48 +0800

On Mon, Jul 29, 2024 at 03:44:03PM +0300, Tariq Toukan wrote:
> From: Jianbo Liu <[email-masked]>
> 
> Need to call xdo_dev_state_free API to avoid hardware resource leakage
> when deleting all SAs from old active real interface.
> 
> Fixes: 9a5605505d9c ("bonding: Add struct bond_ipesc to manage SA")
> Signed-off-by: Jianbo Liu <[email-masked]>
> Reviewed-by: Cosmin Ratiu <[email-masked]>
> Signed-off-by: Tariq Toukan <[email-masked]>
> ---
>  drivers/net/bonding/bond_main.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> index 3b880ff2b82a..551cebfa3261 100644
> --- a/drivers/net/bonding/bond_main.c
> +++ b/drivers/net/bonding/bond_main.c
> @@ -581,6 +581,8 @@ static void bond_ipsec_del_sa_all(struct bonding *bond)
>  				   __func__);
>  		} else {
>  			slave->dev->xfrmdev_ops->xdo_dev_state_delete(ipsec->xs);
> +			if (slave->dev->xfrmdev_ops->xdo_dev_state_free)
> +				slave->dev->xfrmdev_ops->xdo_dev_state_free(ipsec->xs);

OH, you do it here. 

>  		}
>  		ipsec->xs->xso.real_dev = NULL;

I'm not sure if we should make xdo_dev_state_free() rely on
xdo_dev_state_delete(). In xfrm_state_find() the xfrm_dev_state_free()
is called whatever xfrm_dev_state_delete() is support or not. Although
usually the NIC driver will support the _delete() if the _free() supported.

BTW, For me this patch should merge with Patch 1/4

Thanks
Hangbin