bonding: remove unnecessary dev_addr_from_first member
authornikolay@redhat.com <nikolay@redhat.com>
Wed, 26 Jun 2013 15:13:38 +0000 (17:13 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 28 Jun 2013 05:50:15 +0000 (22:50 -0700)
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>
drivers/net/bonding/bond_main.c
drivers/net/bonding/bonding.h

index 2e8b9f1e27477e2e9658b63237c6f93687c3493b..0da3c126c7c4c27a96a86daceb978ed7fd926d12 100644 (file)
@@ -1596,7 +1596,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
 
        /* If this is the first slave, then we need to set the master's hardware
         * address to be the same as the slave's. */
-       if (bond->slave_cnt == 0 && bond->dev_addr_from_first)
+       if (!bond->slave_cnt && bond->dev->addr_assign_type == NET_ADDR_RANDOM)
                bond_set_dev_addr(bond->dev, slave_dev);
 
        new_slave = kzalloc(sizeof(struct slave), GFP_KERNEL);
@@ -2041,7 +2041,6 @@ static int __bond_release_one(struct net_device *bond_dev,
        if (bond->slave_cnt == 0) {
                bond_set_carrier(bond);
                eth_hw_addr_random(bond_dev);
-               bond->dev_addr_from_first = true;
 
                if (bond_vlan_used(bond)) {
                        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)
 
        /* Ensure valid dev_addr */
        if (is_zero_ether_addr(bond_dev->dev_addr) &&
-           bond_dev->addr_assign_type == NET_ADDR_PERM) {
+           bond_dev->addr_assign_type == NET_ADDR_PERM)
                eth_hw_addr_random(bond_dev);
-               bond->dev_addr_from_first = true;
-       }
 
        return 0;
 }
index c6c8d03562e5ed4890842002297c1a7eb21e52fc..42d1c6599cba944cd1854759f010b5c6776c438b 100644 (file)
@@ -248,7 +248,6 @@ struct bonding {
        /* debugging support via debugfs */
        struct   dentry *debug_dir;
 #endif /* CONFIG_DEBUG_FS */
-       bool    dev_addr_from_first;
 };
 
 static inline bool bond_vlan_used(struct bonding *bond)
This page took 0.04255 seconds and 5 git commands to generate.