patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH 19.11] net/af_xdp: ensure socket is deleted on Rx queue setup error
@ 2022-03-10 10:07 Ciara Loftus
  2022-03-10 10:42 ` Christian Ehrhardt
  0 siblings, 1 reply; 2+ messages in thread
From: Ciara Loftus @ 2022-03-10 10:07 UTC (permalink / raw)
  To: stable; +Cc: Ciara Loftus

[ upstream commit b26431a617e4039e6c0f65c5ee56f62f347b686b ]

During Rx queue setup the PMD attempts to allocate mbufs for the fill
queue after the socket is created. If this allocation fails, the socket
should be deleted before returning an error to the user. Fix this.

Fixes: d8a210774e1d ("net/af_xdp: support unaligned umem chunks")

Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
---
 drivers/net/af_xdp/rte_eth_af_xdp.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index 9eae705caa..9b36d80335 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -898,26 +898,27 @@ xsk_configure(struct pmd_internals *internals, struct pkt_rx_queue *rxq,
 			&txq->tx, &cfg);
 	if (ret) {
 		AF_XDP_LOG(ERR, "Failed to create xsk socket.\n");
-		goto err;
+		goto out_umem;
 	}
 
 #if defined(XDP_UMEM_UNALIGNED_CHUNK_FLAG)
 	ret = rte_pktmbuf_alloc_bulk(rxq->umem->mb_pool, fq_bufs, reserve_size);
 	if (ret) {
 		AF_XDP_LOG(DEBUG, "Failed to get enough buffers for fq.\n");
-		goto err;
+		goto out_xsk;
 	}
 #endif
 	ret = reserve_fill_queue(rxq->umem, reserve_size, fq_bufs);
 	if (ret) {
-		xsk_socket__delete(rxq->xsk);
 		AF_XDP_LOG(ERR, "Failed to reserve fill queue.\n");
-		goto err;
+		goto out_xsk;
 	}
 
 	return 0;
 
-err:
+out_xsk:
+	xsk_socket__delete(rxq->xsk);
+out_umem:
 	xdp_umem_destroy(rxq->umem);
 
 	return ret;
-- 
2.17.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 19.11] net/af_xdp: ensure socket is deleted on Rx queue setup error
  2022-03-10 10:07 [PATCH 19.11] net/af_xdp: ensure socket is deleted on Rx queue setup error Ciara Loftus
@ 2022-03-10 10:42 ` Christian Ehrhardt
  0 siblings, 0 replies; 2+ messages in thread
From: Christian Ehrhardt @ 2022-03-10 10:42 UTC (permalink / raw)
  To: Ciara Loftus; +Cc: stable

On Thu, Mar 10, 2022 at 11:07 AM Ciara Loftus <ciara.loftus@intel.com> wrote:
>
> [ upstream commit b26431a617e4039e6c0f65c5ee56f62f347b686b ]
>
> During Rx queue setup the PMD attempts to allocate mbufs for the fill
> queue after the socket is created. If this allocation fails, the socket
> should be deleted before returning an error to the user. Fix this.
>
> Fixes: d8a210774e1d ("net/af_xdp: support unaligned umem chunks")
>
> Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>

Thank you Ciara, applied

> ---
>  drivers/net/af_xdp/rte_eth_af_xdp.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
> index 9eae705caa..9b36d80335 100644
> --- a/drivers/net/af_xdp/rte_eth_af_xdp.c
> +++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
> @@ -898,26 +898,27 @@ xsk_configure(struct pmd_internals *internals, struct pkt_rx_queue *rxq,
>                         &txq->tx, &cfg);
>         if (ret) {
>                 AF_XDP_LOG(ERR, "Failed to create xsk socket.\n");
> -               goto err;
> +               goto out_umem;
>         }
>
>  #if defined(XDP_UMEM_UNALIGNED_CHUNK_FLAG)
>         ret = rte_pktmbuf_alloc_bulk(rxq->umem->mb_pool, fq_bufs, reserve_size);
>         if (ret) {
>                 AF_XDP_LOG(DEBUG, "Failed to get enough buffers for fq.\n");
> -               goto err;
> +               goto out_xsk;
>         }
>  #endif
>         ret = reserve_fill_queue(rxq->umem, reserve_size, fq_bufs);
>         if (ret) {
> -               xsk_socket__delete(rxq->xsk);
>                 AF_XDP_LOG(ERR, "Failed to reserve fill queue.\n");
> -               goto err;
> +               goto out_xsk;
>         }
>
>         return 0;
>
> -err:
> +out_xsk:
> +       xsk_socket__delete(rxq->xsk);
> +out_umem:
>         xdp_umem_destroy(rxq->umem);
>
>         return ret;
> --
> 2.17.1
>


-- 
Christian Ehrhardt
Staff Engineer, Ubuntu Server
Canonical Ltd

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-10 10:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-10 10:07 [PATCH 19.11] net/af_xdp: ensure socket is deleted on Rx queue setup error Ciara Loftus
2022-03-10 10:42 ` Christian Ehrhardt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).