]> git.droids-corp.org - dpdk.git/commitdiff
net/af_xdp: ensure socket is deleted on Rx queue setup error
authorCiara Loftus <ciara.loftus@intel.com>
Fri, 18 Feb 2022 11:20:36 +0000 (11:20 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 18 Feb 2022 18:47:52 +0000 (19:47 +0100)
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: d8a210774e1d ("net/af_xdp: support unaligned umem chunks")
Fixes: 288a85aef192 ("net/af_xdp: enable custom XDP program loading")
Fixes: 055a393626ed ("net/af_xdp: prefer busy polling")
Fixes: 01fa83c94d7e ("net/af_xdp: workaround custom program loading")
Cc: stable@dpdk.org
Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
drivers/net/af_xdp/rte_eth_af_xdp.c

index 2477f31c7b273c7c1ab1df0db99b4c58a8387b1c..7d5e2887b8be045be5bfc2c02672a2e85e86aa72 100644 (file)
@@ -1301,7 +1301,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;
                cfg.libbpf_flags = XSK_LIBBPF_FLAGS__INHIBIT_PROG_LOAD;
@@ -1318,7 +1318,7 @@ 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;
        }
 
        /* insert the xsk into the xsks_map */
@@ -1330,7 +1330,7 @@ xsk_configure(struct pmd_internals *internals, struct pkt_rx_queue *rxq,
                                          &rxq->xsk_queue_idx, &fd, 0);
                if (err) {
                        AF_XDP_LOG(ERR, "Failed to insert xsk in map.\n");
-                       goto err;
+                       goto out_xsk;
                }
        }
 
@@ -1338,7 +1338,7 @@ xsk_configure(struct pmd_internals *internals, struct pkt_rx_queue *rxq,
        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
 
@@ -1346,20 +1346,21 @@ xsk_configure(struct pmd_internals *internals, struct pkt_rx_queue *rxq,
                ret = configure_preferred_busy_poll(rxq);
                if (ret) {
                        AF_XDP_LOG(ERR, "Failed configure busy polling.\n");
-                       goto err;
+                       goto out_xsk;
                }
        }
 
        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);