Lines Matching full:slave
20 * the first slave bonded to the channel. All slaves will then use
27 * will attach eth0 to bond0 as a slave. eth0 hw mac address will either
143 MODULE_PARM_DESC(primary_reselect, "Reselect primary slave "
148 "2 for only on active slave "
187 MODULE_PARM_DESC(packets_per_slave, "Packets to send per slave in balance-rr "
188 "mode; 0 for a random slave, 1 packet per "
189 "slave (default), >1 packets per slave.");
241 * @slave_dev: slave that is supposed to xmit this skbuff
259 * We don't protect the slave list iteration with a lock because:
283 struct slave *slave, *rollback_slave; in bond_vlan_rx_add_vid() local
287 bond_for_each_slave(bond, slave, iter) { in bond_vlan_rx_add_vid()
288 res = vlan_vid_add(slave->dev, proto, vid); in bond_vlan_rx_add_vid()
296 /* unwind to the slave that failed */ in bond_vlan_rx_add_vid()
298 if (rollback_slave == slave) in bond_vlan_rx_add_vid()
317 struct slave *slave; in bond_vlan_rx_kill_vid() local
319 bond_for_each_slave(bond, slave, iter) in bond_vlan_rx_kill_vid()
320 vlan_vid_del(slave->dev, proto, vid); in bond_vlan_rx_kill_vid()
339 struct slave *slave; in bond_set_carrier() local
347 bond_for_each_slave(bond, slave, iter) { in bond_set_carrier()
348 if (slave->link == BOND_LINK_UP) { in bond_set_carrier()
365 /* Get link speed and duplex from the slave's base driver
371 static int bond_update_speed_duplex(struct slave *slave) in bond_update_speed_duplex() argument
373 struct net_device *slave_dev = slave->dev; in bond_update_speed_duplex()
377 slave->speed = SPEED_UNKNOWN; in bond_update_speed_duplex()
378 slave->duplex = DUPLEX_UNKNOWN; in bond_update_speed_duplex()
393 slave->speed = ecmd.base.speed; in bond_update_speed_duplex()
394 slave->duplex = ecmd.base.duplex; in bond_update_speed_duplex()
491 struct slave *curr_active = rtnl_dereference(bond->curr_active_slave); in bond_set_promiscuity()
496 struct slave *slave; in bond_set_promiscuity() local
498 bond_for_each_slave(bond, slave, iter) { in bond_set_promiscuity()
499 err = dev_set_promiscuity(slave->dev, inc); in bond_set_promiscuity()
514 struct slave *curr_active = rtnl_dereference(bond->curr_active_slave); in bond_set_allmulti()
519 struct slave *slave; in bond_set_allmulti() local
521 bond_for_each_slave(bond, slave, iter) { in bond_set_allmulti()
522 err = dev_set_allmulti(slave->dev, inc); in bond_set_allmulti()
532 * slave.
552 /* Flush bond's hardware addresses from slave */
569 /*--------------------------- Active slave change ---------------------------*/
576 static void bond_hw_addr_swap(struct bonding *bond, struct slave *new_active, in bond_hw_addr_swap()
577 struct slave *old_active) in bond_hw_addr_swap()
605 * bond_set_dev_addr - clone slave's address to bond
607 * @slave_dev: slave net device
628 static struct slave *bond_get_old_active(struct bonding *bond, in bond_get_old_active()
629 struct slave *new_active) in bond_get_old_active()
631 struct slave *slave; in bond_get_old_active() local
634 bond_for_each_slave(bond, slave, iter) { in bond_get_old_active()
635 if (slave == new_active) in bond_get_old_active()
638 if (ether_addr_equal(bond->dev->dev_addr, slave->dev->dev_addr)) in bond_get_old_active()
639 return slave; in bond_get_old_active()
652 struct slave *new_active, in bond_do_fail_over_mac()
653 struct slave *old_active) in bond_do_fail_over_mac()
664 slave_err(bond->dev, new_active->dev, "Error %d setting bond MAC from slave\n", in bond_do_fail_over_mac()
670 * if just old_active, do nothing (going to no active slave) in bond_do_fail_over_mac()
695 slave_err(bond->dev, new_active->dev, "Error %d setting MAC of new active slave\n", in bond_do_fail_over_mac()
710 slave_err(bond->dev, old_active->dev, "Error %d setting MAC of old active slave\n", in bond_do_fail_over_mac()
722 static struct slave *bond_choose_primary_or_current(struct bonding *bond) in bond_choose_primary_or_current()
724 struct slave *prim = rtnl_dereference(bond->primary_slave); in bond_choose_primary_or_current()
725 struct slave *curr = rtnl_dereference(bond->curr_active_slave); in bond_choose_primary_or_current()
761 * bond_find_best_slave - select the best available slave to be the active one
764 static struct slave *bond_find_best_slave(struct bonding *bond) in bond_find_best_slave()
766 struct slave *slave, *bestslave = NULL; in bond_find_best_slave() local
770 slave = bond_choose_primary_or_current(bond); in bond_find_best_slave()
771 if (slave) in bond_find_best_slave()
772 return slave; in bond_find_best_slave()
774 bond_for_each_slave(bond, slave, iter) { in bond_find_best_slave()
775 if (slave->link == BOND_LINK_UP) in bond_find_best_slave()
776 return slave; in bond_find_best_slave()
777 if (slave->link == BOND_LINK_BACK && bond_slave_is_up(slave) && in bond_find_best_slave()
778 slave->delay < mintime) { in bond_find_best_slave()
779 mintime = slave->delay; in bond_find_best_slave()
780 bestslave = slave; in bond_find_best_slave()
789 struct slave *slave; in bond_should_notify_peers() local
792 slave = rcu_dereference(bond->curr_active_slave); in bond_should_notify_peers()
795 netdev_dbg(bond->dev, "bond_should_notify_peers: slave %s\n", in bond_should_notify_peers()
796 slave ? slave->dev->name : "NULL"); in bond_should_notify_peers()
798 if (!slave || !bond->send_peer_notif || in bond_should_notify_peers()
802 test_bit(__LINK_STATE_LINKWATCH_PENDING, &slave->dev->state)) in bond_should_notify_peers()
809 * change_active_interface - change the active slave into the specified one
811 * @new: the new slave to make the active one
813 * Set the new slave to the bond's settings and unset them on the old
818 * because it is apparently the best available slave we have, even though its
823 void bond_change_active_slave(struct bonding *bond, struct slave *new_active) in bond_change_active_slave()
825 struct slave *old_active; in bond_change_active_slave()
906 /* resend IGMP joins since active slave has changed or in bond_change_active_slave()
920 * bond_select_active_slave - select a new active slave, if needed
926 * - A slave has got its link back and there's no old curr_active_slave.
932 struct slave *best_slave; in bond_select_active_slave()
952 static inline int slave_enable_netpoll(struct slave *slave) in slave_enable_netpoll() argument
962 err = __netpoll_setup(np, slave->dev); in slave_enable_netpoll()
967 slave->np = np; in slave_enable_netpoll()
971 static inline void slave_disable_netpoll(struct slave *slave) in slave_disable_netpoll() argument
973 struct netpoll *np = slave->np; in slave_disable_netpoll()
978 slave->np = NULL; in slave_disable_netpoll()
986 struct slave *slave = NULL; in bond_poll_controller() local
994 bond_for_each_slave_rcu(bond, slave, iter) { in bond_poll_controller()
995 if (!bond_slave_is_up(slave)) in bond_poll_controller()
1000 SLAVE_AD_INFO(slave)->port.aggregator; in bond_poll_controller()
1007 netpoll_poll_dev(slave->dev); in bond_poll_controller()
1015 struct slave *slave; in bond_netpoll_cleanup() local
1017 bond_for_each_slave(bond, slave, iter) in bond_netpoll_cleanup()
1018 if (bond_slave_is_up(slave)) in bond_netpoll_cleanup()
1019 slave_disable_netpoll(slave); in bond_netpoll_cleanup()
1026 struct slave *slave; in bond_netpoll_setup() local
1029 bond_for_each_slave(bond, slave, iter) { in bond_netpoll_setup()
1030 err = slave_enable_netpoll(slave); in bond_netpoll_setup()
1039 static inline int slave_enable_netpoll(struct slave *slave) in slave_enable_netpoll() argument
1043 static inline void slave_disable_netpoll(struct slave *slave) in slave_disable_netpoll() argument
1059 struct slave *slave; in bond_fix_features() local
1066 bond_for_each_slave(bond, slave, iter) { in bond_fix_features()
1068 slave->dev->features, in bond_fix_features()
1095 struct slave *slave; in bond_compute_features() local
1105 bond_for_each_slave(bond, slave, iter) { in bond_compute_features()
1107 slave->dev->vlan_features, BOND_VLAN_FEATURES); in bond_compute_features()
1110 slave->dev->hw_enc_features, in bond_compute_features()
1114 slave->dev->mpls_features, in bond_compute_features()
1117 dst_release_flag &= slave->dev->priv_flags; in bond_compute_features()
1118 if (slave->dev->hard_header_len > max_hard_header_len) in bond_compute_features()
1119 max_hard_header_len = slave->dev->hard_header_len; in bond_compute_features()
1121 gso_max_size = min(gso_max_size, slave->dev->gso_max_size); in bond_compute_features()
1122 gso_max_segs = min(gso_max_segs, slave->dev->gso_max_segs); in bond_compute_features()
1157 /* On bonding slaves other than the currently active slave, suppress
1161 struct slave *slave, in bond_should_deliver_exact_match() argument
1164 if (bond_is_slave_inactive(slave)) { in bond_should_deliver_exact_match()
1177 struct slave *slave; in bond_handle_frame() local
1180 struct slave *); in bond_handle_frame()
1189 slave = bond_slave_get_rcu(skb->dev); in bond_handle_frame()
1190 bond = slave->bond; in bond_handle_frame()
1194 ret = recv_probe(skb, bond, slave); in bond_handle_frame()
1205 * inactive slave links without being forced to bind to them in bond_handle_frame()
1212 if (bond_should_deliver_exact_match(skb, slave, bond)) { in bond_handle_frame()
1275 static int bond_master_upper_dev_link(struct bonding *bond, struct slave *slave, in bond_master_upper_dev_link() argument
1285 return netdev_master_upper_dev_link(slave->dev, bond->dev, slave, in bond_master_upper_dev_link()
1289 static void bond_upper_dev_unlink(struct bonding *bond, struct slave *slave) in bond_upper_dev_unlink() argument
1291 netdev_upper_dev_unlink(slave->dev, bond->dev); in bond_upper_dev_unlink()
1292 slave->dev->flags &= ~IFF_SLAVE; in bond_upper_dev_unlink()
1295 static struct slave *bond_alloc_slave(struct bonding *bond) in bond_alloc_slave()
1297 struct slave *slave = NULL; in bond_alloc_slave() local
1299 slave = kzalloc(sizeof(*slave), GFP_KERNEL); in bond_alloc_slave()
1300 if (!slave) in bond_alloc_slave()
1304 SLAVE_AD_INFO(slave) = kzalloc(sizeof(struct ad_slave_info), in bond_alloc_slave()
1306 if (!SLAVE_AD_INFO(slave)) { in bond_alloc_slave()
1307 kfree(slave); in bond_alloc_slave()
1311 INIT_DELAYED_WORK(&slave->notify_work, bond_netdev_notify_work); in bond_alloc_slave()
1313 return slave; in bond_alloc_slave()
1316 static void bond_free_slave(struct slave *slave) in bond_free_slave() argument
1318 struct bonding *bond = bond_get_bond_by_slave(slave); in bond_free_slave()
1320 cancel_delayed_work_sync(&slave->notify_work); in bond_free_slave()
1322 kfree(SLAVE_AD_INFO(slave)); in bond_free_slave()
1324 kfree(slave); in bond_free_slave()
1334 static void bond_fill_ifslave(struct slave *slave, struct ifslave *info) in bond_fill_ifslave() argument
1336 strcpy(info->slave_name, slave->dev->name); in bond_fill_ifslave()
1337 info->link = slave->link; in bond_fill_ifslave()
1338 info->state = bond_slave_state(slave); in bond_fill_ifslave()
1339 info->link_failure_count = slave->link_failure_count; in bond_fill_ifslave()
1344 struct slave *slave = container_of(_work, struct slave, in bond_netdev_notify_work() local
1350 bond_fill_ifslave(slave, &binfo.slave); in bond_netdev_notify_work()
1351 bond_fill_ifbond(slave->bond, &binfo.master); in bond_netdev_notify_work()
1352 netdev_bonding_info_change(slave->dev, &binfo); in bond_netdev_notify_work()
1355 queue_delayed_work(slave->bond->wq, &slave->notify_work, 1); in bond_netdev_notify_work()
1359 void bond_queue_slave_event(struct slave *slave) in bond_queue_slave_event() argument
1361 queue_delayed_work(slave->bond->wq, &slave->notify_work, 0); in bond_queue_slave_event()
1364 void bond_lower_state_changed(struct slave *slave) in bond_lower_state_changed() argument
1368 info.link_up = slave->link == BOND_LINK_UP || in bond_lower_state_changed()
1369 slave->link == BOND_LINK_FAIL; in bond_lower_state_changed()
1370 info.tx_enabled = bond_is_active_slave(slave); in bond_lower_state_changed()
1371 netdev_lower_state_changed(slave->dev, &info); in bond_lower_state_changed()
1374 /* enslave device <slave> to bond device <master> */
1380 struct slave *new_slave = NULL, *prev_slave; in bond_enslave()
1411 …slave_err(bond_dev, slave_dev, "Error: cannot enslave VLAN challenged slave on VLAN enabled bond\n… in bond_enslave()
1414 …slave_warn(bond_dev, slave_dev, "enslaved VLAN challenged slave. Adding VLANs will be blocked as l… in bond_enslave()
1421 * be identified with moderate accuracy by the state of the slave: in bond_enslave()
1427 slave_err(bond_dev, slave_dev, "slave is up - this may be due to an out of date ifenslave\n"); in bond_enslave()
1431 /* set bonding device ether type by slave - bonding netdevices are in bond_enslave()
1432 * created with ether_setup, so when the slave type is not ARPHRD_ETHER in bond_enslave()
1483 …slave_warn(bond_dev, slave_dev, "The slave device specified does not support setting the MAC addre… in bond_enslave()
1490 …NL_SET_ERR_MSG(extack, "Slave device does not support setting the MAC address, but fail_over_mac i… in bond_enslave()
1491 …slave_err(bond_dev, slave_dev, "The slave device specified does not support setting the MAC addres… in bond_enslave()
1500 /* If this is the first slave, then we need to set the master's hardware in bond_enslave()
1501 * address to be the same as the slave's. in bond_enslave()
1523 /* Save slave's original mtu and then set it to match the bond */ in bond_enslave()
1531 /* Save slave's original ("permanent") mac address for modes in bond_enslave()
1540 /* Set slave to master's mac address. The application already in bond_enslave()
1541 * set the master's mac address to that of the first slave in bond_enslave()
1553 /* set slave flag before open to prevent IPv6 addrconf */ in bond_enslave()
1556 /* open the slave since the application closed it */ in bond_enslave()
1559 slave_err(bond_dev, slave_dev, "Opening slave failed\n"); in bond_enslave()
1564 /* initialize slave stats */ in bond_enslave()
1608 …slave_warn(bond_dev, slave_dev, "MII and ETHTOOL support not available for slave, and arp_interval… in bond_enslave()
1611 …slave_warn(bond_dev, slave_dev, "can't get link status from slave; the network driver associated w… in bond_enslave()
1645 slave_dbg(bond_dev, slave_dev, "Initial state of slave is BOND_LINK_%s\n", in bond_enslave()
1650 /* if there is a primary slave, remember it */ in bond_enslave()
1668 /* if this is the first slave */ in bond_enslave()
1688 slave_dbg(bond_dev, slave_dev, "This slave is always active in trunk mode\n"); in bond_enslave()
1707 …slave_info(bond_dev, slave_dev, "master_dev is using netpoll, but new slave device does not suppor… in bond_enslave()
1740 /* set promiscuity level to new slave */ in bond_enslave()
1747 /* set allmulti level to new slave */ in bond_enslave()
1826 * MAC if this slave's MAC is in use by the bond, or at in bond_enslave()
1842 /* Enslave of first slave has failed and we need to fix master's mac */ in bond_enslave()
1858 /* Try to release the slave device <slave> from the bond device <master>
1863 * The rules for slave state should be:
1874 struct slave *slave, *oldcurrent; in __bond_release_one() local
1879 /* slave is not a slave or master is not master of this slave */ in __bond_release_one()
1882 slave_dbg(bond_dev, slave_dev, "cannot release slave\n"); in __bond_release_one()
1888 slave = bond_get_slave_by_dev(bond, slave_dev); in __bond_release_one()
1889 if (!slave) { in __bond_release_one()
1890 /* not a slave of this bond */ in __bond_release_one()
1896 bond_set_slave_inactive_flags(slave, BOND_SLAVE_NOTIFY_NOW); in __bond_release_one()
1898 bond_sysfs_slave_del(slave); in __bond_release_one()
1900 /* recompute stats just before removing the slave */ in __bond_release_one()
1903 bond_upper_dev_unlink(bond, slave); in __bond_release_one()
1905 * for this slave anymore. in __bond_release_one()
1910 bond_3ad_unbind_slave(slave); in __bond_release_one()
1913 bond_update_slave_arr(bond, slave); in __bond_release_one()
1916 bond_is_active_slave(slave) ? "active" : "backup"); in __bond_release_one()
1924 if (ether_addr_equal_64bits(bond_dev->dev_addr, slave->perm_hwaddr) && in __bond_release_one()
1926 …ond_dev, slave_dev, "the permanent HWaddr of slave - %pM - is still in use by bond - set the HWadd… in __bond_release_one()
1927 slave->perm_hwaddr); in __bond_release_one()
1930 if (rtnl_dereference(bond->primary_slave) == slave) in __bond_release_one()
1933 if (oldcurrent == slave) in __bond_release_one()
1937 /* Must be called only after the slave has been in __bond_release_one()
1940 * but before a new active slave is selected. in __bond_release_one()
1942 bond_alb_deinit_slave(bond, slave); in __bond_release_one()
1947 } else if (oldcurrent == slave) { in __bond_release_one()
1949 * is no concern that another slave add/remove event in __bond_release_one()
1972 …slave_info(bond_dev, slave_dev, "last VLAN challenged slave left bond - VLAN blocking is removed\n… in __bond_release_one()
1980 /* unset promiscuity level from slave in __bond_release_one()
1984 * when this slave was attached, so we cache at the start of the in __bond_release_one()
1990 /* unset allmulti level from slave */ in __bond_release_one()
1997 slave_disable_netpoll(slave); in __bond_release_one()
1999 /* close slave before restoring its mac address */ in __bond_release_one()
2005 bond_hw_addr_copy(ss.__data, slave->perm_hwaddr, in __bond_release_one()
2006 slave->dev->addr_len); in __bond_release_one()
2012 __dev_set_mtu(slave_dev, slave->original_mtu); in __bond_release_one()
2014 dev_set_mtu(slave_dev, slave->original_mtu); in __bond_release_one()
2019 bond_free_slave(slave); in __bond_release_one()
2030 /* First release a slave and then destroy the bond if no more slaves are left.
2060 struct slave *slave; in bond_slave_info_query() local
2062 bond_for_each_slave(bond, slave, iter) { in bond_slave_info_query()
2065 bond_fill_ifslave(slave, info); in bond_slave_info_query()
2080 struct slave *slave; in bond_miimon_inspect() local
2085 bond_for_each_slave_rcu(bond, slave, iter) { in bond_miimon_inspect()
2086 bond_propose_link_state(slave, BOND_LINK_NOCHANGE); in bond_miimon_inspect()
2088 link_state = bond_check_dev_link(bond, slave->dev, 0); in bond_miimon_inspect()
2090 switch (slave->link) { in bond_miimon_inspect()
2095 bond_propose_link_state(slave, BOND_LINK_FAIL); in bond_miimon_inspect()
2097 slave->delay = bond->params.downdelay; in bond_miimon_inspect()
2098 if (slave->delay) { in bond_miimon_inspect()
2099 slave_info(bond->dev, slave->dev, "link status down for %sinterface, disabling it in %d ms\n", in bond_miimon_inspect()
2102 (bond_is_active_slave(slave) ? in bond_miimon_inspect()
2110 bond_propose_link_state(slave, BOND_LINK_UP); in bond_miimon_inspect()
2111 slave->last_link_up = jiffies; in bond_miimon_inspect()
2112 slave_info(bond->dev, slave->dev, "link status up again after %d ms\n", in bond_miimon_inspect()
2113 (bond->params.downdelay - slave->delay) * in bond_miimon_inspect()
2119 if (slave->delay <= 0) { in bond_miimon_inspect()
2120 bond_propose_link_state(slave, BOND_LINK_DOWN); in bond_miimon_inspect()
2125 slave->delay--; in bond_miimon_inspect()
2132 bond_propose_link_state(slave, BOND_LINK_BACK); in bond_miimon_inspect()
2134 slave->delay = bond->params.updelay; in bond_miimon_inspect()
2136 if (slave->delay) { in bond_miimon_inspect()
2137 slave_info(bond->dev, slave->dev, "link status up, enabling it in %d ms\n", in bond_miimon_inspect()
2145 bond_propose_link_state(slave, BOND_LINK_DOWN); in bond_miimon_inspect()
2146 slave_info(bond->dev, slave->dev, "link status down again after %d ms\n", in bond_miimon_inspect()
2147 (bond->params.updelay - slave->delay) * in bond_miimon_inspect()
2154 slave->delay = 0; in bond_miimon_inspect()
2156 if (slave->delay <= 0) { in bond_miimon_inspect()
2157 bond_propose_link_state(slave, BOND_LINK_UP); in bond_miimon_inspect()
2163 slave->delay--; in bond_miimon_inspect()
2172 struct slave *slave, in bond_miimon_link_change() argument
2177 bond_3ad_handle_link_change(slave, link); in bond_miimon_link_change()
2181 bond_alb_handle_link_change(bond, slave, link); in bond_miimon_link_change()
2192 struct slave *slave, *primary; in bond_miimon_commit() local
2194 bond_for_each_slave(bond, slave, iter) { in bond_miimon_commit()
2195 switch (slave->link_new_state) { in bond_miimon_commit()
2197 /* For 802.3ad mode, check current slave speed and in bond_miimon_commit()
2204 slave->link == BOND_LINK_UP) in bond_miimon_commit()
2205 bond_3ad_adapter_speed_duplex_changed(slave); in bond_miimon_commit()
2209 if (bond_update_speed_duplex(slave) && in bond_miimon_commit()
2211 slave->link = BOND_LINK_DOWN; in bond_miimon_commit()
2213 slave_warn(bond->dev, slave->dev, in bond_miimon_commit()
2217 bond_set_slave_link_state(slave, BOND_LINK_UP, in bond_miimon_commit()
2219 slave->last_link_up = jiffies; in bond_miimon_commit()
2224 bond_set_backup_slave(slave); in bond_miimon_commit()
2227 bond_set_active_slave(slave); in bond_miimon_commit()
2228 } else if (slave != primary) { in bond_miimon_commit()
2230 bond_set_backup_slave(slave); in bond_miimon_commit()
2233 slave_info(bond->dev, slave->dev, "link status definitely up, %u Mbps %s duplex\n", in bond_miimon_commit()
2234 slave->speed == SPEED_UNKNOWN ? 0 : slave->speed, in bond_miimon_commit()
2235 slave->duplex ? "full" : "half"); in bond_miimon_commit()
2237 bond_miimon_link_change(bond, slave, BOND_LINK_UP); in bond_miimon_commit()
2239 if (!bond->curr_active_slave || slave == primary) in bond_miimon_commit()
2245 if (slave->link_failure_count < UINT_MAX) in bond_miimon_commit()
2246 slave->link_failure_count++; in bond_miimon_commit()
2248 bond_set_slave_link_state(slave, BOND_LINK_DOWN, in bond_miimon_commit()
2253 bond_set_slave_inactive_flags(slave, in bond_miimon_commit()
2256 slave_info(bond->dev, slave->dev, "link status definitely down, disabling slave\n"); in bond_miimon_commit()
2258 bond_miimon_link_change(bond, slave, BOND_LINK_DOWN); in bond_miimon_commit()
2260 if (slave == rcu_access_pointer(bond->curr_active_slave)) in bond_miimon_commit()
2266 slave_err(bond->dev, slave->dev, "invalid new link %d on slave\n", in bond_miimon_commit()
2267 slave->link_new_state); in bond_miimon_commit()
2268 bond_propose_link_state(slave, BOND_LINK_NOCHANGE); in bond_miimon_commit()
2296 struct slave *slave; in bond_mii_monitor() local
2325 bond_for_each_slave(bond, slave, iter) { in bond_mii_monitor()
2326 bond_commit_link_state(slave, BOND_SLAVE_NOTIFY_LATER); in bond_mii_monitor()
2371 static void bond_arp_send(struct slave *slave, int arp_op, __be32 dest_ip, in bond_arp_send() argument
2376 struct net_device *slave_dev = slave->dev; in bond_arp_send()
2377 struct net_device *bond_dev = slave->bond->dev; in bond_arp_send()
2379 slave_dbg(bond_dev, slave_dev, "arp %d on slave: dst %pI4 src %pI4\n", in bond_arp_send()
2465 static void bond_arp_send_all(struct bonding *bond, struct slave *slave) in bond_arp_send_all() argument
2473 slave_dbg(bond->dev, slave->dev, "%s: target %pI4\n", in bond_arp_send_all()
2488 bond_arp_send(slave, ARPOP_REQUEST, targets[i], in bond_arp_send_all()
2505 slave_dbg(bond->dev, slave->dev, "no path to arp_ip_target %pI4 via rt.dev %s\n", in bond_arp_send_all()
2514 bond_arp_send(slave, ARPOP_REQUEST, targets[i], addr, tags); in bond_arp_send_all()
2519 static void bond_validate_arp(struct bonding *bond, struct slave *slave, __be32 sip, __be32 tip) in bond_validate_arp() argument
2524 slave_dbg(bond->dev, slave->dev, "%s: sip %pI4 tip %pI4 not found\n", in bond_validate_arp()
2531 slave_dbg(bond->dev, slave->dev, "%s: sip %pI4 not found in targets\n", in bond_validate_arp()
2535 slave->last_rx = jiffies; in bond_validate_arp()
2536 slave->target_last_arp_rx[i] = jiffies; in bond_validate_arp()
2540 struct slave *slave) in bond_arp_rcv() argument
2543 struct slave *curr_active_slave, *curr_arp_slave; in bond_arp_rcv()
2549 if (!slave_do_arp_validate(bond, slave)) { in bond_arp_rcv()
2552 slave->last_rx = jiffies; in bond_arp_rcv()
2560 slave_dbg(bond->dev, slave->dev, "%s: skb->dev %s\n", in bond_arp_rcv()
2585 slave_dbg(bond->dev, slave->dev, "%s: %s/%d av %d sv %d sip %pI4 tip %pI4\n", in bond_arp_rcv()
2586 __func__, slave->dev->name, bond_slave_state(slave), in bond_arp_rcv()
2587 bond->params.arp_validate, slave_do_arp_validate(bond, slave), in bond_arp_rcv()
2595 * (a) the slave receiving the ARP is active (which includes the in bond_arp_rcv()
2596 * current ARP slave, if any), or in bond_arp_rcv()
2598 * (b) the receiving slave isn't active, but there is a currently in bond_arp_rcv()
2599 * active slave and it received valid arp reply(s) after it became in bond_arp_rcv()
2600 * the currently active slave, or in bond_arp_rcv()
2602 * (c) there is an ARP slave that sent an ARP during the prior ARP in bond_arp_rcv()
2603 * interval, and we receive an ARP reply on any slave. We accept in bond_arp_rcv()
2605 * reply to a slave other than the sender of the ARP request. in bond_arp_rcv()
2609 * slave through the L2 switch(es) to the receiving slave. Since in bond_arp_rcv()
2616 if (bond_is_active_slave(slave)) in bond_arp_rcv()
2617 bond_validate_arp(bond, slave, sip, tip); in bond_arp_rcv()
2621 bond_validate_arp(bond, slave, tip, sip); in bond_arp_rcv()
2625 bond_validate_arp(bond, slave, sip, tip); in bond_arp_rcv()
2647 /* This function is called regularly to monitor each slave's link
2655 struct slave *slave, *oldcurrent; in bond_loadbalance_arp_mon() local
2667 * the picture unless it is null. also, slave->last_link_up is not in bond_loadbalance_arp_mon()
2668 * needed here because we send an arp on each slave and give a slave in bond_loadbalance_arp_mon()
2673 bond_for_each_slave_rcu(bond, slave, iter) { in bond_loadbalance_arp_mon()
2674 unsigned long trans_start = dev_trans_start(slave->dev); in bond_loadbalance_arp_mon()
2676 bond_propose_link_state(slave, BOND_LINK_NOCHANGE); in bond_loadbalance_arp_mon()
2678 if (slave->link != BOND_LINK_UP) { in bond_loadbalance_arp_mon()
2680 bond_time_in_interval(bond, slave->last_rx, 1)) { in bond_loadbalance_arp_mon()
2682 bond_propose_link_state(slave, BOND_LINK_UP); in bond_loadbalance_arp_mon()
2686 * mode. the window of a slave being up and in bond_loadbalance_arp_mon()
2691 slave_info(bond->dev, slave->dev, "link status definitely up\n"); in bond_loadbalance_arp_mon()
2694 slave_info(bond->dev, slave->dev, "interface is now up\n"); in bond_loadbalance_arp_mon()
2698 /* slave->link == BOND_LINK_UP */ in bond_loadbalance_arp_mon()
2705 !bond_time_in_interval(bond, slave->last_rx, 2)) { in bond_loadbalance_arp_mon()
2707 bond_propose_link_state(slave, BOND_LINK_DOWN); in bond_loadbalance_arp_mon()
2710 if (slave->link_failure_count < UINT_MAX) in bond_loadbalance_arp_mon()
2711 slave->link_failure_count++; in bond_loadbalance_arp_mon()
2713 slave_info(bond->dev, slave->dev, "interface is now down\n"); in bond_loadbalance_arp_mon()
2715 if (slave == oldcurrent) in bond_loadbalance_arp_mon()
2727 if (bond_slave_is_up(slave)) in bond_loadbalance_arp_mon()
2728 bond_arp_send_all(bond, slave); in bond_loadbalance_arp_mon()
2737 bond_for_each_slave(bond, slave, iter) { in bond_loadbalance_arp_mon()
2738 if (slave->link_new_state != BOND_LINK_NOCHANGE) in bond_loadbalance_arp_mon()
2739 slave->link = slave->link_new_state; in bond_loadbalance_arp_mon()
2763 * should take place for the slave. Returns 0 if no changes are found, >0
2772 struct slave *slave; in bond_ab_arp_inspect() local
2775 bond_for_each_slave_rcu(bond, slave, iter) { in bond_ab_arp_inspect()
2776 bond_propose_link_state(slave, BOND_LINK_NOCHANGE); in bond_ab_arp_inspect()
2777 last_rx = slave_last_rx(bond, slave); in bond_ab_arp_inspect()
2779 if (slave->link != BOND_LINK_UP) { in bond_ab_arp_inspect()
2781 bond_propose_link_state(slave, BOND_LINK_UP); in bond_ab_arp_inspect()
2791 if (bond_time_in_interval(bond, slave->last_link_up, 2)) in bond_ab_arp_inspect()
2794 /* Backup slave is down if: in bond_ab_arp_inspect()
2803 * gives each slave a chance to tx/rx traffic in bond_ab_arp_inspect()
2806 if (!bond_is_active_slave(slave) && in bond_ab_arp_inspect()
2809 bond_propose_link_state(slave, BOND_LINK_DOWN); in bond_ab_arp_inspect()
2813 /* Active slave is down if: in bond_ab_arp_inspect()
2818 trans_start = dev_trans_start(slave->dev); in bond_ab_arp_inspect()
2819 if (bond_is_active_slave(slave) && in bond_ab_arp_inspect()
2822 bond_propose_link_state(slave, BOND_LINK_DOWN); in bond_ab_arp_inspect()
2839 struct slave *slave; in bond_ab_arp_commit() local
2841 bond_for_each_slave(bond, slave, iter) { in bond_ab_arp_commit()
2842 switch (slave->link_new_state) { in bond_ab_arp_commit()
2847 trans_start = dev_trans_start(slave->dev); in bond_ab_arp_commit()
2848 if (rtnl_dereference(bond->curr_active_slave) != slave || in bond_ab_arp_commit()
2851 struct slave *current_arp_slave; in bond_ab_arp_commit()
2854 bond_set_slave_link_state(slave, BOND_LINK_UP, in bond_ab_arp_commit()
2863 slave_info(bond->dev, slave->dev, "link status definitely up\n"); in bond_ab_arp_commit()
2866 slave == rtnl_dereference(bond->primary_slave)) in bond_ab_arp_commit()
2874 if (slave->link_failure_count < UINT_MAX) in bond_ab_arp_commit()
2875 slave->link_failure_count++; in bond_ab_arp_commit()
2877 bond_set_slave_link_state(slave, BOND_LINK_DOWN, in bond_ab_arp_commit()
2879 bond_set_slave_inactive_flags(slave, in bond_ab_arp_commit()
2882 slave_info(bond->dev, slave->dev, "link status definitely down, disabling slave\n"); in bond_ab_arp_commit()
2884 if (slave == rtnl_dereference(bond->curr_active_slave)) { in bond_ab_arp_commit()
2892 slave_err(bond->dev, slave->dev, in bond_ab_arp_commit()
2893 "impossible: link_new_state %d on slave\n", in bond_ab_arp_commit()
2894 slave->link_new_state); in bond_ab_arp_commit()
2913 struct slave *slave, *before = NULL, *new_slave = NULL, in bond_ab_arp_probe() local
2931 * backup slave from the current_arp_slave and make it the candidate in bond_ab_arp_probe()
2943 bond_for_each_slave_rcu(bond, slave, iter) { in bond_ab_arp_probe()
2944 if (!found && !before && bond_slave_is_up(slave)) in bond_ab_arp_probe()
2945 before = slave; in bond_ab_arp_probe()
2947 if (found && !new_slave && bond_slave_is_up(slave)) in bond_ab_arp_probe()
2948 new_slave = slave; in bond_ab_arp_probe()
2953 * one the current slave so it is still marked in bond_ab_arp_probe()
2956 if (!bond_slave_is_up(slave) && slave->link == BOND_LINK_UP) { in bond_ab_arp_probe()
2957 bond_set_slave_link_state(slave, BOND_LINK_DOWN, in bond_ab_arp_probe()
2959 if (slave->link_failure_count < UINT_MAX) in bond_ab_arp_probe()
2960 slave->link_failure_count++; in bond_ab_arp_probe()
2962 bond_set_slave_inactive_flags(slave, in bond_ab_arp_probe()
2965 slave_info(bond->dev, slave->dev, "backup interface is now down\n"); in bond_ab_arp_probe()
2967 if (slave == curr_arp_slave) in bond_ab_arp_probe()
2985 bond_for_each_slave_rcu(bond, slave, iter) { in bond_ab_arp_probe()
2986 if (slave->should_notify || slave->should_notify_link) { in bond_ab_arp_probe()
3098 struct slave *slave = bond_slave_get_rtnl(slave_dev), *primary; in bond_slave_netdev_event() local
3104 * slave will be NULL in bond_slave_netdev_event()
3106 if (!slave) { in bond_slave_netdev_event()
3107 netdev_dbg(slave_dev, "%s called on NULL slave\n", __func__); in bond_slave_netdev_event()
3111 bond_dev = slave->bond->dev; in bond_slave_netdev_event()
3112 bond = slave->bond; in bond_slave_netdev_event()
3127 * Getting invalid Speed/Duplex values here will put slave in bond_slave_netdev_event()
3133 if (bond_update_speed_duplex(slave) && in bond_slave_netdev_event()
3135 if (slave->last_link_up) in bond_slave_netdev_event()
3136 slave->link = BOND_LINK_FAIL; in bond_slave_netdev_event()
3138 slave->link = BOND_LINK_DOWN; in bond_slave_netdev_event()
3142 bond_3ad_adapter_speed_duplex_changed(slave); in bond_slave_netdev_event()
3145 /* Refresh slave-array if applicable! in bond_slave_netdev_event()
3147 * then these events will not cause the slave-array to be in bond_slave_netdev_event()
3148 * refreshed. This will cause xmit to use a slave that is not in bond_slave_netdev_event()
3164 * take over the slave's change_mtu in bond_slave_netdev_event()
3175 if (slave == primary) { in bond_slave_netdev_event()
3176 /* slave's name changed - he's no longer primary */ in bond_slave_netdev_event()
3179 /* we have a new primary slave */ in bond_slave_netdev_event()
3180 rcu_assign_pointer(bond->primary_slave, slave); in bond_slave_netdev_event()
3185 netdev_info(bond->dev, "Primary slave changed to %s, reselecting active slave\n", in bond_slave_netdev_event()
3197 call_netdevice_notifiers(event, slave->bond->dev); in bond_slave_netdev_event()
3210 * locks for us to safely manipulate the slave devices (RTNL lock,
3353 struct slave *slave; in bond_open() local
3355 /* reset slave->backup and slave->inactive */ in bond_open()
3357 bond_for_each_slave(bond, slave, iter) { in bond_open()
3359 slave != rcu_access_pointer(bond->curr_active_slave)) { in bond_open()
3360 bond_set_slave_inactive_flags(slave, in bond_open()
3363 bond_set_slave_active_flags(slave, in bond_open()
3448 struct slave *slave; in bond_get_stats() local
3454 bond_for_each_slave_rcu(bond, slave, iter) { in bond_get_stats()
3456 dev_get_stats(slave->dev, &temp); in bond_get_stats()
3458 bond_fold_stats(stats, new, &slave->slave_stats); in bond_get_stats()
3460 /* save off the slave stats for the next run */ in bond_get_stats()
3461 memcpy(&slave->slave_stats, new, sizeof(*new)); in bond_get_stats()
3591 struct slave *slave; in bond_set_rx_mode() local
3595 slave = rcu_dereference(bond->curr_active_slave); in bond_set_rx_mode()
3596 if (slave) { in bond_set_rx_mode()
3597 dev_uc_sync(slave->dev, bond_dev); in bond_set_rx_mode()
3598 dev_mc_sync(slave->dev, bond_dev); in bond_set_rx_mode()
3601 bond_for_each_slave_rcu(bond, slave, iter) { in bond_set_rx_mode()
3602 dev_uc_sync_multiple(slave->dev, bond_dev); in bond_set_rx_mode()
3603 dev_mc_sync_multiple(slave->dev, bond_dev); in bond_set_rx_mode()
3614 struct slave *slave; in bond_neigh_init() local
3617 slave = bond_first_slave(bond); in bond_neigh_init()
3618 if (!slave) in bond_neigh_init()
3620 slave_ops = slave->dev->netdev_ops; in bond_neigh_init()
3626 ret = slave_ops->ndo_neigh_setup(slave->dev, &parms); in bond_neigh_init()
3630 /* Assign slave's neigh_cleanup to neighbour in case cleanup is called in bond_neigh_init()
3631 * after the last slave has been detached. Assumes that all slaves in bond_neigh_init()
3644 * slave exists. So we must declare proxy setup function which will
3645 * be used at run time to resolve the actual slave neigh param setup.
3665 struct slave *slave, *rollback_slave; in bond_change_mtu() local
3671 bond_for_each_slave(bond, slave, iter) { in bond_change_mtu()
3672 slave_dbg(bond_dev, slave->dev, "s %p c_m %p\n", in bond_change_mtu()
3673 slave, slave->dev->netdev_ops->ndo_change_mtu); in bond_change_mtu()
3675 res = dev_set_mtu(slave->dev, new_mtu); in bond_change_mtu()
3678 /* If we failed to set the slave's mtu to the new value in bond_change_mtu()
3681 * different mtu values than the active slave we'll in bond_change_mtu()
3686 slave_dbg(bond_dev, slave->dev, "err %d setting mtu to %d\n", in bond_change_mtu()
3697 /* unwind from head to the slave that failed */ in bond_change_mtu()
3701 if (rollback_slave == slave) in bond_change_mtu()
3722 struct slave *slave, *rollback_slave; in bond_set_mac_address() local
3743 bond_for_each_slave(bond, slave, iter) { in bond_set_mac_address()
3744 slave_dbg(bond_dev, slave->dev, "%s: slave=%p\n", in bond_set_mac_address()
3745 __func__, slave); in bond_set_mac_address()
3746 res = dev_set_mac_address(slave->dev, addr, NULL); in bond_set_mac_address()
3748 /* TODO: consider downing the slave in bond_set_mac_address()
3754 slave_dbg(bond_dev, slave->dev, "%s: err %d\n", in bond_set_mac_address()
3768 /* unwind from head to the slave that failed */ in bond_set_mac_address()
3772 if (rollback_slave == slave) in bond_set_mac_address()
3787 * bond_xmit_slave_id - transmit skb through slave with slave_id
3790 * @slave_id: slave id up to slave_cnt-1 through which to transmit
3792 * This function tries to transmit through slave with slave_id but in case
3793 * it fails, it tries to find the first available slave for transmission.
3799 struct slave *slave; in bond_xmit_slave_id() local
3802 /* Here we start from the slave with slave_id */ in bond_xmit_slave_id()
3803 bond_for_each_slave_rcu(bond, slave, iter) { in bond_xmit_slave_id()
3805 if (bond_slave_can_tx(slave)) { in bond_xmit_slave_id()
3806 bond_dev_queue_xmit(bond, skb, slave->dev); in bond_xmit_slave_id()
3812 /* Here we start from the first slave up to slave_id */ in bond_xmit_slave_id()
3814 bond_for_each_slave_rcu(bond, slave, iter) { in bond_xmit_slave_id()
3817 if (bond_slave_can_tx(slave)) { in bond_xmit_slave_id()
3818 bond_dev_queue_xmit(bond, skb, slave->dev); in bond_xmit_slave_id()
3822 /* no slave that can tx has been found */ in bond_xmit_slave_id()
3827 * bond_rr_gen_slave_id - generate slave id based on packets_per_slave
3831 * this function generates a slave id, which is usually used as the next
3832 * slave to transmit through.
3863 struct slave *slave; in bond_xmit_roundrobin() local
3882 slave = rcu_dereference(bond->curr_active_slave); in bond_xmit_roundrobin()
3883 if (slave) in bond_xmit_roundrobin()
3884 bond_dev_queue_xmit(bond, skb, slave->dev); in bond_xmit_roundrobin()
3909 struct slave *slave; in bond_xmit_activebackup() local
3911 slave = rcu_dereference(bond->curr_active_slave); in bond_xmit_activebackup()
3912 if (slave) in bond_xmit_activebackup()
3913 bond_dev_queue_xmit(bond, skb, slave->dev); in bond_xmit_activebackup()
3929 /* Slave array work handler. Holds only RTNL */
3942 pr_warn_ratelimited("Failed to update slave array from WT\n"); in bond_slave_arr_handler()
3952 * to determine the slave interface -
3959 int bond_update_slave_arr(struct bonding *bond, struct slave *skipslave) in bond_update_slave_arr()
3961 struct slave *slave; in bond_update_slave_arr() local
3975 pr_err("Failed to build slave-array.\n"); in bond_update_slave_arr()
3996 bond_for_each_slave(bond, slave, iter) { in bond_update_slave_arr()
4000 agg = SLAVE_AD_INFO(slave)->port.aggregator; in bond_update_slave_arr()
4004 if (!bond_slave_can_tx(slave)) in bond_update_slave_arr()
4006 if (skipslave == slave) in bond_update_slave_arr()
4009 slave_dbg(bond->dev, slave->dev, "Adding slave to tx hash array[%d]\n", in bond_update_slave_arr()
4012 new_arr->arr[new_arr->count++] = slave; in bond_update_slave_arr()
4024 * slave but allocation failed (most likely!). BTW this is in bond_update_slave_arr()
4029 * this to-be-skipped slave to send a packet out. in bond_update_slave_arr()
4045 * usable slave array is formed in the control path. The xmit function
4052 struct slave *slave; in bond_3ad_xor_xmit() local
4059 slave = slaves->arr[bond_xmit_hash(bond, skb) % count]; in bond_3ad_xor_xmit()
4060 bond_dev_queue_xmit(bond, skb, slave->dev); in bond_3ad_xor_xmit()
4073 struct slave *slave = NULL; in bond_xmit_broadcast() local
4076 bond_for_each_slave_rcu(bond, slave, iter) { in bond_xmit_broadcast()
4077 if (bond_is_last_slave(bond, slave)) in bond_xmit_broadcast()
4079 if (bond_slave_is_up(slave) && slave->link == BOND_LINK_UP) { in bond_xmit_broadcast()
4087 bond_dev_queue_xmit(bond, skb2, slave->dev); in bond_xmit_broadcast()
4090 if (slave && bond_slave_is_up(slave) && slave->link == BOND_LINK_UP) in bond_xmit_broadcast()
4091 bond_dev_queue_xmit(bond, skb, slave->dev); in bond_xmit_broadcast()
4100 /* Lookup the slave that corresponds to a qid */
4104 struct slave *slave = NULL; in bond_slave_override() local
4111 bond_for_each_slave_rcu(bond, slave, iter) { in bond_slave_override()
4112 if (slave->queue_id == skb_get_queue_mapping(skb)) { in bond_slave_override()
4113 if (bond_slave_is_up(slave) && in bond_slave_override()
4114 slave->link == BOND_LINK_UP) { in bond_slave_override()
4115 bond_dev_queue_xmit(bond, skb, slave->dev); in bond_slave_override()
4118 /* If the slave isn't UP, use default transmit policy. */ in bond_slave_override()
4206 struct slave *slave; in bond_ethtool_get_link_ksettings() local
4216 bond_for_each_slave(bond, slave, iter) { in bond_ethtool_get_link_ksettings()
4217 if (bond_slave_can_tx(slave)) { in bond_ethtool_get_link_ksettings()
4218 if (slave->speed != SPEED_UNKNOWN) in bond_ethtool_get_link_ksettings()
4219 speed += slave->speed; in bond_ethtool_get_link_ksettings()
4221 slave->duplex != DUPLEX_UNKNOWN) in bond_ethtool_get_link_ksettings()
4222 cmd->base.duplex = slave->duplex; in bond_ethtool_get_link_ksettings()
4338 struct slave *slave; in bond_uninit() local
4344 bond_for_each_slave(bond, slave, iter) in bond_uninit()
4345 __bond_release_one(bond_dev, slave->dev, true, true); in bond_uninit()