DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] app/pdump: cleanup rte rings upon failures
@ 2016-07-22 13:44 Reshma Pattan
  2016-07-22 14:19 ` Ferruh Yigit
  0 siblings, 1 reply; 3+ messages in thread
From: Reshma Pattan @ 2016-07-22 13:44 UTC (permalink / raw)
  To: dev; +Cc: Reshma Pattan

Function create_mp_ring_vdev() for failure cases exits without
freeing the created rte rings, because of this pdump tool cannot be
rerun successfully. Added rte ring cleanup logic upon failures.

Fixes: caa7028276b8 ("app/pdump: add tool for packet capturing")

Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>
---
 app/pdump/main.c | 67 +++++++++++++++++++++++++++++++++++++++++---------------
 1 file changed, 49 insertions(+), 18 deletions(-)

diff --git a/app/pdump/main.c b/app/pdump/main.c
index e0ff8be..b76cfd0 100644
--- a/app/pdump/main.c
+++ b/app/pdump/main.c
@@ -525,6 +525,26 @@ free_ring_data(struct rte_ring *ring, uint8_t vdev_id,
 }
 
 static void
+cleanup_rings(void)
+{
+	int i;
+	struct pdump_tuples *pt;
+
+	for (i = 0; i < num_tuples; i++) {
+		pt = &pdump_t[i];
+
+		if (pt->device_id)
+			free(pt->device_id);
+
+		/* free the rings */
+		if (pt->rx_ring)
+			rte_ring_free(pt->rx_ring);
+		if (pt->tx_ring)
+			rte_ring_free(pt->tx_ring);
+	}
+}
+
+static void
 cleanup_pdump_resources(void)
 {
 	int i;
@@ -545,16 +565,8 @@ cleanup_pdump_resources(void)
 			free_ring_data(pt->rx_ring, pt->rx_vdev_id, &pt->stats);
 		if (pt->dir & RTE_PDUMP_FLAG_TX)
 			free_ring_data(pt->tx_ring, pt->tx_vdev_id, &pt->stats);
-
-		if (pt->device_id)
-			free(pt->device_id);
-
-		/* free the rings */
-		if (pt->rx_ring)
-			rte_ring_free(pt->rx_ring);
-		if (pt->tx_ring)
-			rte_ring_free(pt->tx_ring);
 	}
+	cleanup_rings();
 }
 
 static void
@@ -630,10 +642,12 @@ create_mp_ring_vdev(void)
 					MBUF_POOL_CACHE_SIZE, 0,
 					pt->mbuf_data_size,
 					rte_socket_id());
-			if (mbuf_pool == NULL)
+			if (mbuf_pool == NULL) {
+				cleanup_rings();
 				rte_exit(EXIT_FAILURE,
 					"Mempool creation failed: %s\n",
 					rte_strerror(rte_errno));
+			}
 		}
 		pt->mp = mbuf_pool;
 
@@ -643,19 +657,23 @@ create_mp_ring_vdev(void)
 			snprintf(ring_name, SIZE, RX_RING, i);
 			pt->rx_ring = rte_ring_create(ring_name, pt->ring_size,
 					rte_socket_id(), 0);
-			if (pt->rx_ring == NULL)
+			if (pt->rx_ring == NULL) {
+				cleanup_rings();
 				rte_exit(EXIT_FAILURE, "%s:%s:%d\n",
 						rte_strerror(rte_errno),
 						__func__, __LINE__);
+			}
 
 			/* create tx_ring */
 			snprintf(ring_name, SIZE, TX_RING, i);
 			pt->tx_ring = rte_ring_create(ring_name, pt->ring_size,
 					rte_socket_id(), 0);
-			if (pt->tx_ring == NULL)
+			if (pt->tx_ring == NULL) {
+				cleanup_rings();
 				rte_exit(EXIT_FAILURE, "%s:%s:%d\n",
 						rte_strerror(rte_errno),
 						__func__, __LINE__);
+			}
 
 			/* create vdevs */
 			(pt->rx_vdev_stream_type == IFACE) ?
@@ -663,10 +681,12 @@ create_mp_ring_vdev(void)
 			pt->rx_dev) :
 			snprintf(vdev_args, SIZE, VDEV_PCAP, RX_STR, i,
 			pt->rx_dev);
-			if (rte_eth_dev_attach(vdev_args, &portid) < 0)
+			if (rte_eth_dev_attach(vdev_args, &portid) < 0) {
+				cleanup_rings();
 				rte_exit(EXIT_FAILURE,
 					"vdev creation failed:%s:%d\n",
 					__func__, __LINE__);
+			}
 			pt->rx_vdev_id = portid;
 
 			/* configure vdev */
@@ -680,10 +700,13 @@ create_mp_ring_vdev(void)
 				pt->tx_dev) :
 				snprintf(vdev_args, SIZE, VDEV_PCAP, TX_STR, i,
 				pt->tx_dev);
-				if (rte_eth_dev_attach(vdev_args, &portid) < 0)
+				if (rte_eth_dev_attach(vdev_args,
+							&portid) < 0) {
+					cleanup_rings();
 					rte_exit(EXIT_FAILURE,
 						"vdev creation failed:"
 						"%s:%d\n", __func__, __LINE__);
+				}
 				pt->tx_vdev_id = portid;
 
 				/* configure vdev */
@@ -695,19 +718,23 @@ create_mp_ring_vdev(void)
 			snprintf(ring_name, SIZE, RX_RING, i);
 			pt->rx_ring = rte_ring_create(ring_name, pt->ring_size,
 					rte_socket_id(), 0);
-			if (pt->rx_ring == NULL)
+			if (pt->rx_ring == NULL) {
+				cleanup_rings();
 				rte_exit(EXIT_FAILURE, "%s\n",
 					rte_strerror(rte_errno));
+			}
 
 			(pt->rx_vdev_stream_type == IFACE) ?
 			snprintf(vdev_args, SIZE, VDEV_IFACE, RX_STR, i,
 				pt->rx_dev) :
 			snprintf(vdev_args, SIZE, VDEV_PCAP, RX_STR, i,
 				pt->rx_dev);
-			if (rte_eth_dev_attach(vdev_args, &portid) < 0)
+			if (rte_eth_dev_attach(vdev_args, &portid) < 0) {
+				cleanup_rings();
 				rte_exit(EXIT_FAILURE,
 					"vdev creation failed:%s:%d\n",
 					__func__, __LINE__);
+			}
 			pt->rx_vdev_id = portid;
 			/* configure vdev */
 			configure_vdev(pt->rx_vdev_id);
@@ -717,18 +744,22 @@ create_mp_ring_vdev(void)
 			snprintf(ring_name, SIZE, TX_RING, i);
 			pt->tx_ring = rte_ring_create(ring_name, pt->ring_size,
 					rte_socket_id(), 0);
-			if (pt->tx_ring == NULL)
+			if (pt->tx_ring == NULL) {
+				cleanup_rings();
 				rte_exit(EXIT_FAILURE, "%s\n",
 					rte_strerror(rte_errno));
+			}
 
 			(pt->tx_vdev_stream_type == IFACE) ?
 			snprintf(vdev_args, SIZE, VDEV_IFACE, TX_STR, i,
 				pt->tx_dev) :
 			snprintf(vdev_args, SIZE, VDEV_PCAP, TX_STR, i,
 				pt->tx_dev);
-			if (rte_eth_dev_attach(vdev_args, &portid) < 0)
+			if (rte_eth_dev_attach(vdev_args, &portid) < 0) {
+				cleanup_rings();
 				rte_exit(EXIT_FAILURE,
 					"vdev creation failed\n");
+			}
 			pt->tx_vdev_id = portid;
 
 			/* configure vdev */
-- 
2.5.0

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

* Re: [dpdk-dev] [PATCH] app/pdump: cleanup rte rings upon failures
  2016-07-22 13:44 [dpdk-dev] [PATCH] app/pdump: cleanup rte rings upon failures Reshma Pattan
@ 2016-07-22 14:19 ` Ferruh Yigit
  2016-07-22 15:58   ` Thomas Monjalon
  0 siblings, 1 reply; 3+ messages in thread
From: Ferruh Yigit @ 2016-07-22 14:19 UTC (permalink / raw)
  To: Reshma Pattan, dev

On 7/22/2016 2:44 PM, Reshma Pattan wrote:
> Function create_mp_ring_vdev() for failure cases exits without
> freeing the created rte rings, because of this pdump tool cannot be
> rerun successfully. Added rte ring cleanup logic upon failures.
> 
> Fixes: caa7028276b8 ("app/pdump: add tool for packet capturing")
> 
> Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>

Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>

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

* Re: [dpdk-dev] [PATCH] app/pdump: cleanup rte rings upon failures
  2016-07-22 14:19 ` Ferruh Yigit
@ 2016-07-22 15:58   ` Thomas Monjalon
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2016-07-22 15:58 UTC (permalink / raw)
  To: Reshma Pattan; +Cc: dev, Ferruh Yigit

2016-07-22 15:19, Ferruh Yigit:
> On 7/22/2016 2:44 PM, Reshma Pattan wrote:
> > Function create_mp_ring_vdev() for failure cases exits without
> > freeing the created rte rings, because of this pdump tool cannot be
> > rerun successfully. Added rte ring cleanup logic upon failures.
> > 
> > Fixes: caa7028276b8 ("app/pdump: add tool for packet capturing")
> > 
> > Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>
> 
> Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>

Applied, thanks

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

end of thread, other threads:[~2016-07-22 15:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-22 13:44 [dpdk-dev] [PATCH] app/pdump: cleanup rte rings upon failures Reshma Pattan
2016-07-22 14:19 ` Ferruh Yigit
2016-07-22 15:58   ` Thomas Monjalon

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).