Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bonding: trivial: make alb use bond_slave_has_mac()

Also, cleanup bond_alb_handle_active_change() from 2 identical ifs.

Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Veaceslav Falico and committed by
David S. Miller
b88ec38d 257a3feb

+11 -42
+11 -42
drivers/net/bonding/bond_alb.c
··· 1129 1129 { 1130 1130 int perm_curr_diff; 1131 1131 int perm_bond_diff; 1132 + struct slave *found_slave; 1132 1133 1133 1134 perm_curr_diff = !ether_addr_equal_64bits(slave->perm_hwaddr, 1134 1135 slave->dev->dev_addr); ··· 1137 1136 bond->dev->dev_addr); 1138 1137 1139 1138 if (perm_curr_diff && perm_bond_diff) { 1140 - struct slave *tmp_slave; 1141 - int i, found = 0; 1139 + found_slave = bond_slave_has_mac(bond, slave->perm_hwaddr); 1142 1140 1143 - bond_for_each_slave(bond, tmp_slave, i) { 1144 - if (ether_addr_equal_64bits(slave->perm_hwaddr, 1145 - tmp_slave->dev->dev_addr)) { 1146 - found = 1; 1147 - break; 1148 - } 1149 - } 1150 - 1151 - if (found) { 1141 + if (found_slave) { 1152 1142 /* locking: needs RTNL and nothing else */ 1153 - alb_swap_mac_addr(slave, tmp_slave); 1154 - alb_fasten_mac_swap(bond, slave, tmp_slave); 1143 + alb_swap_mac_addr(slave, found_slave); 1144 + alb_fasten_mac_swap(bond, slave, found_slave); 1155 1145 } 1156 1146 } 1157 1147 } ··· 1660 1668 __acquires(&bond->curr_slave_lock) 1661 1669 { 1662 1670 struct slave *swap_slave; 1663 - int i; 1664 1671 1665 1672 if (bond->curr_active_slave == new_slave) { 1666 1673 return; ··· 1681 1690 /* set the new curr_active_slave to the bonds mac address 1682 1691 * i.e. swap mac addresses of old curr_active_slave and new curr_active_slave 1683 1692 */ 1684 - if (!swap_slave) { 1685 - struct slave *tmp_slave; 1686 - /* find slave that is holding the bond's mac address */ 1687 - bond_for_each_slave(bond, tmp_slave, i) { 1688 - if (ether_addr_equal_64bits(tmp_slave->dev->dev_addr, 1689 - bond->dev->dev_addr)) { 1690 - swap_slave = tmp_slave; 1691 - break; 1692 - } 1693 - } 1694 - } 1693 + if (!swap_slave) 1694 + swap_slave = bond_slave_has_mac(bond, bond->dev->dev_addr); 1695 1695 1696 1696 /* 1697 1697 * Arrange for swap_slave and new_slave to temporarily be ··· 1703 1721 if (swap_slave) { 1704 1722 /* swap mac address */ 1705 1723 alb_swap_mac_addr(swap_slave, new_slave); 1706 - } else { 1707 - /* set the new_slave to the bond mac address */ 1708 - alb_set_slave_mac_addr(new_slave, bond->dev->dev_addr); 1709 - } 1710 - 1711 - if (swap_slave) { 1712 1724 alb_fasten_mac_swap(bond, swap_slave, new_slave); 1713 1725 read_lock(&bond->lock); 1714 1726 } else { 1727 + /* set the new_slave to the bond mac address */ 1728 + alb_set_slave_mac_addr(new_slave, bond->dev->dev_addr); 1715 1729 read_lock(&bond->lock); 1716 1730 alb_send_learning_packets(new_slave, bond->dev->dev_addr); 1717 1731 } ··· 1724 1746 { 1725 1747 struct bonding *bond = netdev_priv(bond_dev); 1726 1748 struct sockaddr *sa = addr; 1727 - struct slave *slave, *swap_slave; 1749 + struct slave *swap_slave; 1728 1750 int res; 1729 - int i; 1730 1751 1731 1752 if (!is_valid_ether_addr(sa->sa_data)) { 1732 1753 return -EADDRNOTAVAIL; ··· 1746 1769 return 0; 1747 1770 } 1748 1771 1749 - swap_slave = NULL; 1750 - 1751 - bond_for_each_slave(bond, slave, i) { 1752 - if (ether_addr_equal_64bits(slave->dev->dev_addr, 1753 - bond_dev->dev_addr)) { 1754 - swap_slave = slave; 1755 - break; 1756 - } 1757 - } 1772 + swap_slave = bond_slave_has_mac(bond, bond_dev->dev_addr); 1758 1773 1759 1774 if (swap_slave) { 1760 1775 alb_swap_mac_addr(swap_slave, bond->curr_active_slave);