[PATCH 19.11] net/af_xdp: ensure socket is deleted on Rx queue setup error

Christian Ehrhardt christian.ehrhardt at canonical.com
Thu Mar 10 11:42:06 CET 2022


On Thu, Mar 10, 2022 at 11:07 AM Ciara Loftus <ciara.loftus at 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 at 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


More information about the stable mailing list