[dpdk-dev] drivers/bonding: fix bond mac address reset

Message ID 20180523091121.9910-1-kiran.kokkilagadda@caviumnetworks.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Kiran Kumar May 23, 2018, 9:11 a.m. UTC
  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: a45b288ef21a ("bond: support link status polling")

Signed-off-by: Kiran Kumar <kiran.kokkilagadda@caviumnetworks.com>
---
 drivers/net/bonding/rte_eth_bond_api.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
  

Comments

Ferruh Yigit June 14, 2018, 4:49 p.m. UTC | #1
On 5/23/2018 10:11 AM, Kiran Kumar wrote:
> 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: a45b288ef21a ("bond: support link status polling")
> 
> Signed-off-by: Kiran Kumar <kiran.kokkilagadda@caviumnetworks.com>

Hi Declan, Radu, Chas,

If there is no objection, the patch will be merged as it is.
Can you please check?

Thanks,
ferruh
  
Chas Williams June 14, 2018, 8:38 p.m. UTC | #2
On Thu, Jun 14, 2018 at 12:49 PM Ferruh Yigit <ferruh.yigit@intel.com>
wrote:

> On 5/23/2018 10:11 AM, Kiran Kumar wrote:
> > 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: a45b288ef21a ("bond: support link status polling")
> >
> > Signed-off-by: Kiran Kumar <kiran.kokkilagadda@caviumnetworks.com>
>
> Hi Declan, Radu, Chas,
>
> If there is no objection, the patch will be merged as it is.
> Can you please check?
>

No objections. This patch looks correct.


>
> Thanks,
> ferruh
>
  
Ferruh Yigit June 15, 2018, 1:26 p.m. UTC | #3
On 6/14/2018 9:38 PM, Chas Williams wrote:
> 
> 
> On Thu, Jun 14, 2018 at 12:49 PM Ferruh Yigit <ferruh.yigit@intel.com
> <mailto:ferruh.yigit@intel.com>> wrote:
> 
>     On 5/23/2018 10:11 AM, Kiran Kumar wrote:
>     > 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: a45b288ef21a ("bond: support link status polling")
>     >
>     > Signed-off-by: Kiran Kumar <kiran.kokkilagadda@caviumnetworks.com
>     <mailto:kiran.kokkilagadda@caviumnetworks.com>>
> 
>     Hi Declan, Radu, Chas,
> 
>     If there is no objection, the patch will be merged as it is.
>     Can you please check?
> 
> 
> No objections. This patch looks correct.

Applied to dpdk-next-net/master, thanks.
  

Patch

diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c
index d558df8b9..d1a110ec9 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -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;