@@ -1129,28 +1129,20 @@ static void alb_change_hw_addr_on_detach(struct bonding *bond, struct slave *sla
11291129{
11301130 int perm_curr_diff ;
11311131 int perm_bond_diff ;
1132+ struct slave * found_slave ;
11321133
11331134 perm_curr_diff = !ether_addr_equal_64bits (slave -> perm_hwaddr ,
11341135 slave -> dev -> dev_addr );
11351136 perm_bond_diff = !ether_addr_equal_64bits (slave -> perm_hwaddr ,
11361137 bond -> dev -> dev_addr );
11371138
11381139 if (perm_curr_diff && perm_bond_diff ) {
1139- struct slave * tmp_slave ;
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- }
1140+ found_slave = bond_slave_has_mac (bond , slave -> perm_hwaddr );
11491141
1150- if (found ) {
1142+ if (found_slave ) {
11511143 /* locking: needs RTNL and nothing else */
1152- alb_swap_mac_addr (slave , tmp_slave );
1153- alb_fasten_mac_swap (bond , slave , tmp_slave );
1144+ alb_swap_mac_addr (slave , found_slave );
1145+ alb_fasten_mac_swap (bond , slave , found_slave );
11541146 }
11551147 }
11561148}
@@ -1668,7 +1660,6 @@ void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave
16681660 __acquires (& bond - > curr_slave_lock )
16691661{
16701662 struct slave * swap_slave ;
1671- int i ;
16721663
16731664 if (bond -> curr_active_slave == new_slave ) {
16741665 return ;
@@ -1690,17 +1681,8 @@ void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave
16901681 /* set the new curr_active_slave to the bonds mac address
16911682 * i.e. swap mac addresses of old curr_active_slave and new curr_active_slave
16921683 */
1693- if (!swap_slave ) {
1694- struct slave * tmp_slave ;
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- }
1684+ if (!swap_slave )
1685+ swap_slave = bond_slave_has_mac (bond , bond -> dev -> dev_addr );
17041686
17051687 /*
17061688 * 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
17211703 if (swap_slave ) {
17221704 /* swap mac address */
17231705 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 ) {
17301706 alb_fasten_mac_swap (bond , swap_slave , new_slave );
17311707 read_lock (& bond -> lock );
17321708 } else {
1709+ /* set the new_slave to the bond mac address */
1710+ alb_set_slave_mac_addr (new_slave , bond -> dev -> dev_addr );
17331711 read_lock (& bond -> lock );
17341712 alb_send_learning_packets (new_slave , bond -> dev -> dev_addr );
17351713 }
@@ -1746,9 +1724,8 @@ int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr)
17461724{
17471725 struct bonding * bond = netdev_priv (bond_dev );
17481726 struct sockaddr * sa = addr ;
1749- struct slave * slave , * swap_slave ;
1727+ struct slave * swap_slave ;
17501728 int res ;
1751- int i ;
17521729
17531730 if (!is_valid_ether_addr (sa -> sa_data )) {
17541731 return - EADDRNOTAVAIL ;
@@ -1769,15 +1746,7 @@ int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr)
17691746 return 0 ;
17701747 }
17711748
1772- swap_slave = NULL ;
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- }
1749+ swap_slave = bond_slave_has_mac (bond , bond_dev -> dev_addr );
17811750
17821751 if (swap_slave ) {
17831752 alb_swap_mac_addr (swap_slave , bond -> curr_active_slave );
0 commit comments