[V2,4/6] app/testpmd: check the validity of the port

Message ID 20220915124522.5407-5-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

Commit Message

lihuisong (C) Sept. 15, 2022, 12:45 p.m. UTC
  This patch checks the validity of port id for all events in
'eth_event_callback()'.

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

Comments

Singh, Aman Deep Sept. 22, 2022, 5:07 a.m. UTC | #1
On 9/15/2022 6:15 PM, Huisong Li wrote:
> This patch checks the validity of port id for all events in
> 'eth_event_callback()'.
> 
> Signed-off-by: Huisong Li <lihuisong@huawei.com>Acked-by: Aman Singh <aman.deep.singh@intel.com>
> ---
  

Patch

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 77741fc41f..1605e34f35 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -3673,14 +3673,15 @@  eth_event_callback(portid_t port_id, enum rte_eth_event_type type, void *param,
 		fflush(stdout);
 	}
 
+	if (port_id_is_invalid(port_id, DISABLED_WARN))
+		return 0;
+
 	switch (type) {
 	case RTE_ETH_EVENT_NEW:
 		ports[port_id].need_setup = 1;
 		ports[port_id].port_status = RTE_PORT_HANDLING;
 		break;
 	case RTE_ETH_EVENT_INTR_RMV:
-		if (port_id_is_invalid(port_id, DISABLED_WARN))
-			break;
 		if (rte_eal_alarm_set(100000,
 				rmv_port_callback, (void *)(intptr_t)port_id))
 			fprintf(stderr,