aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bonding
diff options
context:
space:
mode:
authorJiri Bohac <jbohac@suse.cz>2012-01-18 07:24:54 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-02-03 12:19:03 -0500
commit03024e3d2d6705443980f956abb56d4453319e95 (patch)
treeac199e6e1fe242c24d3325b466beb28fa78a8284 /drivers/net/bonding
parent62252cba2867cec7cc484ebb2d3ec705c41d9684 (diff)
bonding: fix enslaving in alb mode when link down
[ Upstream commit b924551bed09f61b64f21bffe241afc5526b091a ] bond_alb_init_slave() is called from bond_enslave() and sets the slave's MAC address. This is done differently for TLB and ALB modes. bond->alb_info.rlb_enabled is used to discriminate between the two modes but this flag may be uninitialized if the slave is being enslaved prior to calling bond_open() -> bond_alb_initialize() on the master. It turns out all the callers of alb_set_slave_mac_addr() pass bond->alb_info.rlb_enabled as the hw parameter. This patch cleans up the unnecessary parameter of alb_set_slave_mac_addr() and makes the function decide based on the bonding mode instead, which fixes the above problem. Reported-by: Narendra K <Narendra_K@Dell.com> Signed-off-by: Jiri Bohac <jbohac@suse.cz> Signed-off-by: Jay Vosburgh <fubar@us.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/net/bonding')
-rw-r--r--drivers/net/bonding/bond_alb.c27
1 files changed, 9 insertions, 18 deletions
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index 2df9276720a..5e725e07d61 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -871,16 +871,12 @@ static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[])
871 } 871 }
872} 872}
873 873
874/* hw is a boolean parameter that determines whether we should try and 874static int alb_set_slave_mac_addr(struct slave *slave, u8 addr[])
875 * set the hw address of the device as well as the hw address of the
876 * net_device
877 */
878static int alb_set_slave_mac_addr(struct slave *slave, u8 addr[], int hw)
879{ 875{
880 struct net_device *dev = slave->dev; 876 struct net_device *dev = slave->dev;
881 struct sockaddr s_addr; 877 struct sockaddr s_addr;
882 878
883 if (!hw) { 879 if (slave->bond->params.mode == BOND_MODE_TLB) {
884 memcpy(dev->dev_addr, addr, dev->addr_len); 880 memcpy(dev->dev_addr, addr, dev->addr_len);
885 return 0; 881 return 0;
886 } 882 }
@@ -910,8 +906,8 @@ static void alb_swap_mac_addr(struct bonding *bond, struct slave *slave1, struct
910 u8 tmp_mac_addr[ETH_ALEN]; 906 u8 tmp_mac_addr[ETH_ALEN];
911 907
912 memcpy(tmp_mac_addr, slave1->dev->dev_addr, ETH_ALEN); 908 memcpy(tmp_mac_addr, slave1->dev->dev_addr, ETH_ALEN);
913 alb_set_slave_mac_addr(slave1, slave2->dev->dev_addr, bond->alb_info.rlb_enabled); 909 alb_set_slave_mac_addr(slave1, slave2->dev->dev_addr);
914 alb_set_slave_mac_addr(slave2, tmp_mac_addr, bond->alb_info.rlb_enabled); 910 alb_set_slave_mac_addr(slave2, tmp_mac_addr);
915 911
916} 912}
917 913
@@ -1058,8 +1054,7 @@ static int alb_handle_addr_collision_on_attach(struct bonding *bond, struct slav
1058 1054
1059 /* Try setting slave mac to bond address and fall-through 1055 /* Try setting slave mac to bond address and fall-through
1060 to code handling that situation below... */ 1056 to code handling that situation below... */
1061 alb_set_slave_mac_addr(slave, bond->dev->dev_addr, 1057 alb_set_slave_mac_addr(slave, bond->dev->dev_addr);
1062 bond->alb_info.rlb_enabled);
1063 } 1058 }
1064 1059
1065 /* The slave's address is equal to the address of the bond. 1060 /* The slave's address is equal to the address of the bond.
@@ -1095,8 +1090,7 @@ static int alb_handle_addr_collision_on_attach(struct bonding *bond, struct slav
1095 } 1090 }
1096 1091
1097 if (free_mac_slave) { 1092 if (free_mac_slave) {
1098 alb_set_slave_mac_addr(slave, free_mac_slave->perm_hwaddr, 1093 alb_set_slave_mac_addr(slave, free_mac_slave->perm_hwaddr);
1099 bond->alb_info.rlb_enabled);
1100 1094
1101 pr_warning("%s: Warning: the hw address of slave %s is in use by the bond; giving it the hw address of %s\n", 1095 pr_warning("%s: Warning: the hw address of slave %s is in use by the bond; giving it the hw address of %s\n",
1102 bond->dev->name, slave->dev->name, 1096 bond->dev->name, slave->dev->name,
@@ -1452,8 +1446,7 @@ int bond_alb_init_slave(struct bonding *bond, struct slave *slave)
1452{ 1446{
1453 int res; 1447 int res;
1454 1448
1455 res = alb_set_slave_mac_addr(slave, slave->perm_hwaddr, 1449 res = alb_set_slave_mac_addr(slave, slave->perm_hwaddr);
1456 bond->alb_info.rlb_enabled);
1457 if (res) { 1450 if (res) {
1458 return res; 1451 return res;
1459 } 1452 }
@@ -1604,8 +1597,7 @@ void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave
1604 alb_swap_mac_addr(bond, swap_slave, new_slave); 1597 alb_swap_mac_addr(bond, swap_slave, new_slave);
1605 } else { 1598 } else {
1606 /* set the new_slave to the bond mac address */ 1599 /* set the new_slave to the bond mac address */
1607 alb_set_slave_mac_addr(new_slave, bond->dev->dev_addr, 1600 alb_set_slave_mac_addr(new_slave, bond->dev->dev_addr);
1608 bond->alb_info.rlb_enabled);
1609 } 1601 }
1610 1602
1611 if (swap_slave) { 1603 if (swap_slave) {
@@ -1665,8 +1657,7 @@ int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr)
1665 alb_swap_mac_addr(bond, swap_slave, bond->curr_active_slave); 1657 alb_swap_mac_addr(bond, swap_slave, bond->curr_active_slave);
1666 alb_fasten_mac_swap(bond, swap_slave, bond->curr_active_slave); 1658 alb_fasten_mac_swap(bond, swap_slave, bond->curr_active_slave);
1667 } else { 1659 } else {
1668 alb_set_slave_mac_addr(bond->curr_active_slave, bond_dev->dev_addr, 1660 alb_set_slave_mac_addr(bond->curr_active_slave, bond_dev->dev_addr);
1669 bond->alb_info.rlb_enabled);
1670 1661
1671 read_lock(&bond->lock); 1662 read_lock(&bond->lock);
1672 alb_send_learning_packets(bond->curr_active_slave, bond_dev->dev_addr); 1663 alb_send_learning_packets(bond->curr_active_slave, bond_dev->dev_addr);