From: Reshma Pattan <reshma.pattan@intel.com>
To: david.hunt@intel.com, dev@dpdk.org
Cc: stable@dpdk.org backport, Reshma Pattan <reshma.pattan@intel.com>
Subject: [dpdk-dev] [PATCH v2] app/test: fix reorder test failure
Date: Thu, 3 May 2018 17:30:19 +0100 [thread overview]
Message-ID: <1525365019-31371-1-git-send-email-reshma.pattan@intel.com> (raw)
In-Reply-To: <1525362123-22326-1-git-send-email-reshma.pattan@intel.com>
mbufs are being freed twice in error, once in rte_mempool_put_bulk()
and then in rte_reorder_free(). Refactor the code so that we use
rte_reorder_free() to free mbufs in the reorder buffer, and use
rte_pktmbuf_free() to free any unused or drained mbufs.
Fixes: d0c9b58d71 ("app/test: new reorder unit test")
Cc: stable@dpdk.org backport
Cc: david.hunt@intel.com
Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>
---
V2:
set mbufs to NULL after reorder insert.
simplified the commit message.
---
test/test/test_reorder.c | 36 ++++++++++++++++++++++++++----------
1 file changed, 26 insertions(+), 10 deletions(-)
diff --git a/test/test/test_reorder.c b/test/test/test_reorder.c
index 65e4f38b2..7eff718c1 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
@@ -165,6 +165,7 @@ test_reorder_insert(void)
ret = -1;
goto exit;
}
+ bufs[i] = NULL;
}
/* early packet - should move mbufs to ready buf and move sequence window
@@ -179,6 +180,7 @@ test_reorder_insert(void)
ret = -1;
goto exit;
}
+ bufs[4] = NULL;
/* early packet from current sequence window - full ready buffer */
bufs[5]->seqn = 2 * size;
@@ -189,6 +191,7 @@ test_reorder_insert(void)
ret = -1;
goto exit;
}
+ bufs[5] = NULL;
/* late packet */
bufs[6]->seqn = 3 * size;
@@ -199,11 +202,15 @@ test_reorder_insert(void)
ret = -1;
goto exit;
}
+ bufs[6] = NULL;
ret = 0;
exit:
- rte_mempool_put_bulk(p, (void *)bufs, num_bufs);
rte_reorder_free(b);
+ for (i = 0; i < num_bufs; i++) {
+ if (bufs[i] != NULL)
+ rte_pktmbuf_free(bufs[i]);
+ }
return ret;
}
@@ -227,9 +234,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 +243,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
@@ -248,6 +255,7 @@ test_reorder_drain(void)
* OB[] = {1, NULL, NULL, NULL}
*/
rte_reorder_insert(b, bufs[1]);
+ bufs[1] = NULL;
cnt = rte_reorder_drain(b, robufs, 1);
if (cnt != 1) {
@@ -263,18 +271,22 @@ test_reorder_drain(void)
*/
rte_reorder_insert(b, bufs[2]);
rte_reorder_insert(b, bufs[3]);
+ bufs[2] = NULL;
+ bufs[3] = NULL;
/* Insert more packets
* RB[] = {NULL, NULL, NULL, NULL}
* OB[] = {NULL, 2, 3, 4}
*/
rte_reorder_insert(b, bufs[4]);
+ bufs[4] = NULL;
/* Insert more packets
* RB[] = {2, 3, 4, NULL}
* OB[] = {NULL, NULL, 7, NULL}
*/
rte_reorder_insert(b, bufs[7]);
+ bufs[7] = NULL;
/* drained expected packets */
cnt = rte_reorder_drain(b, robufs, 4);
@@ -298,8 +310,12 @@ test_reorder_drain(void)
}
ret = 0;
exit:
- rte_mempool_put_bulk(p, (void *)bufs, num_bufs);
+
rte_reorder_free(b);
+ for (i = 0; i < num_bufs; i++) {
+ if (bufs[i] != NULL)
+ rte_pktmbuf_free(bufs[i]);
+ }
return ret;
}
--
2.14.3
next prev parent reply other threads:[~2018-05-03 16:30 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-03 15:42 [dpdk-dev] [PATCH] " 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 ` Reshma Pattan [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1525365019-31371-1-git-send-email-reshma.pattan@intel.com \
--to=reshma.pattan@intel.com \
--cc=david.hunt@intel.com \
--cc=dev@dpdk.org \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).