[V2,6/6] app/testpmd: stop packet forwarding in new and destroy event

Message ID 20220915124522.5407-7-lihuisong@huawei.com (mailing list archive)
State Changes Requested, archived
Delegated to: Andrew Rybchenko
Headers
Series app/testpmd: support attach and detach port for MP |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/github-robot: build success github build: passed
ci/intel-Testing success Testing PASS

Commit Message

lihuisong (C) Sept. 15, 2022, 12:45 p.m. UTC
  When testpmd receives the new or destroy event, the port related
information will be updated. Testpmd must stop packet forwarding
before updating the information to avoid some serious problems.

Signed-off-by: Huisong Li <lihuisong@huawei.com>
---
 app/test-pmd/testpmd.c | 4 ++++
 1 file changed, 4 insertions(+)
  

Patch

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 10b330e33c..faea6358f9 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -3694,6 +3694,8 @@  eth_event_callback(portid_t port_id, enum rte_eth_event_type type, void *param,
 
 	switch (type) {
 	case RTE_ETH_EVENT_NEW:
+		if (test_done == 0)
+			stop_packet_forwarding();
 		config_attached_port(port_id);
 		break;
 	case RTE_ETH_EVENT_INTR_RMV:
@@ -3703,6 +3705,8 @@  eth_event_callback(portid_t port_id, enum rte_eth_event_type type, void *param,
 				"Could not set up deferred device removal\n");
 		break;
 	case RTE_ETH_EVENT_DESTROY:
+		if (test_done == 0)
+			stop_packet_forwarding();
 		ports[port_id].port_status = RTE_PORT_CLOSED;
 		printf("Port %u is closed\n", port_id);
 		if (rte_eal_alarm_set(100000, remove_invalid_ports_callback,