Skip to content

Commit

Permalink
net/af_xdp: ensure socket is deleted on Rx queue setup error
Browse files Browse the repository at this point in the history
[ upstream commit b26431a ]

The Rx queue setup can fail for many reasons eg. failure to setup the
custom program, failure to allocate or reserve fill queue buffers,
failure to configure busy polling etc. When a failure like one of these
occurs, if the xsk is already set up it should be deleted before
returning. This commit ensures this happens.

Fixes: d8a2107 ("net/af_xdp: support unaligned umem chunks")
Fixes: 288a85a ("net/af_xdp: enable custom XDP program loading")
Fixes: 055a393 ("net/af_xdp: prefer busy polling")
Fixes: 01fa83c ("net/af_xdp: workaround custom program loading")

Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
  • Loading branch information
cloftus authored and bluca committed Feb 28, 2022
1 parent 92f8822 commit b1b1cd7
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions drivers/net/af_xdp/rte_eth_af_xdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 +1125,7 @@ xsk_configure(struct pmd_internals *internals, struct pkt_rx_queue *rxq,
if (ret) {
AF_XDP_LOG(ERR, "Failed to load custom XDP program %s\n",
internals->prog_path);
goto err;
goto out_umem;
}
internals->custom_prog_configured = 1;
}
Expand All @@ -1141,26 +1141,27 @@ xsk_configure(struct pmd_internals *internals, struct pkt_rx_queue *rxq,

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, &rxq->fq);
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:
if (__atomic_sub_fetch(&rxq->umem->refcnt, 1, __ATOMIC_ACQUIRE) == 0)
xdp_umem_destroy(rxq->umem);

Expand Down

0 comments on commit b1b1cd7

Please sign in to comment.