Lines Matching full:slave
21 * the first slave bonded to the channel. All slaves will then use
28 * will attach eth0 to bond0 as a slave. eth0 hw mac address will either
154 MODULE_PARM_DESC(primary_reselect, "Reselect primary slave "
159 "2 for only on active slave "
198 MODULE_PARM_DESC(packets_per_slave, "Packets to send per slave in balance-rr "
199 "mode; 0 for a random slave, 1 packet per "
200 "slave (default), >1 packets per slave.");
295 * @slave_dev: slave that is supposed to xmit this skbuff
347 * We don't protect the slave list iteration with a lock because:
372 struct slave *slave, *rollback_slave; in bond_vlan_rx_add_vid() local
376 bond_for_each_slave(bond, slave, iter) { in bond_vlan_rx_add_vid()
377 res = vlan_vid_add(slave->dev, proto, vid); in bond_vlan_rx_add_vid()
385 /* unwind to the slave that failed */ in bond_vlan_rx_add_vid()
387 if (rollback_slave == slave) in bond_vlan_rx_add_vid()
407 struct slave *slave; in bond_vlan_rx_kill_vid() local
409 bond_for_each_slave(bond, slave, iter) in bond_vlan_rx_kill_vid()
410 vlan_vid_del(slave->dev, proto, vid); in bond_vlan_rx_kill_vid()
434 struct slave *slave; in bond_ipsec_add_sa() local
442 slave = rcu_dereference(bond->curr_active_slave); in bond_ipsec_add_sa()
443 real_dev = slave ? slave->dev : NULL; in bond_ipsec_add_sa()
454 NL_SET_ERR_MSG_MOD(extack, "Slave does not support ipsec offload"); in bond_ipsec_add_sa()
486 struct slave *slave; in bond_ipsec_add_sa_all() local
488 slave = rtnl_dereference(bond->curr_active_slave); in bond_ipsec_add_sa_all()
489 real_dev = slave ? slave->dev : NULL; in bond_ipsec_add_sa_all()
499 "%s: no slave xdo_dev_state_add\n", in bond_ipsec_add_sa_all()
530 struct slave *slave; in bond_ipsec_del_sa() local
537 slave = rcu_dereference(bond->curr_active_slave); in bond_ipsec_del_sa()
538 real_dev = slave ? slave->dev : NULL; in bond_ipsec_del_sa()
542 if (!slave) in bond_ipsec_del_sa()
553 slave_warn(bond_dev, real_dev, "%s: no slave xdo_dev_state_delete\n", __func__); in bond_ipsec_del_sa()
576 struct slave *slave; in bond_ipsec_del_sa_all() local
578 slave = rtnl_dereference(bond->curr_active_slave); in bond_ipsec_del_sa_all()
579 real_dev = slave ? slave->dev : NULL; in bond_ipsec_del_sa_all()
592 "%s: no slave xdo_dev_state_delete\n", in bond_ipsec_del_sa_all()
609 struct slave *slave; in bond_ipsec_free_sa() local
616 slave = rcu_dereference(bond->curr_active_slave); in bond_ipsec_free_sa()
617 real_dev = slave ? slave->dev : NULL; in bond_ipsec_free_sa()
621 if (!slave) in bond_ipsec_free_sa()
645 struct slave *curr_active; in bond_ipsec_offload_ok()
692 struct slave *slave; in bond_set_carrier() local
700 bond_for_each_slave(bond, slave, iter) { in bond_set_carrier()
701 if (slave->link == BOND_LINK_UP) { in bond_set_carrier()
718 /* Get link speed and duplex from the slave's base driver
724 static int bond_update_speed_duplex(struct slave *slave) in bond_update_speed_duplex() argument
726 struct net_device *slave_dev = slave->dev; in bond_update_speed_duplex()
730 slave->speed = SPEED_UNKNOWN; in bond_update_speed_duplex()
731 slave->duplex = DUPLEX_UNKNOWN; in bond_update_speed_duplex()
746 slave->speed = ecmd.base.speed; in bond_update_speed_duplex()
747 slave->duplex = ecmd.base.duplex; in bond_update_speed_duplex()
844 struct slave *curr_active = rtnl_dereference(bond->curr_active_slave); in bond_set_promiscuity()
849 struct slave *slave; in bond_set_promiscuity() local
851 bond_for_each_slave(bond, slave, iter) { in bond_set_promiscuity()
852 err = dev_set_promiscuity(slave->dev, inc); in bond_set_promiscuity()
867 struct slave *curr_active = rtnl_dereference(bond->curr_active_slave); in bond_set_allmulti()
872 struct slave *slave; in bond_set_allmulti() local
874 bond_for_each_slave(bond, slave, iter) { in bond_set_allmulti()
875 err = dev_set_allmulti(slave->dev, inc); in bond_set_allmulti()
885 * slave.
905 /* Flush bond's hardware addresses from slave */
918 /*--------------------------- Active slave change ---------------------------*/
925 static void bond_hw_addr_swap(struct bonding *bond, struct slave *new_active, in bond_hw_addr_swap()
926 struct slave *old_active) in bond_hw_addr_swap()
961 * bond_set_dev_addr - clone slave's address to bond
963 * @slave_dev: slave net device
984 static struct slave *bond_get_old_active(struct bonding *bond, in bond_get_old_active()
985 struct slave *new_active) in bond_get_old_active()
987 struct slave *slave; in bond_get_old_active() local
990 bond_for_each_slave(bond, slave, iter) { in bond_get_old_active()
991 if (slave == new_active) in bond_get_old_active()
994 if (ether_addr_equal(bond->dev->dev_addr, slave->dev->dev_addr)) in bond_get_old_active()
995 return slave; in bond_get_old_active()
1008 struct slave *new_active, in bond_do_fail_over_mac()
1009 struct slave *old_active) in bond_do_fail_over_mac()
1020 slave_err(bond->dev, new_active->dev, "Error %d setting bond MAC from slave\n", in bond_do_fail_over_mac()
1026 * if just old_active, do nothing (going to no active slave) in bond_do_fail_over_mac()
1051 slave_err(bond->dev, new_active->dev, "Error %d setting MAC of new active slave\n", in bond_do_fail_over_mac()
1066 slave_err(bond->dev, old_active->dev, "Error %d setting MAC of old active slave\n", in bond_do_fail_over_mac()
1079 * bond_choose_primary_or_current - select the primary or high priority slave
1086 * If the highest priority link is not current slave, set it as primary
1089 static struct slave *bond_choose_primary_or_current(struct bonding *bond) in bond_choose_primary_or_current()
1091 struct slave *prim = rtnl_dereference(bond->primary_slave); in bond_choose_primary_or_current()
1092 struct slave *curr = rtnl_dereference(bond->curr_active_slave); in bond_choose_primary_or_current()
1093 struct slave *slave, *hprio = NULL; in bond_choose_primary_or_current() local
1097 bond_for_each_slave(bond, slave, iter) { in bond_choose_primary_or_current()
1098 if (slave->link == BOND_LINK_UP) { in bond_choose_primary_or_current()
1099 hprio = hprio ?: slave; in bond_choose_primary_or_current()
1100 if (slave->prio > hprio->prio) in bond_choose_primary_or_current()
1101 hprio = slave; in bond_choose_primary_or_current()
1144 * bond_find_best_slave - select the best available slave to be the active one
1147 static struct slave *bond_find_best_slave(struct bonding *bond) in bond_find_best_slave()
1149 struct slave *slave, *bestslave = NULL; in bond_find_best_slave() local
1153 slave = bond_choose_primary_or_current(bond); in bond_find_best_slave()
1154 if (slave) in bond_find_best_slave()
1155 return slave; in bond_find_best_slave()
1157 bond_for_each_slave(bond, slave, iter) { in bond_find_best_slave()
1158 if (slave->link == BOND_LINK_UP) in bond_find_best_slave()
1159 return slave; in bond_find_best_slave()
1160 if (slave->link == BOND_LINK_BACK && bond_slave_is_up(slave) && in bond_find_best_slave()
1161 slave->delay < mintime) { in bond_find_best_slave()
1162 mintime = slave->delay; in bond_find_best_slave()
1163 bestslave = slave; in bond_find_best_slave()
1173 struct slave *slave = rcu_dereference_rtnl(bond->curr_active_slave); in bond_should_notify_peers() local
1175 if (!slave || !bond->send_peer_notif || in bond_should_notify_peers()
1179 test_bit(__LINK_STATE_LINKWATCH_PENDING, &slave->dev->state)) in bond_should_notify_peers()
1182 netdev_dbg(bond->dev, "bond_should_notify_peers: slave %s\n", in bond_should_notify_peers()
1183 slave ? slave->dev->name : "NULL"); in bond_should_notify_peers()
1189 * bond_change_active_slave - change the active slave into the specified one
1191 * @new_active: the new slave to make the active one
1193 * Set the new slave to the bond's settings and unset them on the old
1198 * because it is apparently the best available slave we have, even though its
1203 void bond_change_active_slave(struct bonding *bond, struct slave *new_active) in bond_change_active_slave()
1205 struct slave *old_active; in bond_change_active_slave()
1293 /* resend IGMP joins since active slave has changed or in bond_change_active_slave()
1307 * bond_select_active_slave - select a new active slave, if needed
1313 * - A slave has got its link back and there's no old curr_active_slave.
1319 struct slave *best_slave; in bond_select_active_slave()
1339 static inline int slave_enable_netpoll(struct slave *slave) in slave_enable_netpoll() argument
1349 err = __netpoll_setup(np, slave->dev); in slave_enable_netpoll()
1354 slave->np = np; in slave_enable_netpoll()
1358 static inline void slave_disable_netpoll(struct slave *slave) in slave_disable_netpoll() argument
1360 struct netpoll *np = slave->np; in slave_disable_netpoll()
1365 slave->np = NULL; in slave_disable_netpoll()
1373 struct slave *slave = NULL; in bond_poll_controller() local
1381 bond_for_each_slave_rcu(bond, slave, iter) { in bond_poll_controller()
1382 if (!bond_slave_is_up(slave)) in bond_poll_controller()
1387 SLAVE_AD_INFO(slave)->port.aggregator; in bond_poll_controller()
1394 netpoll_poll_dev(slave->dev); in bond_poll_controller()
1402 struct slave *slave; in bond_netpoll_cleanup() local
1404 bond_for_each_slave(bond, slave, iter) in bond_netpoll_cleanup()
1405 if (bond_slave_is_up(slave)) in bond_netpoll_cleanup()
1406 slave_disable_netpoll(slave); in bond_netpoll_cleanup()
1413 struct slave *slave; in bond_netpoll_setup() local
1416 bond_for_each_slave(bond, slave, iter) { in bond_netpoll_setup()
1417 err = slave_enable_netpoll(slave); in bond_netpoll_setup()
1426 static inline int slave_enable_netpoll(struct slave *slave) in slave_enable_netpoll() argument
1430 static inline void slave_disable_netpoll(struct slave *slave) in slave_disable_netpoll() argument
1446 struct slave *slave; in bond_fix_features() local
1453 bond_for_each_slave(bond, slave, iter) { in bond_fix_features()
1455 slave->dev->features, in bond_fix_features()
1487 struct slave *slave; in bond_compute_features() local
1497 bond_for_each_slave(bond, slave, iter) { in bond_compute_features()
1499 slave->dev->vlan_features, BOND_VLAN_FEATURES); in bond_compute_features()
1502 slave->dev->hw_enc_features, in bond_compute_features()
1507 slave->dev->hw_enc_features, in bond_compute_features()
1512 slave->dev->mpls_features, in bond_compute_features()
1515 dst_release_flag &= slave->dev->priv_flags; in bond_compute_features()
1516 if (slave->dev->hard_header_len > max_hard_header_len) in bond_compute_features()
1517 max_hard_header_len = slave->dev->hard_header_len; in bond_compute_features()
1519 tso_max_size = min(tso_max_size, slave->dev->tso_max_size); in bond_compute_features()
1520 tso_max_segs = min(tso_max_segs, slave->dev->tso_max_segs); in bond_compute_features()
1569 /* On bonding slaves other than the currently active slave, suppress
1573 struct slave *slave, in bond_should_deliver_exact_match() argument
1576 if (bond_is_slave_inactive(slave)) { in bond_should_deliver_exact_match()
1589 struct slave *slave; in bond_handle_frame() local
1592 struct slave *); in bond_handle_frame()
1601 slave = bond_slave_get_rcu(skb->dev); in bond_handle_frame()
1602 bond = slave->bond; in bond_handle_frame()
1606 ret = recv_probe(skb, bond, slave); in bond_handle_frame()
1617 * inactive slave links without being forced to bind to them in bond_handle_frame()
1624 if (bond_should_deliver_exact_match(skb, slave, bond)) { in bond_handle_frame()
1689 static int bond_master_upper_dev_link(struct bonding *bond, struct slave *slave, in bond_master_upper_dev_link() argument
1700 err = netdev_master_upper_dev_link(slave->dev, bond->dev, slave, in bond_master_upper_dev_link()
1705 slave->dev->flags |= IFF_SLAVE; in bond_master_upper_dev_link()
1709 static void bond_upper_dev_unlink(struct bonding *bond, struct slave *slave) in bond_upper_dev_unlink() argument
1711 netdev_upper_dev_unlink(slave->dev, bond->dev); in bond_upper_dev_unlink()
1712 slave->dev->flags &= ~IFF_SLAVE; in bond_upper_dev_unlink()
1717 struct slave *slave = to_slave(kobj); in slave_kobj_release() local
1718 struct bonding *bond = bond_get_bond_by_slave(slave); in slave_kobj_release()
1720 cancel_delayed_work_sync(&slave->notify_work); in slave_kobj_release()
1722 kfree(SLAVE_AD_INFO(slave)); in slave_kobj_release()
1724 kfree(slave); in slave_kobj_release()
1734 static int bond_kobj_init(struct slave *slave) in bond_kobj_init() argument
1738 err = kobject_init_and_add(&slave->kobj, &slave_ktype, in bond_kobj_init()
1739 &(slave->dev->dev.kobj), "bonding_slave"); in bond_kobj_init()
1741 kobject_put(&slave->kobj); in bond_kobj_init()
1746 static struct slave *bond_alloc_slave(struct bonding *bond, in bond_alloc_slave()
1749 struct slave *slave = NULL; in bond_alloc_slave() local
1751 slave = kzalloc(sizeof(*slave), GFP_KERNEL); in bond_alloc_slave()
1752 if (!slave) in bond_alloc_slave()
1755 slave->bond = bond; in bond_alloc_slave()
1756 slave->dev = slave_dev; in bond_alloc_slave()
1757 INIT_DELAYED_WORK(&slave->notify_work, bond_netdev_notify_work); in bond_alloc_slave()
1759 if (bond_kobj_init(slave)) in bond_alloc_slave()
1763 SLAVE_AD_INFO(slave) = kzalloc(sizeof(struct ad_slave_info), in bond_alloc_slave()
1765 if (!SLAVE_AD_INFO(slave)) { in bond_alloc_slave()
1766 kobject_put(&slave->kobj); in bond_alloc_slave()
1771 return slave; in bond_alloc_slave()
1781 static void bond_fill_ifslave(struct slave *slave, struct ifslave *info) in bond_fill_ifslave() argument
1783 strcpy(info->slave_name, slave->dev->name); in bond_fill_ifslave()
1784 info->link = slave->link; in bond_fill_ifslave()
1785 info->state = bond_slave_state(slave); in bond_fill_ifslave()
1786 info->link_failure_count = slave->link_failure_count; in bond_fill_ifslave()
1791 struct slave *slave = container_of(_work, struct slave, in bond_netdev_notify_work() local
1797 bond_fill_ifslave(slave, &binfo.slave); in bond_netdev_notify_work()
1798 bond_fill_ifbond(slave->bond, &binfo.master); in bond_netdev_notify_work()
1799 netdev_bonding_info_change(slave->dev, &binfo); in bond_netdev_notify_work()
1802 queue_delayed_work(slave->bond->wq, &slave->notify_work, 1); in bond_netdev_notify_work()
1806 void bond_queue_slave_event(struct slave *slave) in bond_queue_slave_event() argument
1808 queue_delayed_work(slave->bond->wq, &slave->notify_work, 0); in bond_queue_slave_event()
1811 void bond_lower_state_changed(struct slave *slave) in bond_lower_state_changed() argument
1815 info.link_up = slave->link == BOND_LINK_UP || in bond_lower_state_changed()
1816 slave->link == BOND_LINK_FAIL; in bond_lower_state_changed()
1817 info.tx_enabled = bond_is_active_slave(slave); in bond_lower_state_changed()
1818 netdev_lower_state_changed(slave->dev, &info); in bond_lower_state_changed()
1854 struct slave *slave; in bond_xdp_set_features() local
1863 bond_for_each_slave(bond, slave, iter) in bond_xdp_set_features()
1864 val &= slave->dev->xdp_features; in bond_xdp_set_features()
1871 /* enslave device <slave> to bond device <master> */
1877 struct slave *new_slave = NULL, *prev_slave; in bond_enslave()
1916 …slave_warn(bond_dev, slave_dev, "enslaved VLAN challenged slave. Adding VLANs will be blocked as l… in bond_enslave()
1926 * be identified with moderate accuracy by the state of the slave: in bond_enslave()
1936 /* set bonding device ether type by slave - bonding netdevices are in bond_enslave()
1937 * created with ether_setup, so when the slave type is not ARPHRD_ETHER in bond_enslave()
1984 …slave_warn(bond_dev, slave_dev, "The slave device specified does not support setting the MAC addre… in bond_enslave()
1992 … "Slave device does not support setting the MAC address, but fail_over_mac is not set to active"); in bond_enslave()
2001 /* If this is the first slave, then we need to set the master's hardware in bond_enslave()
2002 * address to be the same as the slave's. in bond_enslave()
2022 /* Save slave's original mtu and then set it to match the bond */ in bond_enslave()
2030 /* Save slave's original ("permanent") mac address for modes in bond_enslave()
2039 /* Set slave to master's mac address. The application already in bond_enslave()
2040 * set the master's mac address to that of the first slave in bond_enslave()
2055 /* open the slave since the application closed it */ in bond_enslave()
2058 slave_err(bond_dev, slave_dev, "Opening slave failed\n"); in bond_enslave()
2063 /* initialize slave stats */ in bond_enslave()
2109 …slave_warn(bond_dev, slave_dev, "MII and ETHTOOL support not available for slave, and arp_interval… in bond_enslave()
2112 …slave_warn(bond_dev, slave_dev, "can't get link status from slave; the network driver associated w… in bond_enslave()
2146 slave_dbg(bond_dev, slave_dev, "Initial state of slave is BOND_LINK_%s\n", in bond_enslave()
2151 /* if there is a primary slave, remember it */ in bond_enslave()
2169 /* if this is the first slave */ in bond_enslave()
2189 slave_dbg(bond_dev, slave_dev, "This slave is always active in trunk mode\n"); in bond_enslave()
2208 …slave_info(bond_dev, slave_dev, "master_dev is using netpoll, but new slave device does not suppor… in bond_enslave()
2243 /* set promiscuity level to new slave */ in bond_enslave()
2250 /* set allmulti level to new slave */ in bond_enslave()
2276 * remove the maddrs if the slave is selected as active slave. in bond_enslave()
2293 "Slave does not support XDP"); in bond_enslave()
2307 "Slave has XDP program loaded, please unload before enslaving"); in bond_enslave()
2366 * MAC if this slave's MAC is in use by the bond, or at in bond_enslave()
2382 /* Enslave of first slave has failed and we need to fix master's mac */ in bond_enslave()
2396 /* Try to release the slave device <slave> from the bond device <master>
2401 * The rules for slave state should be:
2412 struct slave *slave, *oldcurrent; in __bond_release_one() local
2417 /* slave is not a slave or master is not master of this slave */ in __bond_release_one()
2420 slave_dbg(bond_dev, slave_dev, "cannot release slave\n"); in __bond_release_one()
2426 slave = bond_get_slave_by_dev(bond, slave_dev); in __bond_release_one()
2427 if (!slave) { in __bond_release_one()
2428 /* not a slave of this bond */ in __bond_release_one()
2434 bond_set_slave_inactive_flags(slave, BOND_SLAVE_NOTIFY_NOW); in __bond_release_one()
2436 bond_sysfs_slave_del(slave); in __bond_release_one()
2438 /* recompute stats just before removing the slave */ in __bond_release_one()
2453 * for this slave anymore. in __bond_release_one()
2458 bond_3ad_unbind_slave(slave); in __bond_release_one()
2460 bond_upper_dev_unlink(bond, slave); in __bond_release_one()
2463 bond_update_slave_arr(bond, slave); in __bond_release_one()
2466 bond_is_active_slave(slave) ? "active" : "backup"); in __bond_release_one()
2474 if (ether_addr_equal_64bits(bond_dev->dev_addr, slave->perm_hwaddr) && in __bond_release_one()
2476 …ond_dev, slave_dev, "the permanent HWaddr of slave - %pM - is still in use by bond - set the HWadd… in __bond_release_one()
2477 slave->perm_hwaddr); in __bond_release_one()
2480 if (rtnl_dereference(bond->primary_slave) == slave) in __bond_release_one()
2483 if (oldcurrent == slave) in __bond_release_one()
2486 /* Must be called after bond_change_active_slave () as the slave in __bond_release_one()
2487 * might change from an active slave to a backup slave. Then it is in __bond_release_one()
2488 * necessary to clear the maddrs on the backup slave. in __bond_release_one()
2490 bond_slave_ns_maddrs_del(bond, slave); in __bond_release_one()
2493 /* Must be called only after the slave has been in __bond_release_one()
2496 * but before a new active slave is selected. in __bond_release_one()
2498 bond_alb_deinit_slave(bond, slave); in __bond_release_one()
2503 } else if (oldcurrent == slave) { in __bond_release_one()
2505 * is no concern that another slave add/remove event in __bond_release_one()
2527 …slave_info(bond_dev, slave_dev, "last VLAN challenged slave left bond - VLAN blocking is removed\n… in __bond_release_one()
2535 /* unset promiscuity level from slave in __bond_release_one()
2539 * when this slave was attached, so we cache at the start of the in __bond_release_one()
2545 /* unset allmulti level from slave */ in __bond_release_one()
2553 slave_disable_netpoll(slave); in __bond_release_one()
2555 /* close slave before restoring its mac address */ in __bond_release_one()
2563 bond_hw_addr_copy(ss.__data, slave->perm_hwaddr, in __bond_release_one()
2564 slave->dev->addr_len); in __bond_release_one()
2570 __dev_set_mtu(slave_dev, slave->original_mtu); in __bond_release_one()
2572 dev_set_mtu(slave_dev, slave->original_mtu); in __bond_release_one()
2578 kobject_put(&slave->kobj); in __bond_release_one()
2589 /* First release a slave and then destroy the bond if no more slaves are left.
2621 struct slave *slave; in bond_slave_info_query() local
2623 bond_for_each_slave(bond, slave, iter) { in bond_slave_info_query()
2626 bond_fill_ifslave(slave, info); in bond_slave_info_query()
2642 struct slave *slave; in bond_miimon_inspect() local
2655 bond_for_each_slave_rcu(bond, slave, iter) { in bond_miimon_inspect()
2656 bond_propose_link_state(slave, BOND_LINK_NOCHANGE); in bond_miimon_inspect()
2658 link_state = bond_check_dev_link(bond, slave->dev, 0); in bond_miimon_inspect()
2660 switch (slave->link) { in bond_miimon_inspect()
2665 bond_propose_link_state(slave, BOND_LINK_FAIL); in bond_miimon_inspect()
2667 slave->delay = bond->params.downdelay; in bond_miimon_inspect()
2668 if (slave->delay) { in bond_miimon_inspect()
2669 slave_info(bond->dev, slave->dev, "link status down for %sinterface, disabling it in %d ms\n", in bond_miimon_inspect()
2672 (bond_is_active_slave(slave) ? in bond_miimon_inspect()
2680 bond_propose_link_state(slave, BOND_LINK_UP); in bond_miimon_inspect()
2681 slave->last_link_up = jiffies; in bond_miimon_inspect()
2682 slave_info(bond->dev, slave->dev, "link status up again after %d ms\n", in bond_miimon_inspect()
2683 (bond->params.downdelay - slave->delay) * in bond_miimon_inspect()
2689 if (slave->delay <= 0) { in bond_miimon_inspect()
2690 bond_propose_link_state(slave, BOND_LINK_DOWN); in bond_miimon_inspect()
2695 slave->delay--; in bond_miimon_inspect()
2702 bond_propose_link_state(slave, BOND_LINK_BACK); in bond_miimon_inspect()
2704 slave->delay = bond->params.updelay; in bond_miimon_inspect()
2706 if (slave->delay) { in bond_miimon_inspect()
2707 slave_info(bond->dev, slave->dev, "link status up, enabling it in %d ms\n", in bond_miimon_inspect()
2715 bond_propose_link_state(slave, BOND_LINK_DOWN); in bond_miimon_inspect()
2716 slave_info(bond->dev, slave->dev, "link status down again after %d ms\n", in bond_miimon_inspect()
2717 (bond->params.updelay - slave->delay) * in bond_miimon_inspect()
2724 slave->delay = 0; in bond_miimon_inspect()
2726 if (slave->delay <= 0) { in bond_miimon_inspect()
2727 bond_propose_link_state(slave, BOND_LINK_UP); in bond_miimon_inspect()
2733 slave->delay--; in bond_miimon_inspect()
2742 struct slave *slave, in bond_miimon_link_change() argument
2747 bond_3ad_handle_link_change(slave, link); in bond_miimon_link_change()
2751 bond_alb_handle_link_change(bond, slave, link); in bond_miimon_link_change()
2761 struct slave *slave, *primary, *active; in bond_miimon_commit() local
2767 bond_for_each_slave(bond, slave, iter) { in bond_miimon_commit()
2768 switch (slave->link_new_state) { in bond_miimon_commit()
2770 /* For 802.3ad mode, check current slave speed and in bond_miimon_commit()
2777 slave->link == BOND_LINK_UP) in bond_miimon_commit()
2778 bond_3ad_adapter_speed_duplex_changed(slave); in bond_miimon_commit()
2782 if (bond_update_speed_duplex(slave) && in bond_miimon_commit()
2784 slave->link = BOND_LINK_DOWN; in bond_miimon_commit()
2786 slave_warn(bond->dev, slave->dev, in bond_miimon_commit()
2790 bond_set_slave_link_state(slave, BOND_LINK_UP, in bond_miimon_commit()
2792 slave->last_link_up = jiffies; in bond_miimon_commit()
2797 bond_set_backup_slave(slave); in bond_miimon_commit()
2800 bond_set_active_slave(slave); in bond_miimon_commit()
2803 slave_info(bond->dev, slave->dev, "link status definitely up, %u Mbps %s duplex\n", in bond_miimon_commit()
2804 slave->speed == SPEED_UNKNOWN ? 0 : slave->speed, in bond_miimon_commit()
2805 slave->duplex ? "full" : "half"); in bond_miimon_commit()
2807 bond_miimon_link_change(bond, slave, BOND_LINK_UP); in bond_miimon_commit()
2810 if (!active || slave == primary || slave->prio > active->prio) in bond_miimon_commit()
2816 if (slave->link_failure_count < UINT_MAX) in bond_miimon_commit()
2817 slave->link_failure_count++; in bond_miimon_commit()
2819 bond_set_slave_link_state(slave, BOND_LINK_DOWN, in bond_miimon_commit()
2824 bond_set_slave_inactive_flags(slave, in bond_miimon_commit()
2827 slave_info(bond->dev, slave->dev, "link status definitely down, disabling slave\n"); in bond_miimon_commit()
2829 bond_miimon_link_change(bond, slave, BOND_LINK_DOWN); in bond_miimon_commit()
2831 if (slave == rcu_access_pointer(bond->curr_active_slave)) in bond_miimon_commit()
2837 slave_err(bond->dev, slave->dev, "invalid new link %d on slave\n", in bond_miimon_commit()
2838 slave->link_new_state); in bond_miimon_commit()
2839 bond_propose_link_state(slave, BOND_LINK_NOCHANGE); in bond_miimon_commit()
2868 struct slave *slave; in bond_mii_monitor() local
2897 bond_for_each_slave(bond, slave, iter) { in bond_mii_monitor()
2898 bond_commit_link_state(slave, BOND_SLAVE_NOTIFY_LATER); in bond_mii_monitor()
2945 static bool bond_handle_vlan(struct slave *slave, struct bond_vlan_tag *tags, in bond_handle_vlan() argument
2948 struct net_device *bond_dev = slave->bond->dev; in bond_handle_vlan()
2949 struct net_device *slave_dev = slave->dev; in bond_handle_vlan()
2990 static void bond_arp_send(struct slave *slave, int arp_op, __be32 dest_ip, in bond_arp_send() argument
2993 struct net_device *bond_dev = slave->bond->dev; in bond_arp_send()
2994 struct net_device *slave_dev = slave->dev; in bond_arp_send()
2997 slave_dbg(bond_dev, slave_dev, "arp %d on slave: dst %pI4 src %pI4\n", in bond_arp_send()
3008 if (bond_handle_vlan(slave, tags, skb)) { in bond_arp_send()
3009 slave_update_last_tx(slave); in bond_arp_send()
3056 static void bond_arp_send_all(struct bonding *bond, struct slave *slave) in bond_arp_send_all() argument
3064 slave_dbg(bond->dev, slave->dev, "%s: target %pI4\n", in bond_arp_send_all()
3079 bond_arp_send(slave, ARPOP_REQUEST, targets[i], in bond_arp_send_all()
3096 slave_dbg(bond->dev, slave->dev, "no path to arp_ip_target %pI4 via rt.dev %s\n", in bond_arp_send_all()
3105 bond_arp_send(slave, ARPOP_REQUEST, targets[i], addr, tags); in bond_arp_send_all()
3110 static void bond_validate_arp(struct bonding *bond, struct slave *slave, __be32 sip, __be32 tip) in bond_validate_arp() argument
3115 slave_dbg(bond->dev, slave->dev, "%s: sip %pI4 tip %pI4 not found\n", in bond_validate_arp()
3122 slave_dbg(bond->dev, slave->dev, "%s: sip %pI4 not found in targets\n", in bond_validate_arp()
3126 slave->last_rx = jiffies; in bond_validate_arp()
3127 slave->target_last_arp_rx[i] = jiffies; in bond_validate_arp()
3131 struct slave *slave) in bond_arp_rcv() argument
3134 struct slave *curr_active_slave, *curr_arp_slave; in bond_arp_rcv()
3163 slave_dbg(bond->dev, slave->dev, "%s: %s/%d av %d sv %d sip %pI4 tip %pI4\n", in bond_arp_rcv()
3164 __func__, slave->dev->name, bond_slave_state(slave), in bond_arp_rcv()
3165 bond->params.arp_validate, slave_do_arp_validate(bond, slave), in bond_arp_rcv()
3173 * (a) the slave receiving the ARP is active (which includes the in bond_arp_rcv()
3174 * current ARP slave, if any), or in bond_arp_rcv()
3176 * (b) the receiving slave isn't active, but there is a currently in bond_arp_rcv()
3177 * active slave and it received valid arp reply(s) after it became in bond_arp_rcv()
3178 * the currently active slave, or in bond_arp_rcv()
3180 * (c) there is an ARP slave that sent an ARP during the prior ARP in bond_arp_rcv()
3181 * interval, and we receive an ARP reply on any slave. We accept in bond_arp_rcv()
3183 * reply to a slave other than the sender of the ARP request. in bond_arp_rcv()
3187 * slave through the L2 switch(es) to the receiving slave. Since in bond_arp_rcv()
3194 if (bond_is_active_slave(slave)) in bond_arp_rcv()
3195 bond_validate_arp(bond, slave, sip, tip); in bond_arp_rcv()
3199 bond_validate_arp(bond, slave, tip, sip); in bond_arp_rcv()
3202 bond_validate_arp(bond, slave, sip, tip); in bond_arp_rcv()
3211 static void bond_ns_send(struct slave *slave, const struct in6_addr *daddr, in bond_ns_send() argument
3214 struct net_device *bond_dev = slave->bond->dev; in bond_ns_send()
3215 struct net_device *slave_dev = slave->dev; in bond_ns_send()
3219 slave_dbg(bond_dev, slave_dev, "NS on slave: dst %pI6c src %pI6c\n", in bond_ns_send()
3229 if (bond_handle_vlan(slave, tags, skb)) { in bond_ns_send()
3230 slave_update_last_tx(slave); in bond_ns_send()
3235 static void bond_ns_send_all(struct bonding *bond, struct slave *slave) in bond_ns_send_all() argument
3245 slave_dbg(bond->dev, slave->dev, "%s: target %pI6c\n", in bond_ns_send_all()
3264 bond_ns_send(slave, &targets[i], &in6addr_any, tags); in bond_ns_send_all()
3280 slave_dbg(bond->dev, slave->dev, "no path to ns_ip6_target %pI6c via dst->dev %s\n", in bond_ns_send_all()
3288 bond_ns_send(slave, &targets[i], &saddr, tags); in bond_ns_send_all()
3290 bond_ns_send(slave, &targets[i], &in6addr_any, tags); in bond_ns_send_all()
3323 static void bond_validate_na(struct bonding *bond, struct slave *slave, in bond_validate_na() argument
3336 slave_dbg(bond->dev, slave->dev, "%s: sip %pI6c tip %pI6c not found\n", in bond_validate_na()
3343 slave_dbg(bond->dev, slave->dev, "%s: sip %pI6c not found in targets\n", in bond_validate_na()
3347 slave->last_rx = jiffies; in bond_validate_na()
3348 slave->target_last_arp_rx[i] = jiffies; in bond_validate_na()
3352 struct slave *slave) in bond_na_rcv() argument
3354 struct slave *curr_active_slave, *curr_arp_slave; in bond_na_rcv()
3374 slave_dbg(bond->dev, slave->dev, "%s: %s/%d av %d sv %d sip %pI6c tip %pI6c\n", in bond_na_rcv()
3375 __func__, slave->dev->name, bond_slave_state(slave), in bond_na_rcv()
3376 bond->params.arp_validate, slave_do_arp_validate(bond, slave), in bond_na_rcv()
3385 if (bond_is_active_slave(slave)) in bond_na_rcv()
3386 bond_validate_na(bond, slave, saddr, daddr); in bond_na_rcv()
3390 bond_validate_na(bond, slave, daddr, saddr); in bond_na_rcv()
3393 bond_validate_na(bond, slave, saddr, daddr); in bond_na_rcv()
3401 struct slave *slave) in bond_rcv_validate() argument
3408 slave_dbg(bond->dev, slave->dev, "%s: skb->dev %s\n", in bond_rcv_validate()
3412 if (!slave_do_arp_validate(bond, slave)) { in bond_rcv_validate()
3418 slave->last_rx = jiffies; in bond_rcv_validate()
3421 return bond_arp_rcv(skb, bond, slave); in bond_rcv_validate()
3424 return bond_na_rcv(skb, bond, slave); in bond_rcv_validate()
3431 static void bond_send_validate(struct bonding *bond, struct slave *slave) in bond_send_validate() argument
3433 bond_arp_send_all(bond, slave); in bond_send_validate()
3435 bond_ns_send_all(bond, slave); in bond_send_validate()
3453 /* This function is called regularly to monitor each slave's link
3461 struct slave *slave, *oldcurrent; in bond_loadbalance_arp_mon() local
3473 * the picture unless it is null. also, slave->last_link_up is not in bond_loadbalance_arp_mon()
3474 * needed here because we send an arp on each slave and give a slave in bond_loadbalance_arp_mon()
3479 bond_for_each_slave_rcu(bond, slave, iter) { in bond_loadbalance_arp_mon()
3480 unsigned long last_tx = slave_last_tx(slave); in bond_loadbalance_arp_mon()
3482 bond_propose_link_state(slave, BOND_LINK_NOCHANGE); in bond_loadbalance_arp_mon()
3484 if (slave->link != BOND_LINK_UP) { in bond_loadbalance_arp_mon()
3486 bond_time_in_interval(bond, slave->last_rx, 1)) { in bond_loadbalance_arp_mon()
3488 bond_propose_link_state(slave, BOND_LINK_UP); in bond_loadbalance_arp_mon()
3492 * mode. the window of a slave being up and in bond_loadbalance_arp_mon()
3497 slave_info(bond->dev, slave->dev, "link status definitely up\n"); in bond_loadbalance_arp_mon()
3500 slave_info(bond->dev, slave->dev, "interface is now up\n"); in bond_loadbalance_arp_mon()
3504 /* slave->link == BOND_LINK_UP */ in bond_loadbalance_arp_mon()
3511 !bond_time_in_interval(bond, slave->last_rx, bond->params.missed_max)) { in bond_loadbalance_arp_mon()
3513 bond_propose_link_state(slave, BOND_LINK_DOWN); in bond_loadbalance_arp_mon()
3516 if (slave->link_failure_count < UINT_MAX) in bond_loadbalance_arp_mon()
3517 slave->link_failure_count++; in bond_loadbalance_arp_mon()
3519 slave_info(bond->dev, slave->dev, "interface is now down\n"); in bond_loadbalance_arp_mon()
3521 if (slave == oldcurrent) in bond_loadbalance_arp_mon()
3533 if (bond_slave_is_up(slave)) in bond_loadbalance_arp_mon()
3534 bond_send_validate(bond, slave); in bond_loadbalance_arp_mon()
3543 bond_for_each_slave(bond, slave, iter) { in bond_loadbalance_arp_mon()
3544 if (slave->link_new_state != BOND_LINK_NOCHANGE) in bond_loadbalance_arp_mon()
3545 slave->link = slave->link_new_state; in bond_loadbalance_arp_mon()
3569 * should take place for the slave. Returns 0 if no changes are found, >0
3578 struct slave *slave; in bond_ab_arp_inspect() local
3581 bond_for_each_slave_rcu(bond, slave, iter) { in bond_ab_arp_inspect()
3582 bond_propose_link_state(slave, BOND_LINK_NOCHANGE); in bond_ab_arp_inspect()
3583 last_rx = slave_last_rx(bond, slave); in bond_ab_arp_inspect()
3585 if (slave->link != BOND_LINK_UP) { in bond_ab_arp_inspect()
3587 bond_propose_link_state(slave, BOND_LINK_UP); in bond_ab_arp_inspect()
3589 } else if (slave->link == BOND_LINK_BACK) { in bond_ab_arp_inspect()
3590 bond_propose_link_state(slave, BOND_LINK_FAIL); in bond_ab_arp_inspect()
3600 if (bond_time_in_interval(bond, slave->last_link_up, 2)) in bond_ab_arp_inspect()
3603 /* Backup slave is down if: in bond_ab_arp_inspect()
3612 * gives each slave a chance to tx/rx traffic in bond_ab_arp_inspect()
3615 if (!bond_is_active_slave(slave) && in bond_ab_arp_inspect()
3618 bond_propose_link_state(slave, BOND_LINK_DOWN); in bond_ab_arp_inspect()
3622 /* Active slave is down if: in bond_ab_arp_inspect()
3627 last_tx = slave_last_tx(slave); in bond_ab_arp_inspect()
3628 if (bond_is_active_slave(slave) && in bond_ab_arp_inspect()
3631 bond_propose_link_state(slave, BOND_LINK_DOWN); in bond_ab_arp_inspect()
3649 struct slave *slave; in bond_ab_arp_commit() local
3651 bond_for_each_slave(bond, slave, iter) { in bond_ab_arp_commit()
3652 switch (slave->link_new_state) { in bond_ab_arp_commit()
3657 last_tx = slave_last_tx(slave); in bond_ab_arp_commit()
3658 if (rtnl_dereference(bond->curr_active_slave) != slave || in bond_ab_arp_commit()
3661 struct slave *current_arp_slave; in bond_ab_arp_commit()
3664 bond_set_slave_link_state(slave, BOND_LINK_UP, in bond_ab_arp_commit()
3673 slave_info(bond->dev, slave->dev, "link status definitely up\n"); in bond_ab_arp_commit()
3676 slave == rtnl_dereference(bond->primary_slave) || in bond_ab_arp_commit()
3677 slave->prio > rtnl_dereference(bond->curr_active_slave)->prio) in bond_ab_arp_commit()
3685 if (slave->link_failure_count < UINT_MAX) in bond_ab_arp_commit()
3686 slave->link_failure_count++; in bond_ab_arp_commit()
3688 bond_set_slave_link_state(slave, BOND_LINK_DOWN, in bond_ab_arp_commit()
3690 bond_set_slave_inactive_flags(slave, in bond_ab_arp_commit()
3693 slave_info(bond->dev, slave->dev, "link status definitely down, disabling slave\n"); in bond_ab_arp_commit()
3695 if (slave == rtnl_dereference(bond->curr_active_slave)) { in bond_ab_arp_commit()
3703 bond_set_slave_link_state(slave, BOND_LINK_FAIL, in bond_ab_arp_commit()
3705 bond_set_slave_inactive_flags(slave, in bond_ab_arp_commit()
3708 /* A slave has just been enslaved and has become in bond_ab_arp_commit()
3709 * the current active slave. in bond_ab_arp_commit()
3716 slave_err(bond->dev, slave->dev, in bond_ab_arp_commit()
3717 "impossible: link_new_state %d on slave\n", in bond_ab_arp_commit()
3718 slave->link_new_state); in bond_ab_arp_commit()
3738 struct slave *slave, *before = NULL, *new_slave = NULL, in bond_ab_arp_probe() local
3756 * backup slave from the current_arp_slave and make it the candidate in bond_ab_arp_probe()
3766 bond_for_each_slave_rcu(bond, slave, iter) { in bond_ab_arp_probe()
3767 if (!found && !before && bond_slave_is_up(slave)) in bond_ab_arp_probe()
3768 before = slave; in bond_ab_arp_probe()
3770 if (found && !new_slave && bond_slave_is_up(slave)) in bond_ab_arp_probe()
3771 new_slave = slave; in bond_ab_arp_probe()
3776 * one the current slave so it is still marked in bond_ab_arp_probe()
3779 if (!bond_slave_is_up(slave) && slave->link == BOND_LINK_UP) { in bond_ab_arp_probe()
3780 bond_set_slave_link_state(slave, BOND_LINK_DOWN, in bond_ab_arp_probe()
3782 if (slave->link_failure_count < UINT_MAX) in bond_ab_arp_probe()
3783 slave->link_failure_count++; in bond_ab_arp_probe()
3785 bond_set_slave_inactive_flags(slave, in bond_ab_arp_probe()
3788 slave_info(bond->dev, slave->dev, "backup interface is now down\n"); in bond_ab_arp_probe()
3790 if (slave == curr_arp_slave) in bond_ab_arp_probe()
3808 bond_for_each_slave_rcu(bond, slave, iter) { in bond_ab_arp_probe()
3809 if (slave->should_notify || slave->should_notify_link) { in bond_ab_arp_probe()
3926 struct slave *slave = bond_slave_get_rtnl(slave_dev), *primary; in bond_slave_netdev_event() local
3932 * slave will be NULL in bond_slave_netdev_event()
3934 if (!slave) { in bond_slave_netdev_event()
3935 netdev_dbg(slave_dev, "%s called on NULL slave\n", __func__); in bond_slave_netdev_event()
3939 bond_dev = slave->bond->dev; in bond_slave_netdev_event()
3940 bond = slave->bond; in bond_slave_netdev_event()
3955 * Getting invalid Speed/Duplex values here will put slave in bond_slave_netdev_event()
3961 if (bond_update_speed_duplex(slave) && in bond_slave_netdev_event()
3963 if (slave->last_link_up) in bond_slave_netdev_event()
3964 slave->link = BOND_LINK_FAIL; in bond_slave_netdev_event()
3966 slave->link = BOND_LINK_DOWN; in bond_slave_netdev_event()
3970 bond_3ad_adapter_speed_duplex_changed(slave); in bond_slave_netdev_event()
3973 /* Refresh slave-array if applicable! in bond_slave_netdev_event()
3975 * then these events will not cause the slave-array to be in bond_slave_netdev_event()
3976 * refreshed. This will cause xmit to use a slave that is not in bond_slave_netdev_event()
3992 * take over the slave's change_mtu in bond_slave_netdev_event()
4003 if (slave == primary) { in bond_slave_netdev_event()
4004 /* slave's name changed - he's no longer primary */ in bond_slave_netdev_event()
4007 /* we have a new primary slave */ in bond_slave_netdev_event()
4008 rcu_assign_pointer(bond->primary_slave, slave); in bond_slave_netdev_event()
4013 netdev_info(bond->dev, "Primary slave changed to %s, reselecting active slave\n", in bond_slave_netdev_event()
4029 call_netdevice_notifiers(event, slave->bond->dev); in bond_slave_netdev_event()
4045 * locks for us to safely manipulate the slave devices (RTNL lock,
4322 struct slave *slave; in bond_open() local
4330 /* reset slave->backup and slave->inactive */ in bond_open()
4332 bond_for_each_slave(bond, slave, iter) { in bond_open()
4334 slave != rcu_access_pointer(bond->curr_active_slave)) { in bond_open()
4335 bond_set_slave_inactive_flags(slave, in bond_open()
4338 bond_set_slave_active_flags(slave, in bond_open()
4368 bond_for_each_slave(bond, slave, iter) in bond_open()
4369 dev_mc_add(slave->dev, lacpdu_mcast_addr); in bond_open()
4381 struct slave *slave; in bond_close() local
4391 slave = rcu_dereference(bond->curr_active_slave); in bond_close()
4392 if (slave) in bond_close()
4393 bond_hw_addr_flush(bond_dev, slave->dev); in bond_close()
4398 bond_for_each_slave(bond, slave, iter) in bond_close()
4399 bond_hw_addr_flush(bond_dev, slave->dev); in bond_close()
4481 struct slave *slave; in bond_get_stats() local
4493 bond_for_each_slave_rcu(bond, slave, iter) { in bond_get_stats()
4495 dev_get_stats(slave->dev, &temp); in bond_get_stats()
4497 bond_fold_stats(stats, new, &slave->slave_stats); in bond_get_stats()
4499 /* save off the slave stats for the next run */ in bond_get_stats()
4500 memcpy(&slave->slave_stats, new, sizeof(*new)); in bond_get_stats()
4661 struct slave *slave; in bond_set_rx_mode() local
4665 slave = rcu_dereference(bond->curr_active_slave); in bond_set_rx_mode()
4666 if (slave) { in bond_set_rx_mode()
4667 dev_uc_sync(slave->dev, bond_dev); in bond_set_rx_mode()
4668 dev_mc_sync(slave->dev, bond_dev); in bond_set_rx_mode()
4671 bond_for_each_slave_rcu(bond, slave, iter) { in bond_set_rx_mode()
4672 dev_uc_sync_multiple(slave->dev, bond_dev); in bond_set_rx_mode()
4673 dev_mc_sync_multiple(slave->dev, bond_dev); in bond_set_rx_mode()
4684 struct slave *slave; in bond_neigh_init() local
4688 slave = bond_first_slave_rcu(bond); in bond_neigh_init()
4689 if (!slave) in bond_neigh_init()
4691 slave_ops = slave->dev->netdev_ops; in bond_neigh_init()
4704 ret = slave_ops->ndo_neigh_setup(slave->dev, &parms); in bond_neigh_init()
4717 * slave exists. So we must declare proxy setup function which will
4718 * be used at run time to resolve the actual slave neigh param setup.
4738 struct slave *slave, *rollback_slave; in bond_change_mtu() local
4744 bond_for_each_slave(bond, slave, iter) { in bond_change_mtu()
4745 slave_dbg(bond_dev, slave->dev, "s %p c_m %p\n", in bond_change_mtu()
4746 slave, slave->dev->netdev_ops->ndo_change_mtu); in bond_change_mtu()
4748 res = dev_set_mtu(slave->dev, new_mtu); in bond_change_mtu()
4751 /* If we failed to set the slave's mtu to the new value in bond_change_mtu()
4754 * different mtu values than the active slave we'll in bond_change_mtu()
4759 slave_dbg(bond_dev, slave->dev, "err %d setting mtu to %d\n", in bond_change_mtu()
4770 /* unwind from head to the slave that failed */ in bond_change_mtu()
4774 if (rollback_slave == slave) in bond_change_mtu()
4795 struct slave *slave, *rollback_slave; in bond_set_mac_address() local
4816 bond_for_each_slave(bond, slave, iter) { in bond_set_mac_address()
4817 slave_dbg(bond_dev, slave->dev, "%s: slave=%p\n", in bond_set_mac_address()
4818 __func__, slave); in bond_set_mac_address()
4819 res = dev_set_mac_address(slave->dev, addr, NULL); in bond_set_mac_address()
4821 /* TODO: consider downing the slave in bond_set_mac_address()
4827 slave_dbg(bond_dev, slave->dev, "%s: err %d\n", in bond_set_mac_address()
4841 /* unwind from head to the slave that failed */ in bond_set_mac_address()
4845 if (rollback_slave == slave) in bond_set_mac_address()
4860 * bond_get_slave_by_id - get xmit slave with slave_id
4862 * @slave_id: slave id up to slave_cnt-1 through which to transmit
4864 * This function tries to get slave with slave_id but in case
4865 * it fails, it tries to find the first available slave for transmission.
4867 static struct slave *bond_get_slave_by_id(struct bonding *bond, in bond_get_slave_by_id()
4871 struct slave *slave; in bond_get_slave_by_id() local
4874 /* Here we start from the slave with slave_id */ in bond_get_slave_by_id()
4875 bond_for_each_slave_rcu(bond, slave, iter) { in bond_get_slave_by_id()
4877 if (bond_slave_can_tx(slave)) in bond_get_slave_by_id()
4878 return slave; in bond_get_slave_by_id()
4882 /* Here we start from the first slave up to slave_id */ in bond_get_slave_by_id()
4884 bond_for_each_slave_rcu(bond, slave, iter) { in bond_get_slave_by_id()
4887 if (bond_slave_can_tx(slave)) in bond_get_slave_by_id()
4888 return slave; in bond_get_slave_by_id()
4890 /* no slave that can tx has been found */ in bond_get_slave_by_id()
4895 * bond_rr_gen_slave_id - generate slave id based on packets_per_slave
4899 * this function generates a slave id, which is usually used as the next
4900 * slave to transmit through.
4927 static struct slave *bond_xmit_roundrobin_slave_get(struct bonding *bond, in bond_xmit_roundrobin_slave_get()
4930 struct slave *slave; in bond_xmit_roundrobin_slave_get() local
4949 slave = rcu_dereference(bond->curr_active_slave); in bond_xmit_roundrobin_slave_get()
4950 if (slave) in bond_xmit_roundrobin_slave_get()
4951 return slave; in bond_xmit_roundrobin_slave_get()
4965 static struct slave *bond_xdp_xmit_roundrobin_slave_get(struct bonding *bond, in bond_xdp_xmit_roundrobin_slave_get()
4968 struct slave *slave; in bond_xdp_xmit_roundrobin_slave_get() local
4990 slave = rcu_dereference(bond->curr_active_slave); in bond_xdp_xmit_roundrobin_slave_get()
4991 if (slave) in bond_xdp_xmit_roundrobin_slave_get()
4992 return slave; in bond_xdp_xmit_roundrobin_slave_get()
5010 struct slave *slave; in bond_xmit_roundrobin() local
5012 slave = bond_xmit_roundrobin_slave_get(bond, skb); in bond_xmit_roundrobin()
5013 if (likely(slave)) in bond_xmit_roundrobin()
5014 return bond_dev_queue_xmit(bond, skb, slave->dev); in bond_xmit_roundrobin()
5019 static struct slave *bond_xmit_activebackup_slave_get(struct bonding *bond) in bond_xmit_activebackup_slave_get()
5031 struct slave *slave; in bond_xmit_activebackup() local
5033 slave = bond_xmit_activebackup_slave_get(bond); in bond_xmit_activebackup()
5034 if (slave) in bond_xmit_activebackup()
5035 return bond_dev_queue_xmit(bond, skb, slave->dev); in bond_xmit_activebackup()
5049 /* Slave array work handler. Holds only RTNL */
5062 pr_warn_ratelimited("Failed to update slave array from WT\n"); in bond_slave_arr_handler()
5072 struct slave *skipslave) in bond_skip_slave()
5077 * slave but allocation failed (most likely!). BTW this is in bond_skip_slave()
5082 * this to-be-skipped slave to send a packet out. in bond_skip_slave()
5115 * to determine the slave interface -
5122 int bond_update_slave_arr(struct bonding *bond, struct slave *skipslave) in bond_update_slave_arr()
5125 struct slave *slave; in bond_update_slave_arr() local
5156 bond_for_each_slave(bond, slave, iter) { in bond_update_slave_arr()
5157 if (skipslave == slave) in bond_update_slave_arr()
5160 all_slaves->arr[all_slaves->count++] = slave; in bond_update_slave_arr()
5164 agg = SLAVE_AD_INFO(slave)->port.aggregator; in bond_update_slave_arr()
5168 if (!bond_slave_can_tx(slave)) in bond_update_slave_arr()
5171 slave_dbg(bond->dev, slave->dev, "Adding slave to tx hash array[%d]\n", in bond_update_slave_arr()
5174 usable_slaves->arr[usable_slaves->count++] = slave; in bond_update_slave_arr()
5192 static struct slave *bond_xmit_3ad_xor_slave_get(struct bonding *bond, in bond_xmit_3ad_xor_slave_get()
5196 struct slave *slave; in bond_xmit_3ad_xor_slave_get() local
5205 slave = slaves->arr[hash % count]; in bond_xmit_3ad_xor_slave_get()
5206 return slave; in bond_xmit_3ad_xor_slave_get()
5209 static struct slave *bond_xdp_xmit_3ad_xor_slave_get(struct bonding *bond, in bond_xdp_xmit_3ad_xor_slave_get()
5226 * usable slave array is formed in the control path. The xmit function
5234 struct slave *slave; in bond_3ad_xor_xmit() local
5237 slave = bond_xmit_3ad_xor_slave_get(bond, skb, slaves); in bond_3ad_xor_xmit()
5238 if (likely(slave)) in bond_3ad_xor_xmit()
5239 return bond_dev_queue_xmit(bond, skb, slave->dev); in bond_3ad_xor_xmit()
5249 struct slave *slave = NULL; in bond_xmit_broadcast() local
5254 bond_for_each_slave_rcu(bond, slave, iter) { in bond_xmit_broadcast()
5257 if (!(bond_slave_is_up(slave) && slave->link == BOND_LINK_UP)) in bond_xmit_broadcast()
5260 if (bond_is_last_slave(bond, slave)) { in bond_xmit_broadcast()
5272 if (bond_dev_queue_xmit(bond, skb2, slave->dev) == NETDEV_TX_OK) in bond_xmit_broadcast()
5288 /* Lookup the slave that corresponds to a qid */
5292 struct slave *slave = NULL; in bond_slave_override() local
5299 bond_for_each_slave_rcu(bond, slave, iter) { in bond_slave_override()
5300 if (slave->queue_id == skb_get_queue_mapping(skb)) { in bond_slave_override()
5301 if (bond_slave_is_up(slave) && in bond_slave_override()
5302 slave->link == BOND_LINK_UP) { in bond_slave_override()
5303 bond_dev_queue_xmit(bond, skb, slave->dev); in bond_slave_override()
5306 /* If the slave isn't UP, use default transmit policy. */ in bond_slave_override()
5342 struct slave *slave = NULL; in bond_xmit_get_slave() local
5346 slave = bond_xmit_roundrobin_slave_get(bond, skb); in bond_xmit_get_slave()
5349 slave = bond_xmit_activebackup_slave_get(bond); in bond_xmit_get_slave()
5357 slave = bond_xmit_3ad_xor_slave_get(bond, skb, slaves); in bond_xmit_get_slave()
5362 slave = bond_xmit_alb_slave_get(bond, skb); in bond_xmit_get_slave()
5365 slave = bond_xmit_tlb_slave_get(bond, skb); in bond_xmit_get_slave()
5373 if (slave) in bond_xmit_get_slave()
5374 return slave->dev; in bond_xmit_get_slave()
5428 struct slave *slave; in __bond_sk_get_lower_dev() local
5438 slave = slaves->arr[hash % count]; in __bond_sk_get_lower_dev()
5440 return slave->dev; in __bond_sk_get_lower_dev()
5533 struct slave *slave; in bond_xdp_get_xmit_slave() local
5539 slave = bond_xdp_xmit_roundrobin_slave_get(bond, xdp); in bond_xdp_get_xmit_slave()
5543 slave = bond_xmit_activebackup_slave_get(bond); in bond_xdp_get_xmit_slave()
5548 slave = bond_xdp_xmit_3ad_xor_slave_get(bond, xdp); in bond_xdp_get_xmit_slave()
5558 if (slave) in bond_xdp_get_xmit_slave()
5559 return slave->dev; in bond_xdp_get_xmit_slave()
5606 struct slave *slave, *rollback_slave; in bond_xdp_set() local
5624 bond_for_each_slave(bond, slave, iter) { in bond_xdp_set()
5625 struct net_device *slave_dev = slave->dev; in bond_xdp_set()
5630 "Slave device does not support XDP"); in bond_xdp_set()
5637 "Slave has XDP program loaded, please unload before enslaving"); in bond_xdp_set()
5671 if (slave == rollback_slave) in bond_xdp_set()
5694 static u32 bond_mode_bcast_speed(struct slave *slave, u32 speed) in bond_mode_bcast_speed() argument
5697 speed = slave->speed; in bond_mode_bcast_speed()
5699 speed = min(speed, slave->speed); in bond_mode_bcast_speed()
5770 struct slave *slave; in bond_ethtool_get_link_ksettings() local
5781 bond_for_each_slave(bond, slave, iter) { in bond_ethtool_get_link_ksettings()
5782 if (bond_slave_can_tx(slave)) { in bond_ethtool_get_link_ksettings()
5783 bond_update_speed_duplex(slave); in bond_ethtool_get_link_ksettings()
5784 if (slave->speed != SPEED_UNKNOWN) { in bond_ethtool_get_link_ksettings()
5786 speed = bond_mode_bcast_speed(slave, in bond_ethtool_get_link_ksettings()
5789 speed += slave->speed; in bond_ethtool_get_link_ksettings()
5792 slave->duplex != DUPLEX_UNKNOWN) in bond_ethtool_get_link_ksettings()
5793 cmd->base.duplex = slave->duplex; in bond_ethtool_get_link_ksettings()
5819 struct slave *slave; in bond_ethtool_get_ts_info() local
5841 bond_for_each_slave_rcu(bond, slave, iter) { in bond_ethtool_get_ts_info()
5843 ops = slave->dev->ethtool_ops; in bond_ethtool_get_ts_info()
5844 phydev = slave->dev->phydev; in bond_ethtool_get_ts_info()
5849 ret = ops->get_ts_info(slave->dev, &ts_info); in bond_ethtool_get_ts_info()
6002 struct slave *slave; in bond_uninit() local
6007 bond_for_each_slave(bond, slave, iter) in bond_uninit()
6008 __bond_release_one(bond_dev, slave->dev, true, true); in bond_uninit()