app/testpmd: forbid actions on invalid port
Currently, if try to start/stop/close one invalid port, no error shows in testpmd. This is a bug, need check the port number. Signed-off-by: Michael Qiu <michael.qiu@intel.com> Acked-by: Tetsuya Mukawa <mukawa@igel.co.jp>
This commit is contained in:
parent
92d2703e2c
commit
4468635fdd
@ -384,6 +384,9 @@ port_infos_display(portid_t port_id)
|
|||||||
int
|
int
|
||||||
port_id_is_invalid(portid_t port_id, enum print_warning warning)
|
port_id_is_invalid(portid_t port_id, enum print_warning warning)
|
||||||
{
|
{
|
||||||
|
if (port_id == (portid_t)RTE_PORT_ALL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (ports[port_id].enabled)
|
if (ports[port_id].enabled)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -1326,6 +1326,9 @@ start_port(portid_t pid)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (port_id_is_invalid(pid, ENABLED_WARN))
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (init_fwd_streams() < 0) {
|
if (init_fwd_streams() < 0) {
|
||||||
printf("Fail from init_fwd_streams()\n");
|
printf("Fail from init_fwd_streams()\n");
|
||||||
return -1;
|
return -1;
|
||||||
@ -1482,10 +1485,14 @@ stop_port(portid_t pid)
|
|||||||
dcb_test = 0;
|
dcb_test = 0;
|
||||||
dcb_config = 0;
|
dcb_config = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (port_id_is_invalid(pid, ENABLED_WARN))
|
||||||
|
return;
|
||||||
|
|
||||||
printf("Stopping ports...\n");
|
printf("Stopping ports...\n");
|
||||||
|
|
||||||
FOREACH_PORT(pi, ports) {
|
FOREACH_PORT(pi, ports) {
|
||||||
if (!port_id_is_invalid(pid, DISABLED_WARN) && pid != pi)
|
if (pid != pi && pid != (portid_t)RTE_PORT_ALL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
port = &ports[pi];
|
port = &ports[pi];
|
||||||
@ -1517,10 +1524,13 @@ close_port(portid_t pid)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (port_id_is_invalid(pid, ENABLED_WARN))
|
||||||
|
return;
|
||||||
|
|
||||||
printf("Closing ports...\n");
|
printf("Closing ports...\n");
|
||||||
|
|
||||||
FOREACH_PORT(pi, ports) {
|
FOREACH_PORT(pi, ports) {
|
||||||
if (!port_id_is_invalid(pid, DISABLED_WARN) && pid != pi)
|
if (pid != pi && pid != (portid_t)RTE_PORT_ALL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
port = &ports[pi];
|
port = &ports[pi];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user