DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] app/test: fix reorder test failure
@ 2018-05-03 15:42 Reshma Pattan
  2018-05-03 15:49 ` Hunt, David
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Reshma Pattan @ 2018-05-03 15:42 UTC (permalink / raw)
  To: dev; +Cc: stable, david.hunt, Reshma Pattan

Inside test_reorder_insert()
rte_mempool_get_bulk() and rte_mempool_put_bulk() are used
to allocate and free the mbufs and then rte_reorder_free()
is called which again freeing the mbufs using rte_pktmbuf_free().

The mixed use of rte_mempool_put_bulk() and rte_pktmbuf_free()
causing duplicate mbufs to be created when rte_mempool_get_bulk()
is called next in test_reorder_drain().

Since reorder library is taking care of freeing the mbufs
using rte_pktmbuf_free() change UT to allocate mbufs using
rte_pktmbuf_alloc().

Do not mix and match the bulk get/put APIs with
alloc/free APIs which can cause undefined behavior.

Fixes: d0c9b58d71 ("app/test: new reorder unit test")
Cc: stable@dpdk.org
Cc: david.hunt@intel.com
Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>
---
 test/test/test_reorder.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/test/test/test_reorder.c b/test/test/test_reorder.c
index 65e4f38b2..b79b00961 100644
--- a/test/test/test_reorder.c
+++ b/test/test/test_reorder.c
@@ -146,11 +146,11 @@ test_reorder_insert(void)
 	b = rte_reorder_create("test_insert", rte_socket_id(), size);
 	TEST_ASSERT_NOT_NULL(b, "Failed to create reorder buffer");
 
-	ret = rte_mempool_get_bulk(p, (void *)bufs, num_bufs);
-	TEST_ASSERT_SUCCESS(ret, "Error getting mbuf from pool");
-
-	for (i = 0; i < num_bufs; i++)
+	for (i = 0; i < num_bufs; i++) {
+		bufs[i] = rte_pktmbuf_alloc(p);
+		TEST_ASSERT_NOT_NULL(bufs[i], "Packet allocation failed\n");
 		bufs[i]->seqn = i;
+	}
 
 	/* This should fill up order buffer:
 	 * reorder_seq = 0
@@ -202,7 +202,6 @@ test_reorder_insert(void)
 
 	ret = 0;
 exit:
-	rte_mempool_put_bulk(p, (void *)bufs, num_bufs);
 	rte_reorder_free(b);
 	return ret;
 }
@@ -227,9 +226,6 @@ test_reorder_drain(void)
 	b = rte_reorder_create("test_drain", rte_socket_id(), size);
 	TEST_ASSERT_NOT_NULL(b, "Failed to create reorder buffer");
 
-	ret = rte_mempool_get_bulk(p, (void *)bufs, num_bufs);
-	TEST_ASSERT_SUCCESS(ret, "Error getting mbuf from pool");
-
 	/* Check no drained packets if reorder is empty */
 	cnt = rte_reorder_drain(b, robufs, 1);
 	if (cnt != 0) {
@@ -239,8 +235,11 @@ test_reorder_drain(void)
 		goto exit;
 	}
 
-	for (i = 0; i < num_bufs; i++)
+	for (i = 0; i < num_bufs; i++) {
+		bufs[i] = rte_pktmbuf_alloc(p);
+		TEST_ASSERT_NOT_NULL(bufs[i], "Packet allocation failed\n");
 		bufs[i]->seqn = i;
+	}
 
 	/* Insert packet with seqn 1:
 	 * reorder_seq = 0
@@ -298,7 +297,6 @@ test_reorder_drain(void)
 	}
 	ret = 0;
 exit:
-	rte_mempool_put_bulk(p, (void *)bufs, num_bufs);
 	rte_reorder_free(b);
 	return ret;
 }
-- 
2.14.3

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

end of thread, other threads:[~2018-05-13 21:17 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-03 15:42 [dpdk-dev] [PATCH] app/test: fix reorder test failure Reshma Pattan
2018-05-03 15:49 ` Hunt, David
2018-05-03 15:53   ` Pattan, Reshma
2018-05-03 15:58     ` Hunt, David
2018-05-03 16:03 ` Hunt, David
2018-05-03 16:30 ` [dpdk-dev] [PATCH v2] " Reshma Pattan
2018-05-03 16:36   ` [dpdk-dev] [PATCH v3] " Reshma Pattan
2018-05-03 17:02     ` Hunt, David
2018-05-04 10:47     ` [dpdk-dev] [PATCH v4] " Reshma Pattan
2018-05-13 21:17       ` Thomas Monjalon
2018-05-03 16:35 ` [dpdk-dev] [PATCH v3] " Reshma Pattan

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