app/testpmd: fix bonding mode set
authorMin Hu (Connor) <humin29@huawei.com>
Fri, 28 Jan 2022 02:35:19 +0000 (10:35 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 31 Jan 2022 16:13:06 +0000 (17:13 +0100)
commit39ddd5d1895e72ba2bc974eddbc12a3135639ed1
treea6bc0d91396e82e9e9e3e9c0d0f0e1d398ca0214
parent814e79f3afad8c45c6922617f26292af3221ae2b
app/testpmd: fix bonding mode set

when start testpmd, and type command like this, it will lead to
Segmentation fault, like:

testpmd> create bonded device 4 0
testpmd> add bonding slave 0 2
testpmd> add bonding slave 1 2
testpmd> port start 2
testpmd> set bonding mode 0 2
testpmd> quit
Stopping port 0...
Stopping ports...
...
Bye...
Segmentation fault

The reason to the bug is that rte timer do not be cancelled when quit.
That is, in 'bond_ethdev_start', resources are allocated according to
different bonding mode. In 'bond_ethdev_stop', resources are free by
the corresponding mode.

For example, 'bond_ethdev_start' start bond_mode_8023ad_ext_periodic_cb
timer for bonding mode 4. and 'bond_ethdev_stop' cancel the timer only
when the current bonding mode is 4. If the bonding mode is changed,
and directly quit the process, the timer will still on, and freed memory
will be accessed, then segmentation fault.

'bonding mode' changed means resources changed, reallocate resources for
different mode should be done, that is, device should be restarted.

Fixes: 2950a769315e ("bond: testpmd support")
Cc: stable@dpdk.org
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
Tested-by: Ferruh Yigit <ferruh.yigit@intel.com>
app/test-pmd/cmdline.c