[dpdk-dev] app/testpmd: fix invalid port ID

Message ID 1481613068-92744-1-git-send-email-wenzhuo.lu@intel.com (mailing list archive)
State Accepted, archived
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel compilation success Compilation OK

Commit Message

Wenzhuo Lu Dec. 13, 2016, 7:11 a.m. UTC
  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 <wenzhuo.lu@intel.com>
Signed-off-by: Chen Jing D(Mark) <jing.d.chen@intel.com>
---
CC: stable@dpdk.org
---
 app/test-pmd/cmdline.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
  

Comments

Jingjing Wu Dec. 19, 2016, 1:24 a.m. UTC | #1
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Wenzhuo Lu
> Sent: Tuesday, December 13, 2016 3:11 PM
> To: dev@dpdk.org
> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Chen, Jing D
> <jing.d.chen@intel.com>; stable@dpdk.org
> Subject: [dpdk-dev] [PATCH] app/testpmd: fix invalid port ID
> 
> 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 <wenzhuo.lu@intel.com>
> Signed-off-by: Chen Jing D(Mark) <jing.d.chen@intel.com>

> ---
> CC: stable@dpdk.org

Acked-by: Jingjing Wu <jingjing.wu@intel.com>
  
Thomas Monjalon Jan. 17, 2017, 3:40 p.m. UTC | #2
> > 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 <wenzhuo.lu@intel.com>
> > Signed-off-by: Chen Jing D(Mark) <jing.d.chen@intel.com>
> 
> > ---
> > CC: stable@dpdk.org
> 
> Acked-by: Jingjing Wu <jingjing.wu@intel.com>

Applied, thanks
  

Patch

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 63b55dc..315a252 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -10807,6 +10807,9 @@  struct cmd_vf_vlan_anti_spoof_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_vf_vlan_anti_spoof(res->port_id, res->vf_id,
 			is_on);
 	switch (ret) {
@@ -10892,6 +10895,9 @@  struct cmd_vf_mac_anti_spoof_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_mac_anti_spoof(res->port_id, res->vf_id,
 			is_on);
 	switch (ret) {
@@ -10977,6 +10983,9 @@  struct cmd_vf_vlan_stripq_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_vf_vlan_stripq(res->port_id, res->vf_id, is_on);
 	switch (ret) {
 	case 0:
@@ -11060,6 +11069,9 @@  struct cmd_vf_vlan_insert_result {
 	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:
@@ -11134,6 +11146,9 @@  struct cmd_tx_loopback_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_tx_loopback(res->port_id, is_on);
 	switch (ret) {
 	case 0:
@@ -11211,6 +11226,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:
@@ -11294,6 +11312,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) {
@@ -11378,6 +11399,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) {