app/testpmd: limit port mask bits to configured maximum
authorBruce Richardson <bruce.richardson@intel.com>
Tue, 16 Dec 2014 14:39:44 +0000 (14:39 +0000)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Wed, 17 Dec 2014 00:04:06 +0000 (01:04 +0100)
The port mask parsing in testpmd allowed up to 64 bits to be processed,
even if RTE_MAX_ETHPORTS is set to a max of 32. Fix this by only
processing up to min(RTE_MAX_ETHPORTS,64) bits of the mask.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
app/test-pmd/config.c

index 69a83c2..97b6525 100644 (file)
@@ -1440,7 +1440,7 @@ set_fwd_ports_mask(uint64_t portmask)
                return;
        }
        nb_pt = 0;
-       for (i = 0; i < 64; i++) {
+       for (i = 0; i < (unsigned)RTE_MIN(64, RTE_MAX_ETHPORTS); i++) {
                if (! ((uint64_t)(1ULL << i) & portmask))
                        continue;
                portlist[nb_pt++] = i;