From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 9CF2211A2 for ; Mon, 9 Mar 2015 04:49:57 +0100 (CET) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP; 08 Mar 2015 20:49:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,365,1422950400"; d="scan'208";a="537865038" Received: from pgsmsx103.gar.corp.intel.com ([10.221.44.82]) by orsmga003.jf.intel.com with ESMTP; 08 Mar 2015 20:49:29 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by PGSMSX103.gar.corp.intel.com (10.221.44.82) with Microsoft SMTP Server (TLS) id 14.3.195.1; Mon, 9 Mar 2015 11:49:54 +0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.192]) by shsmsx102.ccr.corp.intel.com ([169.254.2.62]) with mapi id 14.03.0195.001; Mon, 9 Mar 2015 11:49:53 +0800 From: "Qiu, Michael" To: Tetsuya Mukawa , "De Lara Guarch, Pablo" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] testpmd: Fix port validation code of "port stop all" command Thread-Index: AQHQVxZUkeUi1+JMQE6Z/J1a0wvVMQ== Date: Mon, 9 Mar 2015 03:49:53 +0000 Message-ID: <533710CFB86FA344BFBF2D6802E60286CF051C@SHSMSX101.ccr.corp.intel.com> References: <1425540606-12554-1-git-send-email-mukawa@igel.co.jp> <533710CFB86FA344BFBF2D6802E60286CEEEC5@SHSMSX101.ccr.corp.intel.com> <54FD03FC.4010807@igel.co.jp> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] testpmd: Fix port validation code of "port stop all" command X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Mar 2015 03:49:58 -0000 On 3/9/2015 10:22 AM, Tetsuya Mukawa wrote:=0A= > On 2015/03/06 22:53, De Lara Guarch, Pablo wrote:=0A= >> Hi Michael,=0A= >>=0A= >>> -----Original Message-----=0A= >>> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Qiu, Michael=0A= >>> Sent: Thursday, March 05, 2015 1:33 PM=0A= >>> To: Tetsuya Mukawa; dev@dpdk.org=0A= >>> Subject: Re: [dpdk-dev] [PATCH] testpmd: Fix port validation code of "p= ort=0A= >>> stop all" command=0A= >>>=0A= >>> Hi, Tetsuya and Pablo=0A= >>> This is not a full fix, I have generate the full fix patch two days ago= ,=0A= > Hi Michel,=0A= >=0A= > I am sorry for late replying, and thanks for your work.=0A= >=0A= >> Sorry I did not see this earlier. Did you upstream this patch already?= =0A= >> I acked Tetsuya's patch, as it was simple and works, but I cannot find= =0A= >> this one.=0A= >>=0A= >> Thanks,=0A= >> Pablo=0A= >>=0A= >>> See below:=0A= >>>=0A= >>> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c=0A= >>> index 49be819..ec53923 100644=0A= >>> --- a/app/test-pmd/config.c=0A= >>> +++ b/app/test-pmd/config.c=0A= >>> @@ -384,6 +384,9 @@ port_infos_display(portid_t port_id)=0A= >>> int=0A= >>> port_id_is_invalid(portid_t port_id, enum print_warning warning)=0A= >>> {=0A= >>> + if (port_id =3D=3D (portid_t)RTE_PORT_ALL)=0A= >>> + return 0;=0A= >>> +=0A= > I am not clearly sure that we need to add above 'if statement'.=0A= =0A= Because some times RTE_PORT_ALL will pass to port start/stop/close, but=0A= the check will be invalid.=0A= =0A= Actually, we should see it as valid, then all port valid check will work=0A= for start/stop/close action=0A= =0A= >=0A= >>> if (ports[port_id].enabled)=0A= >>> return 0;=0A= >>>=0A= >>> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c=0A= >>> index e556b4c..1c4c651 100644=0A= >>> --- a/app/test-pmd/testpmd.c=0A= >>> +++ b/app/test-pmd/testpmd.c=0A= >>> @@ -1326,6 +1326,9 @@ start_port(portid_t pid)=0A= >>> return -1;=0A= >>> }=0A= >>>=0A= >>> + if (port_id_is_invalid(pid, ENABLED_WARN))=0A= >>> + return 0;=0A= >>> +=0A= > Same as above.=0A= >=0A= >>> if (init_fwd_streams() < 0) {=0A= >>> printf("Fail from init_fwd_streams()\n");=0A= >>> return -1;=0A= >>> @@ -1482,10 +1485,14 @@ stop_port(portid_t pid)=0A= >>> dcb_test =3D 0;=0A= >>> dcb_config =3D 0;=0A= >>> }=0A= >>> +=0A= >>> + if (port_id_is_invalid(pid, ENABLED_WARN))=0A= >>> + return;=0A= >>> +=0A= > Same as above.=0A= >=0A= >>> printf("Stopping ports...\n");=0A= >>>=0A= >>> FOREACH_PORT(pi, ports) {=0A= >>> - if (!port_id_is_invalid(pid, DISABLED_WARN) && pid !=3D= pi)=0A= >>> + if (pid !=3D pi && pid !=3D (portid_t)RTE_PORT_ALL)=0A= >>> continue;=0A= >>>=0A= >>> port =3D &ports[pi];=0A= >>> @@ -1517,10 +1524,13 @@ close_port(portid_t pid)=0A= >>> return;=0A= >>> }=0A= >>>=0A= >>> + if (port_id_is_invalid(pid, ENABLED_WARN))=0A= >>> + return;=0A= >>> +=0A= > Same as above.=0A= >=0A= >>> printf("Closing ports...\n");=0A= >>>=0A= >>> FOREACH_PORT(pi, ports) {=0A= >>> - if (!port_id_is_invalid(pid, DISABLED_WARN) && pid !=3D= pi)=0A= >>> + if (pid !=3D pi && pid !=3D (portid_t)RTE_PORT_ALL)=0A= >>> continue;=0A= >>>=0A= >>> port =3D &ports[pi];=0A= >>> --=0A= >>> 1.9.3=0A= > FOREACH_PORT() returns valid ports, so is it not enough to check like abo= ve?=0A= > I am not clearly understand which case we need to add above extra if=0A= > statements.=0A= > Could you please describe?=0A= =0A= Yes, just consider this situation, the valid port number are [0, 1],=0A= but you try to to stop prot number 2, what will happen?=0A= =0A= Noting will be show, at least we need an error log.=0A= =0A= So it must be check.=0A= =0A= Thanks,=0A= Michael=0A= > But I agree we cannot use my previous patch.=0A= > We need to fix not only stop_port() but also close_port() like start_port= ().=0A= >=0A= > Thanks,=0A= > Tetsuya=0A= >=0A= >>> Thanks,=0A= >>> Michael=0A= >>>=0A= >>> On 3/5/2015 3:31 PM, Tetsuya Mukawa wrote:=0A= >>>> When "port stop all" is executed, the command doesn't work as it shoul= d=0A= >>>> because of wrong port validation. The patch fixes this issue.=0A= >>>>=0A= >>>> Reported-by: Pablo de Lara =0A= >>>> Signed-off-by: Tetsuya Mukawa =0A= >>>> ---=0A= >>>> app/test-pmd/testpmd.c | 2 +-=0A= >>>> 1 file changed, 1 insertion(+), 1 deletion(-)=0A= >>>>=0A= >>>> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c=0A= >>>> index 61291be..bb65342 100644=0A= >>>> --- a/app/test-pmd/testpmd.c=0A= >>>> +++ b/app/test-pmd/testpmd.c=0A= >>>> @@ -1484,7 +1484,7 @@ stop_port(portid_t pid)=0A= >>>> printf("Stopping ports...\n");=0A= >>>>=0A= >>>> FOREACH_PORT(pi, ports) {=0A= >>>> - if (!port_id_is_invalid(pid, DISABLED_WARN) && pid !=3D pi)=0A= >>>> + if (pid !=3D pi && pid !=3D (portid_t)RTE_PORT_ALL)=0A= >>>> continue;=0A= >>>>=0A= >>>> port =3D &ports[pi];=0A= >=0A= >=0A= =0A=