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()
433 struct slave *slave; in bond_ipsec_dev() local
442 slave = rcu_dereference(bond->curr_active_slave); in bond_ipsec_dev()
443 if (!slave) in bond_ipsec_dev()
449 if (xs->xso.real_dev != slave->dev) in bond_ipsec_dev()
450 pr_warn_ratelimited("%s: (slave %s): not same with IPsec offload real dev %s\n", in bond_ipsec_dev()
451 bond_dev->name, slave->dev->name, xs->xso.real_dev->name); in bond_ipsec_dev()
453 return slave->dev; in bond_ipsec_dev()
469 struct slave *slave; in bond_ipsec_add_sa() local
477 slave = rcu_dereference(bond->curr_active_slave); in bond_ipsec_add_sa()
478 real_dev = slave ? slave->dev : NULL; in bond_ipsec_add_sa()
489 NL_SET_ERR_MSG_MOD(extack, "Slave does not support ipsec offload"); in bond_ipsec_add_sa()
521 struct slave *slave; in bond_ipsec_add_sa_all() local
523 slave = rtnl_dereference(bond->curr_active_slave); in bond_ipsec_add_sa_all()
524 real_dev = slave ? slave->dev : NULL; in bond_ipsec_add_sa_all()
534 "%s: no slave xdo_dev_state_add\n", in bond_ipsec_add_sa_all()
565 struct slave *slave; in bond_ipsec_del_sa() local
572 slave = rcu_dereference(bond->curr_active_slave); in bond_ipsec_del_sa()
573 real_dev = slave ? slave->dev : NULL; in bond_ipsec_del_sa()
577 if (!slave) in bond_ipsec_del_sa()
588 slave_warn(bond_dev, real_dev, "%s: no slave xdo_dev_state_delete\n", __func__); in bond_ipsec_del_sa()
611 struct slave *slave; in bond_ipsec_del_sa_all() local
613 slave = rtnl_dereference(bond->curr_active_slave); in bond_ipsec_del_sa_all()
614 real_dev = slave ? slave->dev : NULL; in bond_ipsec_del_sa_all()
627 "%s: no slave xdo_dev_state_delete\n", in bond_ipsec_del_sa_all()
644 struct slave *slave; in bond_ipsec_free_sa() local
651 slave = rcu_dereference(bond->curr_active_slave); in bond_ipsec_free_sa()
652 real_dev = slave ? slave->dev : NULL; in bond_ipsec_free_sa()
656 if (!slave) in bond_ipsec_free_sa()
766 struct slave *slave; in bond_set_carrier() local
774 bond_for_each_slave(bond, slave, iter) { in bond_set_carrier()
775 if (slave->link == BOND_LINK_UP) { in bond_set_carrier()
792 /* Get link speed and duplex from the slave's base driver
798 static int bond_update_speed_duplex(struct slave *slave) in bond_update_speed_duplex() argument
800 struct net_device *slave_dev = slave->dev; in bond_update_speed_duplex()
804 slave->speed = SPEED_UNKNOWN; in bond_update_speed_duplex()
805 slave->duplex = DUPLEX_UNKNOWN; in bond_update_speed_duplex()
820 slave->speed = ecmd.base.speed; in bond_update_speed_duplex()
821 slave->duplex = ecmd.base.duplex; in bond_update_speed_duplex()
918 struct slave *curr_active = rtnl_dereference(bond->curr_active_slave); in bond_set_promiscuity()
923 struct slave *slave; in bond_set_promiscuity() local
925 bond_for_each_slave(bond, slave, iter) { in bond_set_promiscuity()
926 err = dev_set_promiscuity(slave->dev, inc); in bond_set_promiscuity()
941 struct slave *curr_active = rtnl_dereference(bond->curr_active_slave); in bond_set_allmulti()
946 struct slave *slave; in bond_set_allmulti() local
948 bond_for_each_slave(bond, slave, iter) { in bond_set_allmulti()
949 err = dev_set_allmulti(slave->dev, inc); in bond_set_allmulti()
959 * slave.
979 /* Flush bond's hardware addresses from slave */
992 /*--------------------------- Active slave change ---------------------------*/
999 static void bond_hw_addr_swap(struct bonding *bond, struct slave *new_active, in bond_hw_addr_swap()
1000 struct slave *old_active) in bond_hw_addr_swap()
1035 * bond_set_dev_addr - clone slave's address to bond
1037 * @slave_dev: slave net device
1058 static struct slave *bond_get_old_active(struct bonding *bond, in bond_get_old_active()
1059 struct slave *new_active) in bond_get_old_active()
1061 struct slave *slave; in bond_get_old_active() local
1064 bond_for_each_slave(bond, slave, iter) { in bond_get_old_active()
1065 if (slave == new_active) in bond_get_old_active()
1068 if (ether_addr_equal(bond->dev->dev_addr, slave->dev->dev_addr)) in bond_get_old_active()
1069 return slave; in bond_get_old_active()
1082 struct slave *new_active, in bond_do_fail_over_mac()
1083 struct slave *old_active) in bond_do_fail_over_mac()
1094 slave_err(bond->dev, new_active->dev, "Error %d setting bond MAC from slave\n", in bond_do_fail_over_mac()
1100 * if just old_active, do nothing (going to no active slave) in bond_do_fail_over_mac()
1125 slave_err(bond->dev, new_active->dev, "Error %d setting MAC of new active slave\n", in bond_do_fail_over_mac()
1140 slave_err(bond->dev, old_active->dev, "Error %d setting MAC of old active slave\n", in bond_do_fail_over_mac()
1153 * bond_choose_primary_or_current - select the primary or high priority slave
1160 * If the highest priority link is not current slave, set it as primary
1163 static struct slave *bond_choose_primary_or_current(struct bonding *bond) in bond_choose_primary_or_current()
1165 struct slave *prim = rtnl_dereference(bond->primary_slave); in bond_choose_primary_or_current()
1166 struct slave *curr = rtnl_dereference(bond->curr_active_slave); in bond_choose_primary_or_current()
1167 struct slave *slave, *hprio = NULL; in bond_choose_primary_or_current() local
1171 bond_for_each_slave(bond, slave, iter) { in bond_choose_primary_or_current()
1172 if (slave->link == BOND_LINK_UP) { in bond_choose_primary_or_current()
1173 hprio = hprio ?: slave; in bond_choose_primary_or_current()
1174 if (slave->prio > hprio->prio) in bond_choose_primary_or_current()
1175 hprio = slave; in bond_choose_primary_or_current()
1218 * bond_find_best_slave - select the best available slave to be the active one
1221 static struct slave *bond_find_best_slave(struct bonding *bond) in bond_find_best_slave()
1223 struct slave *slave, *bestslave = NULL; in bond_find_best_slave() local
1227 slave = bond_choose_primary_or_current(bond); in bond_find_best_slave()
1228 if (slave) in bond_find_best_slave()
1229 return slave; in bond_find_best_slave()
1231 bond_for_each_slave(bond, slave, iter) { in bond_find_best_slave()
1232 if (slave->link == BOND_LINK_UP) in bond_find_best_slave()
1233 return slave; in bond_find_best_slave()
1234 if (slave->link == BOND_LINK_BACK && bond_slave_is_up(slave) && in bond_find_best_slave()
1235 slave->delay < mintime) { in bond_find_best_slave()
1236 mintime = slave->delay; in bond_find_best_slave()
1237 bestslave = slave; in bond_find_best_slave()
1247 struct slave *slave = rcu_dereference_rtnl(bond->curr_active_slave); in bond_should_notify_peers() local
1249 if (!slave || !bond->send_peer_notif || in bond_should_notify_peers()
1253 test_bit(__LINK_STATE_LINKWATCH_PENDING, &slave->dev->state)) in bond_should_notify_peers()
1256 netdev_dbg(bond->dev, "bond_should_notify_peers: slave %s\n", in bond_should_notify_peers()
1257 slave ? slave->dev->name : "NULL"); in bond_should_notify_peers()
1263 * bond_change_active_slave - change the active slave into the specified one
1265 * @new_active: the new slave to make the active one
1267 * Set the new slave to the bond's settings and unset them on the old
1272 * because it is apparently the best available slave we have, even though its
1277 void bond_change_active_slave(struct bonding *bond, struct slave *new_active) in bond_change_active_slave()
1279 struct slave *old_active; in bond_change_active_slave()
1367 /* resend IGMP joins since active slave has changed or in bond_change_active_slave()
1381 * bond_select_active_slave - select a new active slave, if needed
1387 * - A slave has got its link back and there's no old curr_active_slave.
1393 struct slave *best_slave; in bond_select_active_slave()
1413 static inline int slave_enable_netpoll(struct slave *slave) in slave_enable_netpoll() argument
1423 err = __netpoll_setup(np, slave->dev); in slave_enable_netpoll()
1428 slave->np = np; in slave_enable_netpoll()
1432 static inline void slave_disable_netpoll(struct slave *slave) in slave_disable_netpoll() argument
1434 struct netpoll *np = slave->np; in slave_disable_netpoll()
1439 slave->np = NULL; in slave_disable_netpoll()
1447 struct slave *slave = NULL; in bond_poll_controller() local
1455 bond_for_each_slave_rcu(bond, slave, iter) { in bond_poll_controller()
1456 if (!bond_slave_is_up(slave)) in bond_poll_controller()
1461 SLAVE_AD_INFO(slave)->port.aggregator; in bond_poll_controller()
1468 netpoll_poll_dev(slave->dev); in bond_poll_controller()
1476 struct slave *slave; in bond_netpoll_cleanup() local
1478 bond_for_each_slave(bond, slave, iter) in bond_netpoll_cleanup()
1479 if (bond_slave_is_up(slave)) in bond_netpoll_cleanup()
1480 slave_disable_netpoll(slave); in bond_netpoll_cleanup()
1487 struct slave *slave; in bond_netpoll_setup() local
1490 bond_for_each_slave(bond, slave, iter) { in bond_netpoll_setup()
1491 err = slave_enable_netpoll(slave); in bond_netpoll_setup()
1500 static inline int slave_enable_netpoll(struct slave *slave) in slave_enable_netpoll() argument
1504 static inline void slave_disable_netpoll(struct slave *slave) in slave_disable_netpoll() argument
1520 struct slave *slave; in bond_fix_features() local
1527 bond_for_each_slave(bond, slave, iter) { in bond_fix_features()
1529 slave->dev->features, in bond_fix_features()
1560 struct slave *slave; in bond_compute_features() local
1570 bond_for_each_slave(bond, slave, iter) { in bond_compute_features()
1572 slave->dev->vlan_features, BOND_VLAN_FEATURES); in bond_compute_features()
1575 slave->dev->hw_enc_features, in bond_compute_features()
1580 slave->dev->hw_enc_features, in bond_compute_features()
1585 slave->dev->mpls_features, in bond_compute_features()
1588 dst_release_flag &= slave->dev->priv_flags; in bond_compute_features()
1589 if (slave->dev->hard_header_len > max_hard_header_len) in bond_compute_features()
1590 max_hard_header_len = slave->dev->hard_header_len; in bond_compute_features()
1592 tso_max_size = min(tso_max_size, slave->dev->tso_max_size); in bond_compute_features()
1593 tso_max_segs = min(tso_max_segs, slave->dev->tso_max_segs); in bond_compute_features()
1642 /* On bonding slaves other than the currently active slave, suppress
1646 struct slave *slave, in bond_should_deliver_exact_match() argument
1649 if (bond_is_slave_inactive(slave)) { in bond_should_deliver_exact_match()
1662 struct slave *slave; in bond_handle_frame() local
1665 struct slave *); in bond_handle_frame()
1674 slave = bond_slave_get_rcu(skb->dev); in bond_handle_frame()
1675 bond = slave->bond; in bond_handle_frame()
1679 ret = recv_probe(skb, bond, slave); in bond_handle_frame()
1690 * inactive slave links without being forced to bind to them in bond_handle_frame()
1697 if (bond_should_deliver_exact_match(skb, slave, bond)) { in bond_handle_frame()
1762 static int bond_master_upper_dev_link(struct bonding *bond, struct slave *slave, in bond_master_upper_dev_link() argument
1773 err = netdev_master_upper_dev_link(slave->dev, bond->dev, slave, in bond_master_upper_dev_link()
1778 slave->dev->flags |= IFF_SLAVE; in bond_master_upper_dev_link()
1782 static void bond_upper_dev_unlink(struct bonding *bond, struct slave *slave) in bond_upper_dev_unlink() argument
1784 netdev_upper_dev_unlink(slave->dev, bond->dev); in bond_upper_dev_unlink()
1785 slave->dev->flags &= ~IFF_SLAVE; in bond_upper_dev_unlink()
1790 struct slave *slave = to_slave(kobj); in slave_kobj_release() local
1791 struct bonding *bond = bond_get_bond_by_slave(slave); in slave_kobj_release()
1793 cancel_delayed_work_sync(&slave->notify_work); in slave_kobj_release()
1795 kfree(SLAVE_AD_INFO(slave)); in slave_kobj_release()
1797 kfree(slave); in slave_kobj_release()
1807 static int bond_kobj_init(struct slave *slave) in bond_kobj_init() argument
1811 err = kobject_init_and_add(&slave->kobj, &slave_ktype, in bond_kobj_init()
1812 &(slave->dev->dev.kobj), "bonding_slave"); in bond_kobj_init()
1814 kobject_put(&slave->kobj); in bond_kobj_init()
1819 static struct slave *bond_alloc_slave(struct bonding *bond, in bond_alloc_slave()
1822 struct slave *slave = NULL; in bond_alloc_slave() local
1824 slave = kzalloc(sizeof(*slave), GFP_KERNEL); in bond_alloc_slave()
1825 if (!slave) in bond_alloc_slave()
1828 slave->bond = bond; in bond_alloc_slave()
1829 slave->dev = slave_dev; in bond_alloc_slave()
1830 INIT_DELAYED_WORK(&slave->notify_work, bond_netdev_notify_work); in bond_alloc_slave()
1832 if (bond_kobj_init(slave)) in bond_alloc_slave()
1836 SLAVE_AD_INFO(slave) = kzalloc(sizeof(struct ad_slave_info), in bond_alloc_slave()
1838 if (!SLAVE_AD_INFO(slave)) { in bond_alloc_slave()
1839 kobject_put(&slave->kobj); in bond_alloc_slave()
1844 return slave; in bond_alloc_slave()
1854 static void bond_fill_ifslave(struct slave *slave, struct ifslave *info) in bond_fill_ifslave() argument
1856 strcpy(info->slave_name, slave->dev->name); in bond_fill_ifslave()
1857 info->link = slave->link; in bond_fill_ifslave()
1858 info->state = bond_slave_state(slave); in bond_fill_ifslave()
1859 info->link_failure_count = slave->link_failure_count; in bond_fill_ifslave()
1864 struct slave *slave = container_of(_work, struct slave, in bond_netdev_notify_work() local
1870 bond_fill_ifslave(slave, &binfo.slave); in bond_netdev_notify_work()
1871 bond_fill_ifbond(slave->bond, &binfo.master); in bond_netdev_notify_work()
1872 netdev_bonding_info_change(slave->dev, &binfo); in bond_netdev_notify_work()
1875 queue_delayed_work(slave->bond->wq, &slave->notify_work, 1); in bond_netdev_notify_work()
1879 void bond_queue_slave_event(struct slave *slave) in bond_queue_slave_event() argument
1881 queue_delayed_work(slave->bond->wq, &slave->notify_work, 0); in bond_queue_slave_event()
1884 void bond_lower_state_changed(struct slave *slave) in bond_lower_state_changed() argument
1888 info.link_up = slave->link == BOND_LINK_UP || in bond_lower_state_changed()
1889 slave->link == BOND_LINK_FAIL; in bond_lower_state_changed()
1890 info.tx_enabled = bond_is_active_slave(slave); in bond_lower_state_changed()
1891 netdev_lower_state_changed(slave->dev, &info); in bond_lower_state_changed()
1927 struct slave *slave; in bond_xdp_set_features() local
1936 bond_for_each_slave(bond, slave, iter) in bond_xdp_set_features()
1937 val &= slave->dev->xdp_features; in bond_xdp_set_features()
1944 /* enslave device <slave> to bond device <master> */
1950 struct slave *new_slave = NULL, *prev_slave; in bond_enslave()
1989 …slave_warn(bond_dev, slave_dev, "enslaved VLAN challenged slave. Adding VLANs will be blocked as l… in bond_enslave()
1999 * be identified with moderate accuracy by the state of the slave: in bond_enslave()
2009 /* set bonding device ether type by slave - bonding netdevices are in bond_enslave()
2010 * created with ether_setup, so when the slave type is not ARPHRD_ETHER in bond_enslave()
2057 …slave_warn(bond_dev, slave_dev, "The slave device specified does not support setting the MAC addre… in bond_enslave()
2065 … "Slave device does not support setting the MAC address, but fail_over_mac is not set to active"); in bond_enslave()
2074 /* If this is the first slave, then we need to set the master's hardware in bond_enslave()
2075 * address to be the same as the slave's. in bond_enslave()
2095 /* Save slave's original mtu and then set it to match the bond */ in bond_enslave()
2103 /* Save slave's original ("permanent") mac address for modes in bond_enslave()
2112 /* Set slave to master's mac address. The application already in bond_enslave()
2113 * set the master's mac address to that of the first slave in bond_enslave()
2128 /* open the slave since the application closed it */ in bond_enslave()
2131 slave_err(bond_dev, slave_dev, "Opening slave failed\n"); in bond_enslave()
2136 /* initialize slave stats */ in bond_enslave()
2182 …slave_warn(bond_dev, slave_dev, "MII and ETHTOOL support not available for slave, and arp_interval… in bond_enslave()
2185 …slave_warn(bond_dev, slave_dev, "can't get link status from slave; the network driver associated w… in bond_enslave()
2219 slave_dbg(bond_dev, slave_dev, "Initial state of slave is BOND_LINK_%s\n", in bond_enslave()
2224 /* if there is a primary slave, remember it */ in bond_enslave()
2242 /* if this is the first slave */ in bond_enslave()
2262 slave_dbg(bond_dev, slave_dev, "This slave is always active in trunk mode\n"); in bond_enslave()
2281 …slave_info(bond_dev, slave_dev, "master_dev is using netpoll, but new slave device does not suppor… in bond_enslave()
2316 /* set promiscuity level to new slave */ in bond_enslave()
2323 /* set allmulti level to new slave */ in bond_enslave()
2349 * remove the maddrs if the slave is selected as active slave. in bond_enslave()
2366 "Slave does not support XDP"); in bond_enslave()
2380 "Slave has XDP program loaded, please unload before enslaving"); in bond_enslave()
2439 * MAC if this slave's MAC is in use by the bond, or at in bond_enslave()
2455 /* Enslave of first slave has failed and we need to fix master's mac */ in bond_enslave()
2469 /* Try to release the slave device <slave> from the bond device <master>
2474 * The rules for slave state should be:
2485 struct slave *slave, *oldcurrent; in __bond_release_one() local
2490 /* slave is not a slave or master is not master of this slave */ in __bond_release_one()
2493 slave_dbg(bond_dev, slave_dev, "cannot release slave\n"); in __bond_release_one()
2499 slave = bond_get_slave_by_dev(bond, slave_dev); in __bond_release_one()
2500 if (!slave) { in __bond_release_one()
2501 /* not a slave of this bond */ in __bond_release_one()
2507 bond_set_slave_inactive_flags(slave, BOND_SLAVE_NOTIFY_NOW); in __bond_release_one()
2509 bond_sysfs_slave_del(slave); in __bond_release_one()
2511 /* recompute stats just before removing the slave */ in __bond_release_one()
2526 * for this slave anymore. in __bond_release_one()
2531 bond_3ad_unbind_slave(slave); in __bond_release_one()
2533 bond_upper_dev_unlink(bond, slave); in __bond_release_one()
2536 bond_update_slave_arr(bond, slave); in __bond_release_one()
2539 bond_is_active_slave(slave) ? "active" : "backup"); in __bond_release_one()
2547 if (ether_addr_equal_64bits(bond_dev->dev_addr, slave->perm_hwaddr) && in __bond_release_one()
2549 …ond_dev, slave_dev, "the permanent HWaddr of slave - %pM - is still in use by bond - set the HWadd… in __bond_release_one()
2550 slave->perm_hwaddr); in __bond_release_one()
2553 if (rtnl_dereference(bond->primary_slave) == slave) in __bond_release_one()
2556 if (oldcurrent == slave) in __bond_release_one()
2559 /* Must be called after bond_change_active_slave () as the slave in __bond_release_one()
2560 * might change from an active slave to a backup slave. Then it is in __bond_release_one()
2561 * necessary to clear the maddrs on the backup slave. in __bond_release_one()
2563 bond_slave_ns_maddrs_del(bond, slave); in __bond_release_one()
2566 /* Must be called only after the slave has been in __bond_release_one()
2569 * but before a new active slave is selected. in __bond_release_one()
2571 bond_alb_deinit_slave(bond, slave); in __bond_release_one()
2576 } else if (oldcurrent == slave) { in __bond_release_one()
2578 * is no concern that another slave add/remove event in __bond_release_one()
2600 …slave_info(bond_dev, slave_dev, "last VLAN challenged slave left bond - VLAN blocking is removed\n… in __bond_release_one()
2608 /* unset promiscuity level from slave in __bond_release_one()
2612 * when this slave was attached, so we cache at the start of the in __bond_release_one()
2618 /* unset allmulti level from slave */ in __bond_release_one()
2626 slave_disable_netpoll(slave); in __bond_release_one()
2628 /* close slave before restoring its mac address */ in __bond_release_one()
2636 bond_hw_addr_copy(ss.__data, slave->perm_hwaddr, in __bond_release_one()
2637 slave->dev->addr_len); in __bond_release_one()
2643 __dev_set_mtu(slave_dev, slave->original_mtu); in __bond_release_one()
2645 dev_set_mtu(slave_dev, slave->original_mtu); in __bond_release_one()
2651 kobject_put(&slave->kobj); in __bond_release_one()
2662 /* First release a slave and then destroy the bond if no more slaves are left.
2694 struct slave *slave; in bond_slave_info_query() local
2696 bond_for_each_slave(bond, slave, iter) { in bond_slave_info_query()
2699 bond_fill_ifslave(slave, info); in bond_slave_info_query()
2715 struct slave *slave; in bond_miimon_inspect() local
2728 bond_for_each_slave_rcu(bond, slave, iter) { in bond_miimon_inspect()
2729 bond_propose_link_state(slave, BOND_LINK_NOCHANGE); in bond_miimon_inspect()
2731 link_state = bond_check_dev_link(bond, slave->dev, 0); in bond_miimon_inspect()
2733 switch (slave->link) { in bond_miimon_inspect()
2738 bond_propose_link_state(slave, BOND_LINK_FAIL); in bond_miimon_inspect()
2740 slave->delay = bond->params.downdelay; in bond_miimon_inspect()
2741 if (slave->delay && net_ratelimit()) { in bond_miimon_inspect()
2742 slave_info(bond->dev, slave->dev, "link status down for %sinterface, disabling it in %d ms\n", in bond_miimon_inspect()
2745 (bond_is_active_slave(slave) ? in bond_miimon_inspect()
2753 bond_propose_link_state(slave, BOND_LINK_UP); in bond_miimon_inspect()
2754 slave->last_link_up = jiffies; in bond_miimon_inspect()
2756 slave_info(bond->dev, slave->dev, "link status up again after %d ms\n", in bond_miimon_inspect()
2757 (bond->params.downdelay - slave->delay) * in bond_miimon_inspect()
2763 if (slave->delay <= 0) { in bond_miimon_inspect()
2764 bond_propose_link_state(slave, BOND_LINK_DOWN); in bond_miimon_inspect()
2769 slave->delay--; in bond_miimon_inspect()
2776 bond_propose_link_state(slave, BOND_LINK_BACK); in bond_miimon_inspect()
2778 slave->delay = bond->params.updelay; in bond_miimon_inspect()
2780 if (slave->delay && net_ratelimit()) { in bond_miimon_inspect()
2781 slave_info(bond->dev, slave->dev, "link status up, enabling it in %d ms\n", in bond_miimon_inspect()
2789 bond_propose_link_state(slave, BOND_LINK_DOWN); in bond_miimon_inspect()
2791 slave_info(bond->dev, slave->dev, "link status down again after %d ms\n", in bond_miimon_inspect()
2792 (bond->params.updelay - slave->delay) * in bond_miimon_inspect()
2799 slave->delay = 0; in bond_miimon_inspect()
2801 if (slave->delay <= 0) { in bond_miimon_inspect()
2802 bond_propose_link_state(slave, BOND_LINK_UP); in bond_miimon_inspect()
2808 slave->delay--; in bond_miimon_inspect()
2817 struct slave *slave, in bond_miimon_link_change() argument
2822 bond_3ad_handle_link_change(slave, link); in bond_miimon_link_change()
2826 bond_alb_handle_link_change(bond, slave, link); in bond_miimon_link_change()
2836 struct slave *slave, *primary, *active; in bond_miimon_commit() local
2842 bond_for_each_slave(bond, slave, iter) { in bond_miimon_commit()
2843 switch (slave->link_new_state) { in bond_miimon_commit()
2845 /* For 802.3ad mode, check current slave speed and in bond_miimon_commit()
2852 slave->link == BOND_LINK_UP) in bond_miimon_commit()
2853 bond_3ad_adapter_speed_duplex_changed(slave); in bond_miimon_commit()
2857 if (bond_update_speed_duplex(slave) && in bond_miimon_commit()
2859 slave->link = BOND_LINK_DOWN; in bond_miimon_commit()
2861 slave_warn(bond->dev, slave->dev, in bond_miimon_commit()
2865 bond_set_slave_link_state(slave, BOND_LINK_UP, in bond_miimon_commit()
2867 slave->last_link_up = jiffies; in bond_miimon_commit()
2872 bond_set_backup_slave(slave); in bond_miimon_commit()
2875 bond_set_active_slave(slave); in bond_miimon_commit()
2878 slave_info(bond->dev, slave->dev, "link status definitely up, %u Mbps %s duplex\n", in bond_miimon_commit()
2879 slave->speed == SPEED_UNKNOWN ? 0 : slave->speed, in bond_miimon_commit()
2880 slave->duplex ? "full" : "half"); in bond_miimon_commit()
2882 bond_miimon_link_change(bond, slave, BOND_LINK_UP); in bond_miimon_commit()
2885 if (!active || slave == primary || slave->prio > active->prio) in bond_miimon_commit()
2891 if (slave->link_failure_count < UINT_MAX) in bond_miimon_commit()
2892 slave->link_failure_count++; in bond_miimon_commit()
2894 bond_set_slave_link_state(slave, BOND_LINK_DOWN, in bond_miimon_commit()
2899 bond_set_slave_inactive_flags(slave, in bond_miimon_commit()
2902 slave_info(bond->dev, slave->dev, "link status definitely down, disabling slave\n"); in bond_miimon_commit()
2904 bond_miimon_link_change(bond, slave, BOND_LINK_DOWN); in bond_miimon_commit()
2906 if (slave == rcu_access_pointer(bond->curr_active_slave)) in bond_miimon_commit()
2912 slave_err(bond->dev, slave->dev, "invalid new link %d on slave\n", in bond_miimon_commit()
2913 slave->link_new_state); in bond_miimon_commit()
2914 bond_propose_link_state(slave, BOND_LINK_NOCHANGE); in bond_miimon_commit()
2943 struct slave *slave; in bond_mii_monitor() local
2972 bond_for_each_slave(bond, slave, iter) { in bond_mii_monitor()
2973 bond_commit_link_state(slave, BOND_SLAVE_NOTIFY_LATER); in bond_mii_monitor()
3020 static bool bond_handle_vlan(struct slave *slave, struct bond_vlan_tag *tags, in bond_handle_vlan() argument
3023 struct net_device *bond_dev = slave->bond->dev; in bond_handle_vlan()
3024 struct net_device *slave_dev = slave->dev; in bond_handle_vlan()
3065 static void bond_arp_send(struct slave *slave, int arp_op, __be32 dest_ip, in bond_arp_send() argument
3068 struct net_device *bond_dev = slave->bond->dev; in bond_arp_send()
3069 struct net_device *slave_dev = slave->dev; in bond_arp_send()
3072 slave_dbg(bond_dev, slave_dev, "arp %d on slave: dst %pI4 src %pI4\n", in bond_arp_send()
3083 if (bond_handle_vlan(slave, tags, skb)) { in bond_arp_send()
3084 slave_update_last_tx(slave); in bond_arp_send()
3131 static void bond_arp_send_all(struct bonding *bond, struct slave *slave) in bond_arp_send_all() argument
3139 slave_dbg(bond->dev, slave->dev, "%s: target %pI4\n", in bond_arp_send_all()
3154 bond_arp_send(slave, ARPOP_REQUEST, targets[i], in bond_arp_send_all()
3171 slave_dbg(bond->dev, slave->dev, "no path to arp_ip_target %pI4 via rt.dev %s\n", in bond_arp_send_all()
3180 bond_arp_send(slave, ARPOP_REQUEST, targets[i], addr, tags); in bond_arp_send_all()
3185 static void bond_validate_arp(struct bonding *bond, struct slave *slave, __be32 sip, __be32 tip) in bond_validate_arp() argument
3190 slave_dbg(bond->dev, slave->dev, "%s: sip %pI4 tip %pI4 not found\n", in bond_validate_arp()
3197 slave_dbg(bond->dev, slave->dev, "%s: sip %pI4 not found in targets\n", in bond_validate_arp()
3201 slave->last_rx = jiffies; in bond_validate_arp()
3202 slave->target_last_arp_rx[i] = jiffies; in bond_validate_arp()
3206 struct slave *slave) in bond_arp_rcv() argument
3209 struct slave *curr_active_slave, *curr_arp_slave; in bond_arp_rcv()
3238 slave_dbg(bond->dev, slave->dev, "%s: %s/%d av %d sv %d sip %pI4 tip %pI4\n", in bond_arp_rcv()
3239 __func__, slave->dev->name, bond_slave_state(slave), in bond_arp_rcv()
3240 bond->params.arp_validate, slave_do_arp_validate(bond, slave), in bond_arp_rcv()
3248 * (a) the slave receiving the ARP is active (which includes the in bond_arp_rcv()
3249 * current ARP slave, if any), or in bond_arp_rcv()
3251 * (b) the receiving slave isn't active, but there is a currently in bond_arp_rcv()
3252 * active slave and it received valid arp reply(s) after it became in bond_arp_rcv()
3253 * the currently active slave, or in bond_arp_rcv()
3255 * (c) there is an ARP slave that sent an ARP during the prior ARP in bond_arp_rcv()
3256 * interval, and we receive an ARP reply on any slave. We accept in bond_arp_rcv()
3258 * reply to a slave other than the sender of the ARP request. in bond_arp_rcv()
3262 * slave through the L2 switch(es) to the receiving slave. Since in bond_arp_rcv()
3269 if (bond_is_active_slave(slave)) in bond_arp_rcv()
3270 bond_validate_arp(bond, slave, sip, tip); in bond_arp_rcv()
3274 bond_validate_arp(bond, slave, tip, sip); in bond_arp_rcv()
3277 bond_validate_arp(bond, slave, sip, tip); in bond_arp_rcv()
3286 static void bond_ns_send(struct slave *slave, const struct in6_addr *daddr, in bond_ns_send() argument
3289 struct net_device *bond_dev = slave->bond->dev; in bond_ns_send()
3290 struct net_device *slave_dev = slave->dev; in bond_ns_send()
3294 slave_dbg(bond_dev, slave_dev, "NS on slave: dst %pI6c src %pI6c\n", in bond_ns_send()
3304 if (bond_handle_vlan(slave, tags, skb)) { in bond_ns_send()
3305 slave_update_last_tx(slave); in bond_ns_send()
3310 static void bond_ns_send_all(struct bonding *bond, struct slave *slave) in bond_ns_send_all() argument
3320 slave_dbg(bond->dev, slave->dev, "%s: target %pI6c\n", in bond_ns_send_all()
3339 bond_ns_send(slave, &targets[i], &in6addr_any, tags); in bond_ns_send_all()
3355 slave_dbg(bond->dev, slave->dev, "no path to ns_ip6_target %pI6c via dst->dev %s\n", in bond_ns_send_all()
3363 bond_ns_send(slave, &targets[i], &saddr, tags); in bond_ns_send_all()
3365 bond_ns_send(slave, &targets[i], &in6addr_any, tags); in bond_ns_send_all()
3398 static void bond_validate_na(struct bonding *bond, struct slave *slave, in bond_validate_na() argument
3411 slave_dbg(bond->dev, slave->dev, "%s: sip %pI6c tip %pI6c not found\n", in bond_validate_na()
3418 slave_dbg(bond->dev, slave->dev, "%s: sip %pI6c not found in targets\n", in bond_validate_na()
3422 slave->last_rx = jiffies; in bond_validate_na()
3423 slave->target_last_arp_rx[i] = jiffies; in bond_validate_na()
3427 struct slave *slave) in bond_na_rcv() argument
3429 struct slave *curr_active_slave, *curr_arp_slave; in bond_na_rcv()
3449 slave_dbg(bond->dev, slave->dev, "%s: %s/%d av %d sv %d sip %pI6c tip %pI6c\n", in bond_na_rcv()
3450 __func__, slave->dev->name, bond_slave_state(slave), in bond_na_rcv()
3451 bond->params.arp_validate, slave_do_arp_validate(bond, slave), in bond_na_rcv()
3460 if (bond_is_active_slave(slave)) in bond_na_rcv()
3461 bond_validate_na(bond, slave, saddr, daddr); in bond_na_rcv()
3465 bond_validate_na(bond, slave, daddr, saddr); in bond_na_rcv()
3468 bond_validate_na(bond, slave, saddr, daddr); in bond_na_rcv()
3476 struct slave *slave) in bond_rcv_validate() argument
3483 slave_dbg(bond->dev, slave->dev, "%s: skb->dev %s\n", in bond_rcv_validate()
3487 if (!slave_do_arp_validate(bond, slave)) { in bond_rcv_validate()
3493 slave->last_rx = jiffies; in bond_rcv_validate()
3496 return bond_arp_rcv(skb, bond, slave); in bond_rcv_validate()
3499 return bond_na_rcv(skb, bond, slave); in bond_rcv_validate()
3506 static void bond_send_validate(struct bonding *bond, struct slave *slave) in bond_send_validate() argument
3508 bond_arp_send_all(bond, slave); in bond_send_validate()
3510 bond_ns_send_all(bond, slave); in bond_send_validate()
3528 /* This function is called regularly to monitor each slave's link
3536 struct slave *slave, *oldcurrent; in bond_loadbalance_arp_mon() local
3548 * the picture unless it is null. also, slave->last_link_up is not in bond_loadbalance_arp_mon()
3549 * needed here because we send an arp on each slave and give a slave in bond_loadbalance_arp_mon()
3554 bond_for_each_slave_rcu(bond, slave, iter) { in bond_loadbalance_arp_mon()
3555 unsigned long last_tx = slave_last_tx(slave); in bond_loadbalance_arp_mon()
3557 bond_propose_link_state(slave, BOND_LINK_NOCHANGE); in bond_loadbalance_arp_mon()
3559 if (slave->link != BOND_LINK_UP) { in bond_loadbalance_arp_mon()
3561 bond_time_in_interval(bond, slave->last_rx, 1)) { in bond_loadbalance_arp_mon()
3563 bond_propose_link_state(slave, BOND_LINK_UP); in bond_loadbalance_arp_mon()
3567 * mode. the window of a slave being up and in bond_loadbalance_arp_mon()
3572 slave_info(bond->dev, slave->dev, "link status definitely up\n"); in bond_loadbalance_arp_mon()
3575 slave_info(bond->dev, slave->dev, "interface is now up\n"); in bond_loadbalance_arp_mon()
3579 /* slave->link == BOND_LINK_UP */ in bond_loadbalance_arp_mon()
3586 !bond_time_in_interval(bond, slave->last_rx, bond->params.missed_max)) { in bond_loadbalance_arp_mon()
3588 bond_propose_link_state(slave, BOND_LINK_DOWN); in bond_loadbalance_arp_mon()
3591 if (slave->link_failure_count < UINT_MAX) in bond_loadbalance_arp_mon()
3592 slave->link_failure_count++; in bond_loadbalance_arp_mon()
3594 slave_info(bond->dev, slave->dev, "interface is now down\n"); in bond_loadbalance_arp_mon()
3596 if (slave == oldcurrent) in bond_loadbalance_arp_mon()
3608 if (bond_slave_is_up(slave)) in bond_loadbalance_arp_mon()
3609 bond_send_validate(bond, slave); in bond_loadbalance_arp_mon()
3618 bond_for_each_slave(bond, slave, iter) { in bond_loadbalance_arp_mon()
3619 if (slave->link_new_state != BOND_LINK_NOCHANGE) in bond_loadbalance_arp_mon()
3620 slave->link = slave->link_new_state; in bond_loadbalance_arp_mon()
3644 * should take place for the slave. Returns 0 if no changes are found, >0
3653 struct slave *slave; in bond_ab_arp_inspect() local
3656 bond_for_each_slave_rcu(bond, slave, iter) { in bond_ab_arp_inspect()
3657 bond_propose_link_state(slave, BOND_LINK_NOCHANGE); in bond_ab_arp_inspect()
3658 last_rx = slave_last_rx(bond, slave); in bond_ab_arp_inspect()
3660 if (slave->link != BOND_LINK_UP) { in bond_ab_arp_inspect()
3662 bond_propose_link_state(slave, BOND_LINK_UP); in bond_ab_arp_inspect()
3664 } else if (slave->link == BOND_LINK_BACK) { in bond_ab_arp_inspect()
3665 bond_propose_link_state(slave, BOND_LINK_FAIL); in bond_ab_arp_inspect()
3675 if (bond_time_in_interval(bond, slave->last_link_up, 2)) in bond_ab_arp_inspect()
3678 /* Backup slave is down if: in bond_ab_arp_inspect()
3687 * gives each slave a chance to tx/rx traffic in bond_ab_arp_inspect()
3690 if (!bond_is_active_slave(slave) && in bond_ab_arp_inspect()
3693 bond_propose_link_state(slave, BOND_LINK_DOWN); in bond_ab_arp_inspect()
3697 /* Active slave is down if: in bond_ab_arp_inspect()
3702 last_tx = slave_last_tx(slave); in bond_ab_arp_inspect()
3703 if (bond_is_active_slave(slave) && in bond_ab_arp_inspect()
3706 bond_propose_link_state(slave, BOND_LINK_DOWN); in bond_ab_arp_inspect()
3724 struct slave *slave; in bond_ab_arp_commit() local
3726 bond_for_each_slave(bond, slave, iter) { in bond_ab_arp_commit()
3727 switch (slave->link_new_state) { in bond_ab_arp_commit()
3732 last_tx = slave_last_tx(slave); in bond_ab_arp_commit()
3733 if (rtnl_dereference(bond->curr_active_slave) != slave || in bond_ab_arp_commit()
3736 struct slave *current_arp_slave; in bond_ab_arp_commit()
3739 bond_set_slave_link_state(slave, BOND_LINK_UP, in bond_ab_arp_commit()
3748 slave_info(bond->dev, slave->dev, "link status definitely up\n"); in bond_ab_arp_commit()
3751 slave == rtnl_dereference(bond->primary_slave) || in bond_ab_arp_commit()
3752 slave->prio > rtnl_dereference(bond->curr_active_slave)->prio) in bond_ab_arp_commit()
3760 if (slave->link_failure_count < UINT_MAX) in bond_ab_arp_commit()
3761 slave->link_failure_count++; in bond_ab_arp_commit()
3763 bond_set_slave_link_state(slave, BOND_LINK_DOWN, in bond_ab_arp_commit()
3765 bond_set_slave_inactive_flags(slave, in bond_ab_arp_commit()
3768 slave_info(bond->dev, slave->dev, "link status definitely down, disabling slave\n"); in bond_ab_arp_commit()
3770 if (slave == rtnl_dereference(bond->curr_active_slave)) { in bond_ab_arp_commit()
3778 bond_set_slave_link_state(slave, BOND_LINK_FAIL, in bond_ab_arp_commit()
3780 bond_set_slave_inactive_flags(slave, in bond_ab_arp_commit()
3783 /* A slave has just been enslaved and has become in bond_ab_arp_commit()
3784 * the current active slave. in bond_ab_arp_commit()
3791 slave_err(bond->dev, slave->dev, in bond_ab_arp_commit()
3792 "impossible: link_new_state %d on slave\n", in bond_ab_arp_commit()
3793 slave->link_new_state); in bond_ab_arp_commit()
3813 struct slave *slave, *before = NULL, *new_slave = NULL, in bond_ab_arp_probe() local
3831 * backup slave from the current_arp_slave and make it the candidate in bond_ab_arp_probe()
3841 bond_for_each_slave_rcu(bond, slave, iter) { in bond_ab_arp_probe()
3842 if (!found && !before && bond_slave_is_up(slave)) in bond_ab_arp_probe()
3843 before = slave; in bond_ab_arp_probe()
3845 if (found && !new_slave && bond_slave_is_up(slave)) in bond_ab_arp_probe()
3846 new_slave = slave; in bond_ab_arp_probe()
3851 * one the current slave so it is still marked in bond_ab_arp_probe()
3854 if (!bond_slave_is_up(slave) && slave->link == BOND_LINK_UP) { in bond_ab_arp_probe()
3855 bond_set_slave_link_state(slave, BOND_LINK_DOWN, in bond_ab_arp_probe()
3857 if (slave->link_failure_count < UINT_MAX) in bond_ab_arp_probe()
3858 slave->link_failure_count++; in bond_ab_arp_probe()
3860 bond_set_slave_inactive_flags(slave, in bond_ab_arp_probe()
3863 slave_info(bond->dev, slave->dev, "backup interface is now down\n"); in bond_ab_arp_probe()
3865 if (slave == curr_arp_slave) in bond_ab_arp_probe()
3883 bond_for_each_slave_rcu(bond, slave, iter) { in bond_ab_arp_probe()
3884 if (slave->should_notify || slave->should_notify_link) { in bond_ab_arp_probe()
4001 struct slave *slave = bond_slave_get_rtnl(slave_dev), *primary; in bond_slave_netdev_event() local
4007 * slave will be NULL in bond_slave_netdev_event()
4009 if (!slave) { in bond_slave_netdev_event()
4010 netdev_dbg(slave_dev, "%s called on NULL slave\n", __func__); in bond_slave_netdev_event()
4014 bond_dev = slave->bond->dev; in bond_slave_netdev_event()
4015 bond = slave->bond; in bond_slave_netdev_event()
4030 * Getting invalid Speed/Duplex values here will put slave in bond_slave_netdev_event()
4036 if (bond_update_speed_duplex(slave) && in bond_slave_netdev_event()
4038 if (slave->last_link_up) in bond_slave_netdev_event()
4039 slave->link = BOND_LINK_FAIL; in bond_slave_netdev_event()
4041 slave->link = BOND_LINK_DOWN; in bond_slave_netdev_event()
4045 bond_3ad_adapter_speed_duplex_changed(slave); in bond_slave_netdev_event()
4048 /* Refresh slave-array if applicable! in bond_slave_netdev_event()
4050 * then these events will not cause the slave-array to be in bond_slave_netdev_event()
4051 * refreshed. This will cause xmit to use a slave that is not in bond_slave_netdev_event()
4067 * take over the slave's change_mtu in bond_slave_netdev_event()
4078 if (slave == primary) { in bond_slave_netdev_event()
4079 /* slave's name changed - he's no longer primary */ in bond_slave_netdev_event()
4082 /* we have a new primary slave */ in bond_slave_netdev_event()
4083 rcu_assign_pointer(bond->primary_slave, slave); in bond_slave_netdev_event()
4088 netdev_info(bond->dev, "Primary slave changed to %s, reselecting active slave\n", in bond_slave_netdev_event()
4104 call_netdevice_notifiers(event, slave->bond->dev); in bond_slave_netdev_event()
4120 * locks for us to safely manipulate the slave devices (RTNL lock,
4397 struct slave *slave; in bond_open() local
4405 /* reset slave->backup and slave->inactive */ in bond_open()
4407 bond_for_each_slave(bond, slave, iter) { in bond_open()
4409 slave != rcu_access_pointer(bond->curr_active_slave)) { in bond_open()
4410 bond_set_slave_inactive_flags(slave, in bond_open()
4413 bond_set_slave_active_flags(slave, in bond_open()
4443 bond_for_each_slave(bond, slave, iter) in bond_open()
4444 dev_mc_add(slave->dev, lacpdu_mcast_addr); in bond_open()
4456 struct slave *slave; in bond_close() local
4466 slave = rcu_dereference(bond->curr_active_slave); in bond_close()
4467 if (slave) in bond_close()
4468 bond_hw_addr_flush(bond_dev, slave->dev); in bond_close()
4473 bond_for_each_slave(bond, slave, iter) in bond_close()
4474 bond_hw_addr_flush(bond_dev, slave->dev); in bond_close()
4556 struct slave *slave; in bond_get_stats() local
4568 bond_for_each_slave_rcu(bond, slave, iter) { in bond_get_stats()
4570 dev_get_stats(slave->dev, &temp); in bond_get_stats()
4572 bond_fold_stats(stats, new, &slave->slave_stats); in bond_get_stats()
4574 /* save off the slave stats for the next run */ in bond_get_stats()
4575 memcpy(&slave->slave_stats, new, sizeof(*new)); in bond_get_stats()
4736 struct slave *slave; in bond_set_rx_mode() local
4740 slave = rcu_dereference(bond->curr_active_slave); in bond_set_rx_mode()
4741 if (slave) { in bond_set_rx_mode()
4742 dev_uc_sync(slave->dev, bond_dev); in bond_set_rx_mode()
4743 dev_mc_sync(slave->dev, bond_dev); in bond_set_rx_mode()
4746 bond_for_each_slave_rcu(bond, slave, iter) { in bond_set_rx_mode()
4747 dev_uc_sync_multiple(slave->dev, bond_dev); in bond_set_rx_mode()
4748 dev_mc_sync_multiple(slave->dev, bond_dev); in bond_set_rx_mode()
4759 struct slave *slave; in bond_neigh_init() local
4763 slave = bond_first_slave_rcu(bond); in bond_neigh_init()
4764 if (!slave) in bond_neigh_init()
4766 slave_ops = slave->dev->netdev_ops; in bond_neigh_init()
4779 ret = slave_ops->ndo_neigh_setup(slave->dev, &parms); in bond_neigh_init()
4792 * slave exists. So we must declare proxy setup function which will
4793 * be used at run time to resolve the actual slave neigh param setup.
4813 struct slave *slave, *rollback_slave; in bond_change_mtu() local
4819 bond_for_each_slave(bond, slave, iter) { in bond_change_mtu()
4820 slave_dbg(bond_dev, slave->dev, "s %p c_m %p\n", in bond_change_mtu()
4821 slave, slave->dev->netdev_ops->ndo_change_mtu); in bond_change_mtu()
4823 res = dev_set_mtu(slave->dev, new_mtu); in bond_change_mtu()
4826 /* If we failed to set the slave's mtu to the new value in bond_change_mtu()
4829 * different mtu values than the active slave we'll in bond_change_mtu()
4834 slave_dbg(bond_dev, slave->dev, "err %d setting mtu to %d\n", in bond_change_mtu()
4845 /* unwind from head to the slave that failed */ in bond_change_mtu()
4849 if (rollback_slave == slave) in bond_change_mtu()
4870 struct slave *slave, *rollback_slave; in bond_set_mac_address() local
4891 bond_for_each_slave(bond, slave, iter) { in bond_set_mac_address()
4892 slave_dbg(bond_dev, slave->dev, "%s: slave=%p\n", in bond_set_mac_address()
4893 __func__, slave); in bond_set_mac_address()
4894 res = dev_set_mac_address(slave->dev, addr, NULL); in bond_set_mac_address()
4896 /* TODO: consider downing the slave in bond_set_mac_address()
4902 slave_dbg(bond_dev, slave->dev, "%s: err %d\n", in bond_set_mac_address()
4916 /* unwind from head to the slave that failed */ in bond_set_mac_address()
4920 if (rollback_slave == slave) in bond_set_mac_address()
4935 * bond_get_slave_by_id - get xmit slave with slave_id
4937 * @slave_id: slave id up to slave_cnt-1 through which to transmit
4939 * This function tries to get slave with slave_id but in case
4940 * it fails, it tries to find the first available slave for transmission.
4942 static struct slave *bond_get_slave_by_id(struct bonding *bond, in bond_get_slave_by_id()
4946 struct slave *slave; in bond_get_slave_by_id() local
4949 /* Here we start from the slave with slave_id */ in bond_get_slave_by_id()
4950 bond_for_each_slave_rcu(bond, slave, iter) { in bond_get_slave_by_id()
4952 if (bond_slave_can_tx(slave)) in bond_get_slave_by_id()
4953 return slave; in bond_get_slave_by_id()
4957 /* Here we start from the first slave up to slave_id */ in bond_get_slave_by_id()
4959 bond_for_each_slave_rcu(bond, slave, iter) { in bond_get_slave_by_id()
4962 if (bond_slave_can_tx(slave)) in bond_get_slave_by_id()
4963 return slave; in bond_get_slave_by_id()
4965 /* no slave that can tx has been found */ in bond_get_slave_by_id()
4970 * bond_rr_gen_slave_id - generate slave id based on packets_per_slave
4974 * this function generates a slave id, which is usually used as the next
4975 * slave to transmit through.
5002 static struct slave *bond_xmit_roundrobin_slave_get(struct bonding *bond, in bond_xmit_roundrobin_slave_get()
5005 struct slave *slave; in bond_xmit_roundrobin_slave_get() local
5024 slave = rcu_dereference(bond->curr_active_slave); in bond_xmit_roundrobin_slave_get()
5025 if (slave) in bond_xmit_roundrobin_slave_get()
5026 return slave; in bond_xmit_roundrobin_slave_get()
5040 static struct slave *bond_xdp_xmit_roundrobin_slave_get(struct bonding *bond, in bond_xdp_xmit_roundrobin_slave_get()
5043 struct slave *slave; in bond_xdp_xmit_roundrobin_slave_get() local
5065 slave = rcu_dereference(bond->curr_active_slave); in bond_xdp_xmit_roundrobin_slave_get()
5066 if (slave) in bond_xdp_xmit_roundrobin_slave_get()
5067 return slave; in bond_xdp_xmit_roundrobin_slave_get()
5085 struct slave *slave; in bond_xmit_roundrobin() local
5087 slave = bond_xmit_roundrobin_slave_get(bond, skb); in bond_xmit_roundrobin()
5088 if (likely(slave)) in bond_xmit_roundrobin()
5089 return bond_dev_queue_xmit(bond, skb, slave->dev); in bond_xmit_roundrobin()
5094 static struct slave *bond_xmit_activebackup_slave_get(struct bonding *bond) in bond_xmit_activebackup_slave_get()
5106 struct slave *slave; in bond_xmit_activebackup() local
5108 slave = bond_xmit_activebackup_slave_get(bond); in bond_xmit_activebackup()
5109 if (slave) in bond_xmit_activebackup()
5110 return bond_dev_queue_xmit(bond, skb, slave->dev); in bond_xmit_activebackup()
5124 /* Slave array work handler. Holds only RTNL */
5137 pr_warn_ratelimited("Failed to update slave array from WT\n"); in bond_slave_arr_handler()
5147 struct slave *skipslave) in bond_skip_slave()
5152 * slave but allocation failed (most likely!). BTW this is in bond_skip_slave()
5157 * this to-be-skipped slave to send a packet out. in bond_skip_slave()
5190 * to determine the slave interface -
5197 int bond_update_slave_arr(struct bonding *bond, struct slave *skipslave) in bond_update_slave_arr()
5200 struct slave *slave; in bond_update_slave_arr() local
5231 bond_for_each_slave(bond, slave, iter) { in bond_update_slave_arr()
5232 if (skipslave == slave) in bond_update_slave_arr()
5235 all_slaves->arr[all_slaves->count++] = slave; in bond_update_slave_arr()
5239 agg = SLAVE_AD_INFO(slave)->port.aggregator; in bond_update_slave_arr()
5243 if (!bond_slave_can_tx(slave)) in bond_update_slave_arr()
5246 slave_dbg(bond->dev, slave->dev, "Adding slave to tx hash array[%d]\n", in bond_update_slave_arr()
5249 usable_slaves->arr[usable_slaves->count++] = slave; in bond_update_slave_arr()
5267 static struct slave *bond_xmit_3ad_xor_slave_get(struct bonding *bond, in bond_xmit_3ad_xor_slave_get()
5271 struct slave *slave; in bond_xmit_3ad_xor_slave_get() local
5280 slave = slaves->arr[hash % count]; in bond_xmit_3ad_xor_slave_get()
5281 return slave; in bond_xmit_3ad_xor_slave_get()
5284 static struct slave *bond_xdp_xmit_3ad_xor_slave_get(struct bonding *bond, in bond_xdp_xmit_3ad_xor_slave_get()
5301 * usable slave array is formed in the control path. The xmit function
5309 struct slave *slave; in bond_3ad_xor_xmit() local
5312 slave = bond_xmit_3ad_xor_slave_get(bond, skb, slaves); in bond_3ad_xor_xmit()
5313 if (likely(slave)) in bond_3ad_xor_xmit()
5314 return bond_dev_queue_xmit(bond, skb, slave->dev); in bond_3ad_xor_xmit()
5324 struct slave *slave = NULL; in bond_xmit_broadcast() local
5329 bond_for_each_slave_rcu(bond, slave, iter) { in bond_xmit_broadcast()
5332 if (!(bond_slave_is_up(slave) && slave->link == BOND_LINK_UP)) in bond_xmit_broadcast()
5335 if (bond_is_last_slave(bond, slave)) { in bond_xmit_broadcast()
5347 if (bond_dev_queue_xmit(bond, skb2, slave->dev) == NETDEV_TX_OK) in bond_xmit_broadcast()
5363 /* Lookup the slave that corresponds to a qid */
5367 struct slave *slave = NULL; in bond_slave_override() local
5374 bond_for_each_slave_rcu(bond, slave, iter) { in bond_slave_override()
5375 if (READ_ONCE(slave->queue_id) == skb_get_queue_mapping(skb)) { in bond_slave_override()
5376 if (bond_slave_is_up(slave) && in bond_slave_override()
5377 slave->link == BOND_LINK_UP) { in bond_slave_override()
5378 bond_dev_queue_xmit(bond, skb, slave->dev); in bond_slave_override()
5381 /* If the slave isn't UP, use default transmit policy. */ in bond_slave_override()
5417 struct slave *slave = NULL; in bond_xmit_get_slave() local
5421 slave = bond_xmit_roundrobin_slave_get(bond, skb); in bond_xmit_get_slave()
5424 slave = bond_xmit_activebackup_slave_get(bond); in bond_xmit_get_slave()
5432 slave = bond_xmit_3ad_xor_slave_get(bond, skb, slaves); in bond_xmit_get_slave()
5437 slave = bond_xmit_alb_slave_get(bond, skb); in bond_xmit_get_slave()
5440 slave = bond_xmit_tlb_slave_get(bond, skb); in bond_xmit_get_slave()
5448 if (slave) in bond_xmit_get_slave()
5449 return slave->dev; in bond_xmit_get_slave()
5503 struct slave *slave; in __bond_sk_get_lower_dev() local
5513 slave = slaves->arr[hash % count]; in __bond_sk_get_lower_dev()
5515 return slave->dev; in __bond_sk_get_lower_dev()
5608 struct slave *slave; in bond_xdp_get_xmit_slave() local
5614 slave = bond_xdp_xmit_roundrobin_slave_get(bond, xdp); in bond_xdp_get_xmit_slave()
5618 slave = bond_xmit_activebackup_slave_get(bond); in bond_xdp_get_xmit_slave()
5623 slave = bond_xdp_xmit_3ad_xor_slave_get(bond, xdp); in bond_xdp_get_xmit_slave()
5633 if (slave) in bond_xdp_get_xmit_slave()
5634 return slave->dev; in bond_xdp_get_xmit_slave()
5681 struct slave *slave, *rollback_slave; in bond_xdp_set() local
5699 bond_for_each_slave(bond, slave, iter) { in bond_xdp_set()
5700 struct net_device *slave_dev = slave->dev; in bond_xdp_set()
5705 "Slave device does not support XDP"); in bond_xdp_set()
5712 "Slave has XDP program loaded, please unload before enslaving"); in bond_xdp_set()
5746 if (slave == rollback_slave) in bond_xdp_set()
5769 static u32 bond_mode_bcast_speed(struct slave *slave, u32 speed) in bond_mode_bcast_speed() argument
5772 speed = slave->speed; in bond_mode_bcast_speed()
5774 speed = min(speed, slave->speed); in bond_mode_bcast_speed()
5845 struct slave *slave; in bond_ethtool_get_link_ksettings() local
5856 bond_for_each_slave(bond, slave, iter) { in bond_ethtool_get_link_ksettings()
5857 if (bond_slave_can_tx(slave)) { in bond_ethtool_get_link_ksettings()
5858 bond_update_speed_duplex(slave); in bond_ethtool_get_link_ksettings()
5859 if (slave->speed != SPEED_UNKNOWN) { in bond_ethtool_get_link_ksettings()
5861 speed = bond_mode_bcast_speed(slave, in bond_ethtool_get_link_ksettings()
5864 speed += slave->speed; in bond_ethtool_get_link_ksettings()
5867 slave->duplex != DUPLEX_UNKNOWN) in bond_ethtool_get_link_ksettings()
5868 cmd->base.duplex = slave->duplex; in bond_ethtool_get_link_ksettings()
5892 struct slave *slave; in bond_ethtool_get_ts_info() local
5905 bond_for_each_slave_rcu(bond, slave, iter) { in bond_ethtool_get_ts_info()
5906 ret = ethtool_get_ts_info_by_layer(slave->dev, &ts_info); in bond_ethtool_get_ts_info()
6052 struct slave *slave; in bond_uninit() local
6057 bond_for_each_slave(bond, slave, iter) in bond_uninit()
6058 __bond_release_one(bond_dev, slave->dev, true, true); in bond_uninit()