From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 060495FEB for ; Mon, 9 Mar 2015 07:01:19 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP; 08 Mar 2015 22:59:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,365,1422950400"; d="scan'208";a="464458620" Received: from pgsmsx108.gar.corp.intel.com ([10.221.44.103]) by FMSMGA003.fm.intel.com with ESMTP; 08 Mar 2015 22:54:41 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by PGSMSX108.gar.corp.intel.com (10.221.44.103) with Microsoft SMTP Server (TLS) id 14.3.195.1; Mon, 9 Mar 2015 14:01:16 +0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.192]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.197]) with mapi id 14.03.0195.001; Mon, 9 Mar 2015 14:01:09 +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 06:01:08 +0000 Message-ID: <533710CFB86FA344BFBF2D6802E60286CF0601@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> <533710CFB86FA344BFBF2D6802E60286CF051C@SHSMSX101.ccr.corp.intel.com> <54FD2DD7.5020604@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 06:01:20 -0000 On 3/9/2015 1:21 PM, Tetsuya Mukawa wrote:=0A= > On 2015/03/09 12:49, Qiu, Michael wrote:=0A= >> 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 = "port=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 a= go,=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= >> 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= >>>>> 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 a= bove?=0A= >>> I am not clearly understand which case we need to add above extra if=0A= >>> statements.=0A= >>> Could you please describe?=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= > Hi Michael,=0A= >=0A= > Thanks, I've understood it.=0A= > Have you already submitted it as patch?=0A= > I could not find it in patchwork.=0A= > I will send an ack to your patch.=0A= =0A= I have not send yet,=0A= =0A= I will send out now and add will add you in cc list.=0A= =0A= Thanks,=0A= Michael=0A= > Thanks,=0A= > Tetsuya=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_po= rt().=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 sho= uld=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=