diff options
-rw-r--r-- | drivers/net/bonding/bond_alb.c | 53 |
1 files changed, 11 insertions, 42 deletions
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c index 27fe329bdf83..4ea8ed150d46 100644 --- a/drivers/net/bonding/bond_alb.c +++ b/drivers/net/bonding/bond_alb.c | |||
@@ -1129,6 +1129,7 @@ static void alb_change_hw_addr_on_detach(struct bonding *bond, struct slave *sla | |||
1129 | { | 1129 | { |
1130 | int perm_curr_diff; | 1130 | int perm_curr_diff; |
1131 | int perm_bond_diff; | 1131 | int perm_bond_diff; |
1132 | struct slave *found_slave; | ||
1132 | 1133 | ||
1133 | perm_curr_diff = !ether_addr_equal_64bits(slave->perm_hwaddr, | 1134 | perm_curr_diff = !ether_addr_equal_64bits(slave->perm_hwaddr, |
1134 | slave->dev->dev_addr); | 1135 | slave->dev->dev_addr); |
@@ -1136,21 +1137,12 @@ static void alb_change_hw_addr_on_detach(struct bonding *bond, struct slave *sla | |||
1136 | bond->dev->dev_addr); | 1137 | bond->dev->dev_addr); |
1137 | 1138 | ||
1138 | if (perm_curr_diff && perm_bond_diff) { | 1139 | if (perm_curr_diff && perm_bond_diff) { |
1139 | struct slave *tmp_slave; | 1140 | found_slave = bond_slave_has_mac(bond, slave->perm_hwaddr); |
1140 | int i, found = 0; | ||
1141 | |||
1142 | bond_for_each_slave(bond, tmp_slave, i) { | ||
1143 | if (ether_addr_equal_64bits(slave->perm_hwaddr, | ||
1144 | tmp_slave->dev->dev_addr)) { | ||
1145 | found = 1; | ||
1146 | break; | ||
1147 | } | ||
1148 | } | ||
1149 | 1141 | ||
1150 | if (found) { | 1142 | if (found_slave) { |
1151 | /* locking: needs RTNL and nothing else */ | 1143 | /* locking: needs RTNL and nothing else */ |
1152 | alb_swap_mac_addr(slave, tmp_slave); | 1144 | alb_swap_mac_addr(slave, found_slave); |
1153 | alb_fasten_mac_swap(bond, slave, tmp_slave); | 1145 | alb_fasten_mac_swap(bond, slave, found_slave); |
1154 | } | 1146 | } |
1155 | } | 1147 | } |
1156 | } | 1148 | } |
@@ -1668,7 +1660,6 @@ void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave | |||
1668 | __acquires(&bond->curr_slave_lock) | 1660 | __acquires(&bond->curr_slave_lock) |
1669 | { | 1661 | { |
1670 | struct slave *swap_slave; | 1662 | struct slave *swap_slave; |
1671 | int i; | ||
1672 | 1663 | ||
1673 | if (bond->curr_active_slave == new_slave) { | 1664 | if (bond->curr_active_slave == new_slave) { |
1674 | return; | 1665 | return; |
@@ -1690,17 +1681,8 @@ void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave | |||
1690 | /* set the new curr_active_slave to the bonds mac address | 1681 | /* set the new curr_active_slave to the bonds mac address |
1691 | * i.e. swap mac addresses of old curr_active_slave and new curr_active_slave | 1682 | * i.e. swap mac addresses of old curr_active_slave and new curr_active_slave |
1692 | */ | 1683 | */ |
1693 | if (!swap_slave) { | 1684 | if (!swap_slave) |
1694 | struct slave *tmp_slave; | 1685 | swap_slave = bond_slave_has_mac(bond, bond->dev->dev_addr); |
1695 | /* find slave that is holding the bond's mac address */ | ||
1696 | bond_for_each_slave(bond, tmp_slave, i) { | ||
1697 | if (ether_addr_equal_64bits(tmp_slave->dev->dev_addr, | ||
1698 | bond->dev->dev_addr)) { | ||
1699 | swap_slave = tmp_slave; | ||
1700 | break; | ||
1701 | } | ||
1702 | } | ||
1703 | } | ||
1704 | 1686 | ||
1705 | /* | 1687 | /* |
1706 | * Arrange for swap_slave and new_slave to temporarily be | 1688 | * Arrange for swap_slave and new_slave to temporarily be |
@@ -1721,15 +1703,11 @@ void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave | |||
1721 | if (swap_slave) { | 1703 | if (swap_slave) { |
1722 | /* swap mac address */ | 1704 | /* swap mac address */ |
1723 | alb_swap_mac_addr(swap_slave, new_slave); | 1705 | alb_swap_mac_addr(swap_slave, new_slave); |
1724 | } else { | ||
1725 | /* set the new_slave to the bond mac address */ | ||
1726 | alb_set_slave_mac_addr(new_slave, bond->dev->dev_addr); | ||
1727 | } | ||
1728 | |||
1729 | if (swap_slave) { | ||
1730 | alb_fasten_mac_swap(bond, swap_slave, new_slave); | 1706 | alb_fasten_mac_swap(bond, swap_slave, new_slave); |
1731 | read_lock(&bond->lock); | 1707 | read_lock(&bond->lock); |
1732 | } else { | 1708 | } else { |
1709 | /* set the new_slave to the bond mac address */ | ||
1710 | alb_set_slave_mac_addr(new_slave, bond->dev->dev_addr); | ||
1733 | read_lock(&bond->lock); | 1711 | read_lock(&bond->lock); |
1734 | alb_send_learning_packets(new_slave, bond->dev->dev_addr); | 1712 | alb_send_learning_packets(new_slave, bond->dev->dev_addr); |
1735 | } | 1713 | } |
@@ -1746,9 +1724,8 @@ int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr) | |||
1746 | { | 1724 | { |
1747 | struct bonding *bond = netdev_priv(bond_dev); | 1725 | struct bonding *bond = netdev_priv(bond_dev); |
1748 | struct sockaddr *sa = addr; | 1726 | struct sockaddr *sa = addr; |
1749 | struct slave *slave, *swap_slave; | 1727 | struct slave *swap_slave; |
1750 | int res; | 1728 | int res; |
1751 | int i; | ||
1752 | 1729 | ||
1753 | if (!is_valid_ether_addr(sa->sa_data)) { | 1730 | if (!is_valid_ether_addr(sa->sa_data)) { |
1754 | return -EADDRNOTAVAIL; | 1731 | return -EADDRNOTAVAIL; |
@@ -1769,15 +1746,7 @@ int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr) | |||
1769 | return 0; | 1746 | return 0; |
1770 | } | 1747 | } |
1771 | 1748 | ||
1772 | swap_slave = NULL; | 1749 | swap_slave = bond_slave_has_mac(bond, bond_dev->dev_addr); |
1773 | |||
1774 | bond_for_each_slave(bond, slave, i) { | ||
1775 | if (ether_addr_equal_64bits(slave->dev->dev_addr, | ||
1776 | bond_dev->dev_addr)) { | ||
1777 | swap_slave = slave; | ||
1778 | break; | ||
1779 | } | ||
1780 | } | ||
1781 | 1750 | ||
1782 | if (swap_slave) { | 1751 | if (swap_slave) { |
1783 | alb_swap_mac_addr(swap_slave, bond->curr_active_slave); | 1752 | alb_swap_mac_addr(swap_slave, bond->curr_active_slave); |