diff mbox

[net-next] bond: set mac address only if necessary

Message ID 1459264457-19000-1-git-send-email-zhangshengju@cmss.chinamobile.com
State Rejected, archived
Delegated to: David Miller
Headers show

Commit Message

Zhang Shengju March 29, 2016, 3:14 p.m. UTC
Bond device gets it's mac address from the first slave device, it's not
necessary to set slave device's mac address to bond if equal.

Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
---
 drivers/net/bonding/bond_main.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

David Miller March 30, 2016, 7:47 p.m. UTC | #1
From: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
Date: Tue, 29 Mar 2016 15:14:17 +0000

> Bond device gets it's mac address from the first slave device, it's not
> necessary to set slave device's mac address to bond if equal.
> 
> Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>

I don't think bond enslavement occurs often enough to justify this
optimization, sorry.
diff mbox

Patch

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 97fad05..6569219 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1473,8 +1473,9 @@  int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
 	 */
 	ether_addr_copy(new_slave->perm_hwaddr, slave_dev->dev_addr);
 
-	if (!bond->params.fail_over_mac ||
-	    BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) {
+	if ((!bond->params.fail_over_mac ||
+	    BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) &&
+	    !ether_addr_equal_64bits(bond_dev->dev_addr, slave_dev->dev_addr)) {
 		/* Set slave to master's mac address.  The application already
 		 * set the master's mac address to that of the first slave
 		 */