The "port config dcb ..." command will segment fault when input with invalid port id, this patch fixes it.
Fixes: 9b53e542e9e1 ("app/testpmd: add priority flow control") Cc: sta...@dpdk.org Signed-off-by: Chengwen Feng <fengcheng...@huawei.com> --- app/test-pmd/cmdline.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 86d763b66a..56031fbd4e 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -3462,6 +3462,9 @@ cmd_config_dcb_parsed(void *parsed_result, uint8_t pfc_en; int ret; + if (port_id_is_invalid(port_id, ENABLED_WARN)) + return; + port = &ports[port_id]; /** Check if the port is not started **/ if (port->port_status != RTE_PORT_STOPPED) { @@ -6664,6 +6667,9 @@ cmd_priority_flow_ctrl_set_parsed(void *parsed_result, int rx_fc_enable, tx_fc_enable; int ret; + if (port_id_is_invalid(res->port_id, ENABLED_WARN)) + return; + /* * Rx on/off, flow control is enabled/disabled on RX side. This can indicate * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side. -- 2.17.1