From: Wenzhuo Lu Date: Tue, 13 Dec 2016 07:11:08 +0000 (+0800) Subject: app/testpmd: fix check for invalid ports X-Git-Tag: spdx-start~5145 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=dc0537e6d6acbc27d79b7d247ca3bc7f8c20f269;p=dpdk.git app/testpmd: fix check for invalid ports 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) Acked-by: Jingjing Wu --- diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 1bf42ba724..b4f35c3794 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -10898,6 +10898,9 @@ cmd_set_vf_vlan_anti_spoof_parsed( 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_vf_vlan_anti_spoof(res->port_id, res->vf_id, is_on); switch (ret) { @@ -10983,6 +10986,9 @@ cmd_set_vf_mac_anti_spoof_parsed( 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_mac_anti_spoof(res->port_id, res->vf_id, is_on); switch (ret) { @@ -11068,6 +11074,9 @@ cmd_set_vf_vlan_stripq_parsed( 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_vf_vlan_stripq(res->port_id, res->vf_id, is_on); switch (ret) { case 0: @@ -11151,6 +11160,9 @@ cmd_set_vf_vlan_insert_parsed( struct cmd_vf_vlan_insert_result *res = parsed_result; int ret; + if (port_id_is_invalid(res->port_id, ENABLED_WARN)) + return; + ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id, res->vlan_id); switch (ret) { case 0: @@ -11225,6 +11237,9 @@ cmd_set_tx_loopback_parsed( 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_tx_loopback(res->port_id, is_on); switch (ret) { case 0: @@ -11302,6 +11317,9 @@ cmd_set_all_queues_drop_en_parsed( 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: @@ -11385,6 +11403,9 @@ cmd_set_vf_split_drop_en_parsed( 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) { @@ -11469,6 +11490,9 @@ cmd_set_vf_mac_addr_parsed( 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) {