Subject: Re: [PATCH net-next v3 2/3] nfp: add framework to support ipsec offloading

From: Leon Romanovsky <[email-masked]>
Date: Sun, 6 Nov 2022 21:39:51 +0200

On Tue, Nov 01, 2022 at 12:02:47PM +0100, Simon Horman wrote:
> From: Huanhuan Wang <[email-masked]>
> 
> A new metadata type and config structure are introduced to
> interact with firmware to support ipsec offloading. This
> feature relies on specific firmware that supports ipsec
> encrypt/decrypt by advertising related capability bit.
> 
> The xfrm callbacks which interact with upper layer are
> implemented in the following patch.
> 
> Based on initial work of Norm Bagley <[email-masked]>.
> 
> Signed-off-by: Huanhuan Wang <[email-masked]>
> Reviewed-by: Louis Peens <[email-masked]>
> Signed-off-by: Simon Horman <[email-masked]>
> ---
>  drivers/net/ethernet/netronome/Kconfig        |  11 ++
>  drivers/net/ethernet/netronome/nfp/Makefile   |   2 +
>  .../ethernet/netronome/nfp/crypto/crypto.h    |  23 ++++
>  .../net/ethernet/netronome/nfp/crypto/ipsec.c | 105 ++++++++++++++++++
>  drivers/net/ethernet/netronome/nfp/nfd3/dp.c  |  58 ++++++++--
>  .../net/ethernet/netronome/nfp/nfd3/ipsec.c   |  18 +++
>  .../net/ethernet/netronome/nfp/nfd3/nfd3.h    |   8 ++
>  drivers/net/ethernet/netronome/nfp/nfp_net.h  |   9 ++
>  .../ethernet/netronome/nfp/nfp_net_common.c   |   3 +
>  .../net/ethernet/netronome/nfp/nfp_net_ctrl.h |   4 +
>  10 files changed, 231 insertions(+), 10 deletions(-)
>  create mode 100644 drivers/net/ethernet/netronome/nfp/crypto/ipsec.c
>  create mode 100644 drivers/net/ethernet/netronome/nfp/nfd3/ipsec.c

<...>

> +void nfp_net_ipsec_clean(struct nfp_net *nn)
> +{
> +	if (!(nn->cap_w1 & NFP_NET_CFG_CTRL_IPSEC))
> +		return;
> +	xa_destroy(&nn->xa_ipsec);

You shouldn't use xa_destroy() here as if you have entries in xa_ipsec,
you won't release them and leak memory without any warning. Most likely,
the WARN_ON(!xa_empty(&nn->xa_ipsec)) is what you want here.

The rest code is ok.

Thanks,
Reviewed-by: Leon Romanovsky <[email-masked]>