[v3] app/testpmd: fix Segment fault when start fwd

Message ID 20190924044903.59156-1-shougangx.wang@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series [v3] app/testpmd: fix Segment fault when start fwd |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-dpdk_compile_ovs success Compile Testing PASS
ci/iol-dpdk_compile success Compile Testing PASS
ci/iol-dpdk_compile_spdk success Compile Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS

Commit Message

Shougang Wang Sept. 24, 2019, 4:49 a.m. UTC
  This patch fixed the reset function to avoid crash when user don't
call port stop, port reset functions as sequence.

Fixes: 97f1e19679 ("app/testpmd: add port reset command")
Cc: stable@dpdk.org

Signed-off-by: Wang ShougangX <shougangx.wang@intel.com>
---
 app/test-pmd/cmdline.c                      | 3 +++
 app/test-pmd/testpmd.c                      | 6 ++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 9 +++++++++
 3 files changed, 18 insertions(+)
  

Comments

Iremonger, Bernard Sept. 24, 2019, 9:09 a.m. UTC | #1
> -----Original Message-----
> From: Wang, ShougangX
> Sent: Tuesday, September 24, 2019 5:49 AM
> To: dev@dpdk.org
> Cc: Yang, Qiming <qiming.yang@intel.com>; Iremonger, Bernard
> <bernard.iremonger@intel.com>; Yigit, Ferruh <ferruh.yigit@intel.com>;
> Wang, ShougangX <shougangx.wang@intel.com>; stable@dpdk.org
> Subject: [PATCH v3] app/testpmd: fix Segment fault when start fwd
> 
> This patch fixed the reset function to avoid crash when user don't call port
> stop, port reset functions as sequence.
> 
> Fixes: 97f1e19679 ("app/testpmd: add port reset command")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Wang ShougangX <shougangx.wang@intel.com>

Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
  
Ferruh Yigit Sept. 25, 2019, 5:37 p.m. UTC | #2
On 9/24/2019 10:09 AM, Iremonger, Bernard wrote:
>> -----Original Message-----
>> From: Wang, ShougangX
>> Sent: Tuesday, September 24, 2019 5:49 AM
>> To: dev@dpdk.org
>> Cc: Yang, Qiming <qiming.yang@intel.com>; Iremonger, Bernard
>> <bernard.iremonger@intel.com>; Yigit, Ferruh <ferruh.yigit@intel.com>;
>> Wang, ShougangX <shougangx.wang@intel.com>; stable@dpdk.org
>> Subject: [PATCH v3] app/testpmd: fix Segment fault when start fwd
>>
>> This patch fixed the reset function to avoid crash when user don't call port
>> stop, port reset functions as sequence.
>>
>> Fixes: 97f1e19679 ("app/testpmd: add port reset command")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Wang ShougangX <shougangx.wang@intel.com>
> 
> Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
> 

Applied to dpdk-next-net/master, thanks.
  

Patch

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 56783aa13..9d0c3db5e 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -758,6 +758,9 @@  static void cmd_help_long_parsed(void *parsed_result,
 			"port close (port_id|all)\n"
 			"    Close all ports or port_id.\n\n"
 
+			"port reset (port_id|all)\n"
+			"    Reset all ports or port_id.\n\n"
+
 			"port attach (ident)\n"
 			"    Attach physical or virtual dev by pci address or virtual device name\n\n"
 
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index e8e2a39b6..9b7a1521a 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -2344,6 +2344,12 @@  reset_port(portid_t pid)
 	if (port_id_is_invalid(pid, ENABLED_WARN))
 		return;
 
+	if ((pid == (portid_t)RTE_PORT_ALL && !all_ports_stopped()) ||
+		(pid != (portid_t)RTE_PORT_ALL && !port_is_stopped(pid))) {
+		printf("Can not reset port(s), please stop port(s) first.\n");
+		return;
+	}
+
 	printf("Resetting ports...\n");
 
 	RTE_ETH_FOREACH_DEV(pi) {
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 313e0707e..b1a14cc4e 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -2041,6 +2041,15 @@  Close all ports or a specific port::
 
    testpmd> port close (port_id|all)
 
+port reset
+~~~~~~~~~~
+
+Reset all ports or a specific port::
+
+   testpmd> port reset (port_id|all)
+
+User should stop port(s) before resetting and (re-)start after reset.
+
 port config - queue ring size
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~