app/testpmd: fix forward port ids setting
authorMatan Azrad <matan@mellanox.com>
Sun, 3 Sep 2017 13:19:07 +0000 (16:19 +0300)
committerFerruh Yigit <ferruh.yigit@intel.com>
Thu, 12 Oct 2017 00:36:58 +0000 (01:36 +0100)
commit65a7360cc3378f5b3edd59f230141462dd98cfe9
treee92e2b5f704949b47dd85083c6a6252204eca578
parentd1f1a0fd8a0b3e5b090e64a8d7d895479e959143
app/testpmd: fix forward port ids setting

The corrupted code didn't check the port availability when
it was trying to set the forward port IDs array.
However, when it was counting the number of ports, the availability
was checked by RTE_ETH_FOREACH_DEV iterator.

Hence, even when ETH devices ports were not in ATTACHED state,
the testpmd tried to forward traffic by them and got segmentation
fault at queue access time.

For example:
When EAL command line parameters include two devices, the first
is failsafe with two sub devices and the second is any device,
testpmd gets two devices by the iterator and sets for forwarding
both, the failsafe device and the failsafe first sub device
(instead of the second sub device).
After the first failsafe sub device state was changed to DEFERRED,
testpmd tries to forward traffic through the deferred device
because it didn't check the port availability in setting time.

The fix uses the RTE_ETH_FOREACH_DEV iterator for the forward
port IDs default setting.

Fixes: cb894d99eceb ("ethdev: add deferred intermediate device state")
Cc: stable@dpdk.org
Signed-off-by: Matan Azrad <matan@mellanox.com>
Acked-by: Jingjing Wu <jingjing.wu@intel.com>
app/test-pmd/testpmd.c