From patchwork Thu Mar 5 13:33:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Qiu X-Patchwork-Id: 3874 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 7C19E5A8A; Thu, 5 Mar 2015 14:33:16 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 296C45A85 for ; Thu, 5 Mar 2015 14:33:13 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 05 Mar 2015 05:33:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,347,1422950400"; d="scan'208";a="687341924" Received: from pgsmsx102.gar.corp.intel.com ([10.221.44.80]) by fmsmga002.fm.intel.com with ESMTP; 05 Mar 2015 05:33:11 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by PGSMSX102.gar.corp.intel.com (10.221.44.80) with Microsoft SMTP Server (TLS) id 14.3.195.1; Thu, 5 Mar 2015 21:33:11 +0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.192]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.46]) with mapi id 14.03.0195.001; Thu, 5 Mar 2015 21:33:09 +0800 From: "Qiu, Michael" To: Tetsuya Mukawa , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] testpmd: Fix port validation code of "port stop all" command Thread-Index: AQHQVxZUkeUi1+JMQE6Z/J1a0wvVMQ== Date: Thu, 5 Mar 2015 13:33:10 +0000 Message-ID: <533710CFB86FA344BFBF2D6802E60286CEEEC5@SHSMSX101.ccr.corp.intel.com> References: <1425540606-12554-1-git-send-email-mukawa@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] 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi, Tetsuya and Pablo This is not a full fix, I have generate the full fix patch two days ago, See below: diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 49be819..ec53923 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -384,6 +384,9 @@ port_infos_display(portid_t port_id) int port_id_is_invalid(portid_t port_id, enum print_warning warning) { + if (port_id == (portid_t)RTE_PORT_ALL) + return 0; + if (ports[port_id].enabled) return 0; diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index e556b4c..1c4c651 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -1326,6 +1326,9 @@ start_port(portid_t pid) return -1; } + if (port_id_is_invalid(pid, ENABLED_WARN)) + return 0; + if (init_fwd_streams() < 0) { printf("Fail from init_fwd_streams()\n"); return -1; @@ -1482,10 +1485,14 @@ stop_port(portid_t pid) dcb_test = 0; dcb_config = 0; } + + if (port_id_is_invalid(pid, ENABLED_WARN)) + return; + printf("Stopping ports...\n"); FOREACH_PORT(pi, ports) { - if (!port_id_is_invalid(pid, DISABLED_WARN) && pid != pi) + if (pid != pi && pid != (portid_t)RTE_PORT_ALL) continue; port = &ports[pi]; @@ -1517,10 +1524,13 @@ close_port(portid_t pid) return; } + if (port_id_is_invalid(pid, ENABLED_WARN)) + return; + printf("Closing ports...\n"); FOREACH_PORT(pi, ports) { - if (!port_id_is_invalid(pid, DISABLED_WARN) && pid != pi) + if (pid != pi && pid != (portid_t)RTE_PORT_ALL) continue; port = &ports[pi];