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 A47C0A0A02; Fri, 15 Jan 2021 09:59:29 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 59B1E140E12; Fri, 15 Jan 2021 09:59:29 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id 2D7ED140E10; Fri, 15 Jan 2021 09:59:26 +0100 (CET) IronPort-SDR: iTAm3gZzdA/I35NeYqCOXE8g5YeWTPvoRq7XmYhk0yOgoqU+iE+nYPJ53V+CdK4IYBl/Aov1Ag rc4fcjaa8BQw== X-IronPort-AV: E=McAfee;i="6000,8403,9864"; a="197185161" X-IronPort-AV: E=Sophos;i="5.79,349,1602572400"; d="scan'208";a="197185161" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jan 2021 00:59:22 -0800 IronPort-SDR: 0fSx8tlB3ZDkf03xE2lzaemQbpIO3y5OpYOR86fpGjR7buws793AaYhPdwIe7s2TtIRYCsn7gg LJzcHQecjl4w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.79,349,1602572400"; d="scan'208";a="425243913" Received: from fmsmsx604.amr.corp.intel.com ([10.18.126.84]) by orsmga001.jf.intel.com with ESMTP; 15 Jan 2021 00:59:20 -0800 Received: from shsmsx603.ccr.corp.intel.com (10.109.6.143) by fmsmsx604.amr.corp.intel.com (10.18.126.84) 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:59:19 -0800 Received: from shsmsx601.ccr.corp.intel.com (10.109.6.141) by SHSMSX603.ccr.corp.intel.com (10.109.6.143) 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:59:18 +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:59:17 +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/3jDaCRBK2aka4UOF7J7MWcaooqp8ggAAHr0A= Date: Fri, 15 Jan 2021 08:59:17 +0000 Message-ID: <75f952994d984b3e80d80d97c872492a@intel.com> References: <20201125094622.12064-1-alvinx.zhang@intel.com> In-Reply-To: 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" Acked-by: Jeff Guo > -----Original Message----- > From: Guo, Jia > Sent: Friday, January 15, 2021 4:31 PM > To: 'Zhang,Alvin' ; Liang, Cunming > > Cc: dev@dpdk.org; Zhang, AlvinX ; > stable@dpdk.org > Subject: RE: [dpdk-dev] [PATCH] test: fix buffer overflow >=20 > Hi, Alvin >=20 > > -----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 > > > > 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 =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; > > > > conf =3D &lcore_conf[lcore]; > > @@ -628,16 +628,14 @@ enum { > > rte_atomic64_set(&start, 1); > > > > /* 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); >=20 > If conf->nb_ports =3D 1, after the above assign, the i should be 1 and is= that > your expected? Please ignore above comment, this code should be works. >=20 > > } > > > > sleep(5); > > -- > > 1.8.3.1