From d1f1a0fd8a0b3e5b090e64a8d7d895479e959143 Mon Sep 17 00:00:00 2001 From: Li Han Date: Tue, 22 Aug 2017 13:03:42 +0800 Subject: [PATCH] app/testpmd: fix invalid port id parameters in parse_ringnuma_config/parse_portnuma_config functions, port_id should be less than RTE_MAX_ETHPORTS, but port_id_is_invalid check assumes that port_id may be RTE_PORT_ALL (65535). Also fix port_id storage size. Fixes: 4468635fdd04 ("app/testpmd: forbid actions on invalid port") Cc: stable@dpdk.org Signed-off-by: Li Han Reviewed-by: Ferruh Yigit --- app/test-pmd/parameters.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index 31287d71d6..72ff971bb2 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -393,7 +393,8 @@ parse_portnuma_config(const char *q_arg) char s[256]; const char *p, *p0 = q_arg; char *end; - uint8_t i,port_id,socket_id; + uint8_t i, socket_id; + portid_t port_id; unsigned size; enum fieldnames { FLD_PORT = 0, @@ -423,8 +424,9 @@ parse_portnuma_config(const char *q_arg) if (errno != 0 || end == str_fld[i] || int_fld[i] > 255) return -1; } - port_id = (uint8_t)int_fld[FLD_PORT]; - if (port_id_is_invalid(port_id, ENABLED_WARN)) { + port_id = (portid_t)int_fld[FLD_PORT]; + if (port_id_is_invalid(port_id, ENABLED_WARN) || + port_id == (portid_t)RTE_PORT_ALL) { printf("Valid port range is [0"); RTE_ETH_FOREACH_DEV(pid) printf(", %d", pid); @@ -448,7 +450,8 @@ parse_ringnuma_config(const char *q_arg) char s[256]; const char *p, *p0 = q_arg; char *end; - uint8_t i,port_id,ring_flag,socket_id; + uint8_t i, ring_flag, socket_id; + portid_t port_id; unsigned size; enum fieldnames { FLD_PORT = 0, @@ -482,8 +485,9 @@ parse_ringnuma_config(const char *q_arg) if (errno != 0 || end == str_fld[i] || int_fld[i] > 255) return -1; } - port_id = (uint8_t)int_fld[FLD_PORT]; - if (port_id_is_invalid(port_id, ENABLED_WARN)) { + port_id = (portid_t)int_fld[FLD_PORT]; + if (port_id_is_invalid(port_id, ENABLED_WARN) || + port_id == (portid_t)RTE_PORT_ALL) { printf("Valid port range is [0"); RTE_ETH_FOREACH_DEV(pid) printf(", %d", pid); -- 2.20.1