From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 177CBA0527; Wed, 25 Nov 2020 10:46:55 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6F223C940; Wed, 25 Nov 2020 10:46:53 +0100 (CET) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id D7A86C93C; Wed, 25 Nov 2020 10:46:50 +0100 (CET) IronPort-SDR: W6hx7RwGuCQn/4GKSqWeCF3uB7ezDpERnfX4veMbexWH8gogrmt+Iguj+f7/cPuZ1lpnDr40xe B+EgqrUbgoSA== X-IronPort-AV: E=McAfee;i="6000,8403,9815"; a="151938564" X-IronPort-AV: E=Sophos;i="5.78,368,1599548400"; d="scan'208";a="151938564" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Nov 2020 01:46:49 -0800 IronPort-SDR: E7rUT+RfJvypL5Ye97DrXVzvU8o5457CaPIfrODpaYMZ4464hJaXBA8aChQ7q3X/ujtx0wUiPu d2K/ygG/VOMw== X-IronPort-AV: E=Sophos;i="5.78,368,1599548400"; d="scan'208";a="536830518" Received: from shwdenpg235.ccr.corp.intel.com ([10.240.182.60]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Nov 2020 01:46:47 -0800 From: "Zhang,Alvin" To: cunming.liang@intel.com Cc: dev@dpdk.org, Alvin Zhang , stable@dpdk.org Date: Wed, 25 Nov 2020 17:46:22 +0800 Message-Id: <20201125094622.12064-1-alvinx.zhang@intel.com> X-Mailer: git-send-email 2.21.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] test: fix buffer overflow 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" From: Alvin Zhang The Tx buffer may overflow when there is more than one port. Signed-off-by: Alvin Zhang Fixes: 002ade70e933 ("app/test: measure cycles per packet in Rx/Tx") Cc: stable@dpdk.org --- app/test/test_pmd_perf.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/app/test/test_pmd_perf.c b/app/test/test_pmd_perf.c index 4db816a..3a248d5 100644 --- a/app/test/test_pmd_perf.c +++ b/app/test/test_pmd_perf.c @@ -606,10 +606,10 @@ enum { static int exec_burst(uint32_t flags, int lcore) { - unsigned i, portid, nb_tx = 0; + unsigned int portid, nb_tx = 0; struct lcore_conf *conf; uint32_t pkt_per_port; - int num, idx = 0; + int num, i, idx = 0; int diff_tsc; conf = &lcore_conf[lcore]; @@ -628,16 +628,14 @@ enum { rte_atomic64_set(&start, 1); /* start xmit */ + i = 0; while (num) { nb_tx = RTE_MIN(MAX_PKT_BURST, num); - for (i = 0; i < conf->nb_ports; i++) { - portid = conf->portlist[i]; - nb_tx = rte_eth_tx_burst(portid, 0, - &tx_burst[idx], nb_tx); - idx += nb_tx; - num -= nb_tx; - } - + portid = conf->portlist[i]; + nb_tx = rte_eth_tx_burst(portid, 0, &tx_burst[idx], nb_tx); + idx += nb_tx; + num -= nb_tx; + i = (i >= conf->nb_ports - 1) ? 0 : (i + 1); } sleep(5); -- 1.8.3.1