From: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
To: reshma.pattan@intel.com
Cc: dev@dpdk.org, Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
Subject: [dpdk-dev] [PATCH 2/2] test/reorder: fix reorder drain test
Date: Tue, 12 Sep 2017 20:36:04 +0530 [thread overview]
Message-ID: <1505228764-9738-2-git-send-email-pbhagavatula@caviumnetworks.com> (raw)
In-Reply-To: <1505228764-9738-1-git-send-email-pbhagavatula@caviumnetworks.com>
The reorder drain test fails due to mempool corruption caused by freeing
packet buffer twice.
Fixes: d0c9b58d7156 ("app/test: new reorder unit test")
Signed-off-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
---
test/test/test_reorder.c | 33 +++++++++++++++++++++++----------
1 file changed, 23 insertions(+), 10 deletions(-)
diff --git a/test/test/test_reorder.c b/test/test/test_reorder.c
index 4ec22ac..51c2dcd 100644
--- a/test/test/test_reorder.c
+++ b/test/test/test_reorder.c
@@ -70,13 +70,15 @@ test_reorder_create(void)
TEST_ASSERT((b == NULL) && (rte_errno == EINVAL),
"No error on create() with NULL name");
- b = rte_reorder_create("PKT", rte_socket_id(), REORDER_BUFFER_SIZE_INVALID);
+ b = rte_reorder_create("PKT", rte_socket_id(),
+ REORDER_BUFFER_SIZE_INVALID);
TEST_ASSERT((b == NULL) && (rte_errno == EINVAL),
"No error on create() with invalid buffer size param.");
b = rte_reorder_create("PKT_RO1", rte_socket_id(), REORDER_BUFFER_SIZE);
TEST_ASSERT_EQUAL(b, test_params->b,
- "New reorder instance created with already existing name");
+ "New reorder instance created with already existing"
+ " name");
return 0;
}
@@ -88,8 +90,8 @@ test_reorder_init(void)
unsigned int size;
/*
* The minimum memory area size that should be passed to library is,
- * sizeof(struct rte_reorder_buffer) + (2 * size * sizeof(struct rte_mbuf *));
- * Otherwise error will be thrown
+ * sizeof(struct rte_reorder_buffer) + (2 * size *
+ * sizeof(struct rte_mbuf *)); Otherwise error will be thrown
*/
size = 100;
@@ -189,15 +191,16 @@ test_reorder_insert(void)
for (i = 0; i < size; i++) {
ret = rte_reorder_insert(b, bufs[i]);
if (ret != 0) {
- printf("%s:%d: Error inserting packet with seqn less than size\n",
+ printf("%s:%d: Error inserting packet with seqn less"
+ " than size\n",
__func__, __LINE__);
ret = -1;
goto exit;
}
}
- /* early packet - should move mbufs to ready buf and move sequence window
- * reorder_seq = 4
+ /* early packet - should move mbufs to ready buf and move sequence
+ * window reorder_seq = 4
* RB[] = {0, 1, 2, 3}
* OB[] = {4, NULL, NULL, NULL}
*/
@@ -208,12 +211,14 @@ test_reorder_insert(void)
ret = -1;
goto exit;
}
+ i++;
/* early packet from current sequence window - full ready buffer */
bufs[5]->seqn = 2 * size;
ret = rte_reorder_insert(b, bufs[5]);
if (!((ret == -1) && (rte_errno == ENOSPC))) {
- printf("%s:%d: No error inserting early packet with full ready buffer\n",
+ printf("%s:%d: No error inserting early packet with full ready"
+ " buffer\n",
__func__, __LINE__);
ret = -1;
goto exit;
@@ -231,7 +236,7 @@ test_reorder_insert(void)
ret = 0;
exit:
- rte_mempool_put_bulk(p, (void *)bufs, num_bufs);
+ rte_mempool_put_bulk(p, (void **)&bufs[i], num_bufs - i);
rte_reorder_free(b);
return ret;
}
@@ -360,6 +365,13 @@ test_setup(void)
return 0;
}
+static void
+test_destroy(void)
+{
+ rte_mempool_free(test_params->p);
+ test_params->p = NULL;
+}
+
static struct unit_test_suite reorder_test_suite = {
.setup = test_setup,
@@ -372,7 +384,8 @@ static struct unit_test_suite reorder_test_suite = {
TEST_CASE(test_reorder_insert),
TEST_CASE(test_reorder_drain),
TEST_CASES_END()
- }
+ },
+ .teardown = test_destroy
};
static int
--
2.7.4
next prev parent reply other threads:[~2017-09-12 15:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-12 15:06 [dpdk-dev] [PATCH 1/2] reorder: fix ready buffers not being nulled out Pavan Nikhilesh
2017-09-12 15:06 ` Pavan Nikhilesh [this message]
2017-10-12 8:28 ` [dpdk-dev] [PATCH 2/2] test/reorder: fix reorder drain test Bruce Richardson
2017-10-11 21:04 ` [dpdk-dev] [PATCH 1/2] reorder: fix ready buffers not being nulled out Thomas Monjalon
2017-10-12 8:32 ` Bruce Richardson
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=1505228764-9738-2-git-send-email-pbhagavatula@caviumnetworks.com \
--to=pbhagavatula@caviumnetworks.com \
--cc=dev@dpdk.org \
--cc=reshma.pattan@intel.com \
/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).