net/bonding: fix MAC address reset

Currently when resetting bond mac address, we are getting the
persisted mac address from slave info considering primary port
as index. But we need to compare the port id from slave info
with the primary port to get the primary slave index and get
the persisted mac address. Without this fix, persisted mac addr
will be zero and rte_eth_dev_default_mac_addr_set will fail.

Fixes: a45b288ef2 ("bond: support link status polling")
Cc: stable@dpdk.org

Signed-off-by: Kiran Kumar <kiran.kokkilagadda@caviumnetworks.com>
This commit is contained in:
Kiran Kumar 2018-05-23 14:41:21 +05:30 committed by Ferruh Yigit
parent 63b113afa5
commit fb6eb1e69c

View File

@ -716,9 +716,21 @@ rte_eth_bond_mac_address_reset(uint16_t bonded_port_id)
internals->user_defined_mac = 0;
if (internals->slave_count > 0) {
int slave_port;
/* Get the primary slave location based on the primary port
* number as, while slave_add(), we will keep the primary
* slave based on slave_count,but not based on the primary port.
*/
for (slave_port = 0; slave_port < internals->slave_count;
slave_port++) {
if (internals->slaves[slave_port].port_id ==
internals->primary_port)
break;
}
/* Set MAC Address of Bonded Device */
if (mac_address_set(bonded_eth_dev,
&internals->slaves[internals->primary_port].persisted_mac_addr)
&internals->slaves[slave_port].persisted_mac_addr)
!= 0) {
RTE_BOND_LOG(ERR, "Failed to set MAC address on bonded device");
return -1;