aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bonding/bond_main.c
diff options
context:
space:
mode:
authornikolay@redhat.com <nikolay@redhat.com>2013-06-26 11:13:38 -0400
committerDavid S. Miller <davem@davemloft.net>2013-06-28 01:50:15 -0400
commit97a1e6396b07581249506952a4c417dc6d2a4f9c (patch)
treea87f2407c53765821708c8619b0b75f8bb9aab55 /drivers/net/bonding/bond_main.c
parent8d2ada77f8a7f8f65fcbf71b23cbac54b64151a6 (diff)
bonding: remove unnecessary dev_addr_from_first member
In struct bonding there's a member called dev_addr_from_first which is used to denote when the bond dev should clone the first slave's MAC address but since we have netdev's addr_assign_type variable that is not necessary. We clone the first slave's MAC each time we have a random MAC set to the bond device. This has the nice side-effect of also fixing an inconsistency - when the MAC address of the bond dev is set after its creation, but prior to having slaves, it's not kept and the first slave's MAC is cloned. The only way to keep the MAC was to create the bond device with the MAC address set (e.g. through ip link). In all cases if the bond device is left without any slaves - its MAC gets reset to a random one as before. Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bonding/bond_main.c')
-rw-r--r--drivers/net/bonding/bond_main.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 2e8b9f1e2747..0da3c126c7c4 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1596,7 +1596,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1596 1596
1597 /* If this is the first slave, then we need to set the master's hardware 1597 /* If this is the first slave, then we need to set the master's hardware
1598 * address to be the same as the slave's. */ 1598 * address to be the same as the slave's. */
1599 if (bond->slave_cnt == 0 && bond->dev_addr_from_first) 1599 if (!bond->slave_cnt && bond->dev->addr_assign_type == NET_ADDR_RANDOM)
1600 bond_set_dev_addr(bond->dev, slave_dev); 1600 bond_set_dev_addr(bond->dev, slave_dev);
1601 1601
1602 new_slave = kzalloc(sizeof(struct slave), GFP_KERNEL); 1602 new_slave = kzalloc(sizeof(struct slave), GFP_KERNEL);
@@ -2041,7 +2041,6 @@ static int __bond_release_one(struct net_device *bond_dev,
2041 if (bond->slave_cnt == 0) { 2041 if (bond->slave_cnt == 0) {
2042 bond_set_carrier(bond); 2042 bond_set_carrier(bond);
2043 eth_hw_addr_random(bond_dev); 2043 eth_hw_addr_random(bond_dev);
2044 bond->dev_addr_from_first = true;
2045 2044
2046 if (bond_vlan_used(bond)) { 2045 if (bond_vlan_used(bond)) {
2047 pr_warning("%s: Warning: clearing HW address of %s while it still has VLANs.\n", 2046 pr_warning("%s: Warning: clearing HW address of %s while it still has VLANs.\n",
@@ -4800,10 +4799,8 @@ static int bond_init(struct net_device *bond_dev)
4800 4799
4801 /* Ensure valid dev_addr */ 4800 /* Ensure valid dev_addr */
4802 if (is_zero_ether_addr(bond_dev->dev_addr) && 4801 if (is_zero_ether_addr(bond_dev->dev_addr) &&
4803 bond_dev->addr_assign_type == NET_ADDR_PERM) { 4802 bond_dev->addr_assign_type == NET_ADDR_PERM)
4804 eth_hw_addr_random(bond_dev); 4803 eth_hw_addr_random(bond_dev);
4805 bond->dev_addr_from_first = true;
4806 }
4807 4804
4808 return 0; 4805 return 0;
4809} 4806}