From patchwork Thu May 3 15:42:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Pattan, Reshma" X-Patchwork-Id: 39322 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 492AB231E; Thu, 3 May 2018 17:42:10 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id A82F820BD; Thu, 3 May 2018 17:42:08 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 May 2018 08:42:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,359,1520924400"; d="scan'208";a="225541441" Received: from sivswdev02.ir.intel.com (HELO localhost.localdomain) ([10.237.217.46]) by fmsmga006.fm.intel.com with ESMTP; 03 May 2018 08:42:05 -0700 From: Reshma Pattan To: dev@dpdk.org Cc: stable@dpdk.org, david.hunt@intel.com, Reshma Pattan Date: Thu, 3 May 2018 16:42:03 +0100 Message-Id: <1525362123-22326-1-git-send-email-reshma.pattan@intel.com> X-Mailer: git-send-email 1.7.0.7 Subject: [dpdk-dev] [PATCH] app/test: fix reorder test failure X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- 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; }