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 239AB2C60 for ; Wed, 7 Dec 2016 04:32:52 +0100 (CET) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP; 06 Dec 2016 19:32:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,310,1477983600"; d="scan'208";a="909513422" Received: from dpdk26.sh.intel.com ([10.239.128.228]) by orsmga003.jf.intel.com with ESMTP; 06 Dec 2016 19:32:51 -0800 From: Wenzhuo Lu To: dev@dpdk.org Cc: Wenzhuo Lu , "Chen Jing D(Mark)" Date: Wed, 7 Dec 2016 11:32:15 +0800 Message-Id: <1481081535-37448-33-git-send-email-wenzhuo.lu@intel.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1481081535-37448-1-git-send-email-wenzhuo.lu@intel.com> References: <1480637533-37425-1-git-send-email-wenzhuo.lu@intel.com> <1481081535-37448-1-git-send-email-wenzhuo.lu@intel.com> Subject: [dpdk-dev] [PATCH v2 32/32] app/testpmd: fix invalid port ID X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Dec 2016 03:32:53 -0000 Some CLIs don't check the input port ID, it may cause segmentation fault (core dumped). Fixes: 425781ff5afe ("app/testpmd: add ixgbe VF management") Signed-off-by: Wenzhuo Lu Signed-off-by: Chen Jing D(Mark) --- app/test-pmd/cmdline.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index e1a7e02..be0c424 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -10829,6 +10829,9 @@ struct cmd_vf_vlan_anti_spoof_result { int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; struct rte_eth_dev_info dev_info; + if (port_id_is_invalid(res->port_id, ENABLED_WARN)) + return; + memset(&dev_info, 0, sizeof(dev_info)); rte_eth_dev_info_get(res->port_id, &dev_info); @@ -10930,6 +10933,9 @@ struct cmd_vf_mac_anti_spoof_result { int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; struct rte_eth_dev_info dev_info; + if (port_id_is_invalid(res->port_id, ENABLED_WARN)) + return; + memset(&dev_info, 0, sizeof(dev_info)); rte_eth_dev_info_get(res->port_id, &dev_info); @@ -11031,6 +11037,9 @@ struct cmd_vf_vlan_stripq_result { int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; struct rte_eth_dev_info dev_info; + if (port_id_is_invalid(res->port_id, ENABLED_WARN)) + return; + memset(&dev_info, 0, sizeof(dev_info)); rte_eth_dev_info_get(res->port_id, &dev_info); @@ -11129,6 +11138,9 @@ struct cmd_vf_vlan_insert_result { int ret; struct rte_eth_dev_info dev_info; + if (port_id_is_invalid(res->port_id, ENABLED_WARN)) + return; + memset(&dev_info, 0, sizeof(dev_info)); rte_eth_dev_info_get(res->port_id, &dev_info); @@ -11218,6 +11230,9 @@ struct cmd_tx_loopback_result { int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; struct rte_eth_dev_info dev_info; + if (port_id_is_invalid(res->port_id, ENABLED_WARN)) + return; + memset(&dev_info, 0, sizeof(dev_info)); rte_eth_dev_info_get(res->port_id, &dev_info); @@ -11307,6 +11322,9 @@ struct cmd_all_queues_drop_en_result { int ret = 0; int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; + if (port_id_is_invalid(res->port_id, ENABLED_WARN)) + return; + ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on); switch (ret) { case 0: @@ -11390,6 +11408,9 @@ struct cmd_vf_split_drop_en_result { int ret; int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; + if (port_id_is_invalid(res->port_id, ENABLED_WARN)) + return; + ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id, is_on); switch (ret) { @@ -11474,6 +11495,9 @@ struct cmd_set_vf_mac_addr_result { struct cmd_set_vf_mac_addr_result *res = parsed_result; int ret; + if (port_id_is_invalid(res->port_id, ENABLED_WARN)) + return; + ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id, &res->mac_addr); switch (ret) { -- 1.9.3