From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 23F57A0A02; Fri, 15 Jan 2021 09:31:24 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9BB8E140DD4; Fri, 15 Jan 2021 09:31:23 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id 52EE7140DCD; Fri, 15 Jan 2021 09:31:20 +0100 (CET) IronPort-SDR: Q+gPHjjGN0BnW2LxZSeJmQ/b+MVsGt5oXHiZRf2LlqbKcFnUFgR2i6ghSZqKhbYnT3EpHjn6BD 5zMuUyrq7P+g== X-IronPort-AV: E=McAfee;i="6000,8403,9864"; a="242587829" X-IronPort-AV: E=Sophos;i="5.79,348,1602572400"; d="scan'208";a="242587829" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jan 2021 00:31:10 -0800 IronPort-SDR: bKeBmT7qkL4JRIVhDSIj9npp1+3htXRKATGU5vBr8FNxVQMowgdz2+tvUU1YWfRvCxmCBscCYD 37m2XXPo6hPA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.79,348,1602572400"; d="scan'208";a="349425735" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga003.jf.intel.com with ESMTP; 15 Jan 2021 00:31:09 -0800 Received: from shsmsx605.ccr.corp.intel.com (10.109.6.215) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Fri, 15 Jan 2021 00:31:09 -0800 Received: from shsmsx601.ccr.corp.intel.com (10.109.6.141) by SHSMSX605.ccr.corp.intel.com (10.109.6.215) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Fri, 15 Jan 2021 16:31:07 +0800 Received: from shsmsx601.ccr.corp.intel.com ([10.109.6.141]) by SHSMSX601.ccr.corp.intel.com ([10.109.6.141]) with mapi id 15.01.1713.004; Fri, 15 Jan 2021 16:31:07 +0800 From: "Guo, Jia" To: "Zhang, AlvinX" , "Liang, Cunming" CC: "dev@dpdk.org" , "Zhang, AlvinX" , "stable@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] test: fix buffer overflow Thread-Index: AQHWww/3jDaCRBK2aka4UOF7J7MWcaooqp8g Date: Fri, 15 Jan 2021 08:31:07 +0000 Message-ID: References: <20201125094622.12064-1-alvinx.zhang@intel.com> In-Reply-To: <20201125094622.12064-1-alvinx.zhang@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.5.1.3 x-originating-ip: [10.239.127.36] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] test: fix buffer overflow X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" Hi, Alvin > -----Original Message----- > From: dev On Behalf Of Zhang,Alvin > Sent: Wednesday, November 25, 2020 5:46 PM > To: Liang, Cunming > Cc: dev@dpdk.org; Zhang, AlvinX ; > stable@dpdk.org > Subject: [dpdk-dev] [PATCH] test: fix buffer overflow >=20 > From: Alvin Zhang >=20 > The Tx buffer may overflow when there is more than one port. >=20 > Signed-off-by: Alvin Zhang >=20 > 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(-) >=20 > 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 =3D 0; > + unsigned int portid, nb_tx =3D 0; > struct lcore_conf *conf; > uint32_t pkt_per_port; > - int num, idx =3D 0; > + int num, i, idx =3D 0; > int diff_tsc; >=20 > conf =3D &lcore_conf[lcore]; > @@ -628,16 +628,14 @@ enum { > rte_atomic64_set(&start, 1); >=20 > /* start xmit */ > + i =3D 0; > while (num) { > nb_tx =3D RTE_MIN(MAX_PKT_BURST, num); > - for (i =3D 0; i < conf->nb_ports; i++) { > - portid =3D conf->portlist[i]; > - nb_tx =3D rte_eth_tx_burst(portid, 0, > - &tx_burst[idx], nb_tx); > - idx +=3D nb_tx; > - num -=3D nb_tx; > - } > - > + portid =3D conf->portlist[i]; > + nb_tx =3D rte_eth_tx_burst(portid, 0, &tx_burst[idx], nb_tx); > + idx +=3D nb_tx; > + num -=3D nb_tx; > + i =3D (i >=3D conf->nb_ports - 1) ? 0 : (i + 1); If conf->nb_ports =3D 1, after the above assign, the i should be 1 and is t= hat your expected? > } >=20 > sleep(5); > -- > 1.8.3.1