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
155 MODULE_PARM_DESC(primary_reselect, "Reselect primary slave "
160 "2 for only on active slave "
199 MODULE_PARM_DESC(packets_per_slave, "Packets to send per slave in balance-rr "
200 "mode; 0 for a random slave, 1 packet per "
201 "slave (default), >1 packets per slave.");
296 * @slave_dev: slave that is supposed to xmit this skbuff
348 * We don't protect the slave list iteration with a lock because:
373 struct slave *slave, *rollback_slave; in bond_vlan_rx_add_vid() local
377 bond_for_each_slave(bond, slave, iter) { in bond_vlan_rx_add_vid()
378 res = vlan_vid_add(slave->dev, proto, vid); in bond_vlan_rx_add_vid()
386 /* unwind to the slave that failed */ in bond_vlan_rx_add_vid()
388 if (rollback_slave == slave) in bond_vlan_rx_add_vid()
408 struct slave *slave; in bond_vlan_rx_kill_vid() local
410 bond_for_each_slave(bond, slave, iter) in bond_vlan_rx_kill_vid()
411 vlan_vid_del(slave->dev, proto, vid); in bond_vlan_rx_kill_vid()
434 struct slave *slave; in bond_ipsec_dev() local
440 slave = rcu_dereference(bond->curr_active_slave); in bond_ipsec_dev()
441 if (!slave) in bond_ipsec_dev()
447 if (xs->xso.real_dev != slave->dev) in bond_ipsec_dev()
448 pr_warn_ratelimited("%s: (slave %s): not same with IPsec offload real dev %s\n", in bond_ipsec_dev()
449 bond_dev->name, slave->dev->name, xs->xso.real_dev->name); in bond_ipsec_dev()
451 return slave->dev; in bond_ipsec_dev()
467 struct slave *slave; in bond_ipsec_add_sa() local
475 slave = rcu_dereference(bond->curr_active_slave); in bond_ipsec_add_sa()
476 real_dev = slave ? slave->dev : NULL; in bond_ipsec_add_sa()
487 NL_SET_ERR_MSG_MOD(extack, "Slave does not support ipsec offload"); in bond_ipsec_add_sa()
519 struct slave *slave; in bond_ipsec_add_sa_all() local
521 slave = rtnl_dereference(bond->curr_active_slave); in bond_ipsec_add_sa_all()
522 real_dev = slave ? slave->dev : NULL; in bond_ipsec_add_sa_all()
532 "%s: no slave xdo_dev_state_add\n", in bond_ipsec_add_sa_all()
563 struct slave *slave; in bond_ipsec_del_sa() local
570 slave = rcu_dereference(bond->curr_active_slave); in bond_ipsec_del_sa()
571 real_dev = slave ? slave->dev : NULL; in bond_ipsec_del_sa()
575 if (!slave) in bond_ipsec_del_sa()
586 slave_warn(bond_dev, real_dev, "%s: no slave xdo_dev_state_delete\n", __func__); in bond_ipsec_del_sa()
609 struct slave *slave; in bond_ipsec_del_sa_all() local
611 slave = rtnl_dereference(bond->curr_active_slave); in bond_ipsec_del_sa_all()
612 real_dev = slave ? slave->dev : NULL; in bond_ipsec_del_sa_all()
625 "%s: no slave xdo_dev_state_delete\n", in bond_ipsec_del_sa_all()
642 struct slave *slave; in bond_ipsec_free_sa() local
649 slave = rcu_dereference(bond->curr_active_slave); in bond_ipsec_free_sa()
650 real_dev = slave ? slave->dev : NULL; in bond_ipsec_free_sa()
654 if (!slave) in bond_ipsec_free_sa()
758 struct slave *slave; in bond_set_carrier() local
766 bond_for_each_slave(bond, slave, iter) { in bond_set_carrier()
767 if (slave->link == BOND_LINK_UP) { in bond_set_carrier()
784 /* Get link speed and duplex from the slave's base driver
790 static int bond_update_speed_duplex(struct slave *slave) in bond_update_speed_duplex() argument
792 struct net_device *slave_dev = slave->dev; in bond_update_speed_duplex()
796 slave->speed = SPEED_UNKNOWN; in bond_update_speed_duplex()
797 slave->duplex = DUPLEX_UNKNOWN; in bond_update_speed_duplex()
812 slave->speed = ecmd.base.speed; in bond_update_speed_duplex()
813 slave->duplex = ecmd.base.duplex; in bond_update_speed_duplex()
914 struct slave *curr_active = rtnl_dereference(bond->curr_active_slave); in bond_set_promiscuity()
919 struct slave *slave; in bond_set_promiscuity() local
921 bond_for_each_slave(bond, slave, iter) { in bond_set_promiscuity()
922 err = dev_set_promiscuity(slave->dev, inc); in bond_set_promiscuity()
937 struct slave *curr_active = rtnl_dereference(bond->curr_active_slave); in bond_set_allmulti()
942 struct slave *slave; in bond_set_allmulti() local
944 bond_for_each_slave(bond, slave, iter) { in bond_set_allmulti()
945 err = dev_set_allmulti(slave->dev, inc); in bond_set_allmulti()
955 * slave.
975 /* Flush bond's hardware addresses from slave */
988 /*--------------------------- Active slave change ---------------------------*/
995 static void bond_hw_addr_swap(struct bonding *bond, struct slave *new_active, in bond_hw_addr_swap()
996 struct slave *old_active) in bond_hw_addr_swap()
1031 * bond_set_dev_addr - clone slave's address to bond
1033 * @slave_dev: slave net device
1054 static struct slave *bond_get_old_active(struct bonding *bond, in bond_get_old_active()
1055 struct slave *new_active) in bond_get_old_active()
1057 struct slave *slave; in bond_get_old_active() local
1060 bond_for_each_slave(bond, slave, iter) { in bond_get_old_active()
1061 if (slave == new_active) in bond_get_old_active()
1064 if (ether_addr_equal(bond->dev->dev_addr, slave->dev->dev_addr)) in bond_get_old_active()
1065 return slave; in bond_get_old_active()
1078 struct slave *new_active, in bond_do_fail_over_mac()
1079 struct slave *old_active) in bond_do_fail_over_mac()
1090 slave_err(bond->dev, new_active->dev, "Error %d setting bond MAC from slave\n", in bond_do_fail_over_mac()
1096 * if just old_active, do nothing (going to no active slave) in bond_do_fail_over_mac()
1121 slave_err(bond->dev, new_active->dev, "Error %d setting MAC of new active slave\n", in bond_do_fail_over_mac()
1136 slave_err(bond->dev, old_active->dev, "Error %d setting MAC of old active slave\n", in bond_do_fail_over_mac()
1149 * bond_choose_primary_or_current - select the primary or high priority slave
1156 * If the highest priority link is not current slave, set it as primary
1159 static struct slave *bond_choose_primary_or_current(struct bonding *bond) in bond_choose_primary_or_current()
1161 struct slave *prim = rtnl_dereference(bond->primary_slave); in bond_choose_primary_or_current()
1162 struct slave *curr = rtnl_dereference(bond->curr_active_slave); in bond_choose_primary_or_current()
1163 struct slave *slave, *hprio = NULL; in bond_choose_primary_or_current() local
1167 bond_for_each_slave(bond, slave, iter) { in bond_choose_primary_or_current()
1168 if (slave->link == BOND_LINK_UP) { in bond_choose_primary_or_current()
1169 hprio = hprio ?: slave; in bond_choose_primary_or_current()
1170 if (slave->prio > hprio->prio) in bond_choose_primary_or_current()
1171 hprio = slave; in bond_choose_primary_or_current()
1214 * bond_find_best_slave - select the best available slave to be the active one
1217 static struct slave *bond_find_best_slave(struct bonding *bond) in bond_find_best_slave()
1219 struct slave *slave, *bestslave = NULL; in bond_find_best_slave() local
1223 slave = bond_choose_primary_or_current(bond); in bond_find_best_slave()
1224 if (slave) in bond_find_best_slave()
1225 return slave; in bond_find_best_slave()
1227 bond_for_each_slave(bond, slave, iter) { in bond_find_best_slave()
1228 if (slave->link == BOND_LINK_UP) in bond_find_best_slave()
1229 return slave; in bond_find_best_slave()
1230 if (slave->link == BOND_LINK_BACK && bond_slave_is_up(slave) && in bond_find_best_slave()
1231 slave->delay < mintime) { in bond_find_best_slave()
1232 mintime = slave->delay; in bond_find_best_slave()
1233 bestslave = slave; in bond_find_best_slave()
1243 struct slave *slave = rcu_dereference_rtnl(bond->curr_active_slave); in bond_should_notify_peers() local
1245 if (!slave || !bond->send_peer_notif || in bond_should_notify_peers()
1249 test_bit(__LINK_STATE_LINKWATCH_PENDING, &slave->dev->state)) in bond_should_notify_peers()
1252 netdev_dbg(bond->dev, "bond_should_notify_peers: slave %s\n", in bond_should_notify_peers()
1253 slave ? slave->dev->name : "NULL"); in bond_should_notify_peers()
1259 * bond_change_active_slave - change the active slave into the specified one
1261 * @new_active: the new slave to make the active one
1263 * Set the new slave to the bond's settings and unset them on the old
1268 * because it is apparently the best available slave we have, even though its
1273 void bond_change_active_slave(struct bonding *bond, struct slave *new_active) in bond_change_active_slave()
1275 struct slave *old_active; in bond_change_active_slave()
1363 /* resend IGMP joins since active slave has changed or in bond_change_active_slave()
1377 * bond_select_active_slave - select a new active slave, if needed
1383 * - A slave has got its link back and there's no old curr_active_slave.
1389 struct slave *best_slave; in bond_select_active_slave()
1409 static inline int slave_enable_netpoll(struct slave *slave) in slave_enable_netpoll() argument
1419 err = __netpoll_setup(np, slave->dev); in slave_enable_netpoll()
1424 slave->np = np; in slave_enable_netpoll()
1428 static inline void slave_disable_netpoll(struct slave *slave) in slave_disable_netpoll() argument
1430 struct netpoll *np = slave->np; in slave_disable_netpoll()
1435 slave->np = NULL; in slave_disable_netpoll()
1443 struct slave *slave = NULL; in bond_poll_controller() local
1451 bond_for_each_slave_rcu(bond, slave, iter) { in bond_poll_controller()
1452 if (!bond_slave_is_up(slave)) in bond_poll_controller()
1457 SLAVE_AD_INFO(slave)->port.aggregator; in bond_poll_controller()
1464 netpoll_poll_dev(slave->dev); in bond_poll_controller()
1472 struct slave *slave; in bond_netpoll_cleanup() local
1474 bond_for_each_slave(bond, slave, iter) in bond_netpoll_cleanup()
1475 if (bond_slave_is_up(slave)) in bond_netpoll_cleanup()
1476 slave_disable_netpoll(slave); in bond_netpoll_cleanup()
1483 struct slave *slave; in bond_netpoll_setup() local
1486 bond_for_each_slave(bond, slave, iter) { in bond_netpoll_setup()
1487 err = slave_enable_netpoll(slave); in bond_netpoll_setup()
1496 static inline int slave_enable_netpoll(struct slave *slave) in slave_enable_netpoll() argument
1500 static inline void slave_disable_netpoll(struct slave *slave) in slave_disable_netpoll() argument
1516 struct slave *slave; in bond_fix_features() local
1521 bond_for_each_slave(bond, slave, iter) { in bond_fix_features()
1523 slave->dev->features, in bond_fix_features()
1559 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->gso_partial_features, in bond_compute_features()
1589 slave->dev->mpls_features, in bond_compute_features()
1592 dst_release_flag &= slave->dev->priv_flags; in bond_compute_features()
1593 if (slave->dev->hard_header_len > max_hard_header_len) in bond_compute_features()
1594 max_hard_header_len = slave->dev->hard_header_len; in bond_compute_features()
1596 tso_max_size = min(tso_max_size, slave->dev->tso_max_size); in bond_compute_features()
1597 tso_max_segs = min(tso_max_segs, slave->dev->tso_max_segs); in bond_compute_features()
1647 /* On bonding slaves other than the currently active slave, suppress
1651 struct slave *slave, in bond_should_deliver_exact_match() argument
1654 if (bond_is_slave_inactive(slave)) { in bond_should_deliver_exact_match()
1667 struct slave *slave; in bond_handle_frame() local
1670 struct slave *); in bond_handle_frame()
1679 slave = bond_slave_get_rcu(skb->dev); in bond_handle_frame()
1680 bond = slave->bond; in bond_handle_frame()
1684 ret = recv_probe(skb, bond, slave); in bond_handle_frame()
1695 * inactive slave links without being forced to bind to them in bond_handle_frame()
1702 if (bond_should_deliver_exact_match(skb, slave, bond)) { in bond_handle_frame()
1767 static int bond_master_upper_dev_link(struct bonding *bond, struct slave *slave, in bond_master_upper_dev_link() argument
1778 err = netdev_master_upper_dev_link(slave->dev, bond->dev, slave, in bond_master_upper_dev_link()
1783 slave->dev->flags |= IFF_SLAVE; in bond_master_upper_dev_link()
1787 static void bond_upper_dev_unlink(struct bonding *bond, struct slave *slave) in bond_upper_dev_unlink() argument
1789 netdev_upper_dev_unlink(slave->dev, bond->dev); in bond_upper_dev_unlink()
1790 slave->dev->flags &= ~IFF_SLAVE; in bond_upper_dev_unlink()
1795 struct slave *slave = to_slave(kobj); in slave_kobj_release() local
1796 struct bonding *bond = bond_get_bond_by_slave(slave); in slave_kobj_release()
1798 cancel_delayed_work_sync(&slave->notify_work); in slave_kobj_release()
1800 kfree(SLAVE_AD_INFO(slave)); in slave_kobj_release()
1802 kfree(slave); in slave_kobj_release()
1812 static int bond_kobj_init(struct slave *slave) in bond_kobj_init() argument
1816 err = kobject_init_and_add(&slave->kobj, &slave_ktype, in bond_kobj_init()
1817 &(slave->dev->dev.kobj), "bonding_slave"); in bond_kobj_init()
1819 kobject_put(&slave->kobj); in bond_kobj_init()
1824 static struct slave *bond_alloc_slave(struct bonding *bond, in bond_alloc_slave()
1827 struct slave *slave = NULL; in bond_alloc_slave() local
1829 slave = kzalloc(sizeof(*slave), GFP_KERNEL); in bond_alloc_slave()
1830 if (!slave) in bond_alloc_slave()
1833 slave->bond = bond; in bond_alloc_slave()
1834 slave->dev = slave_dev; in bond_alloc_slave()
1835 INIT_DELAYED_WORK(&slave->notify_work, bond_netdev_notify_work); in bond_alloc_slave()
1837 if (bond_kobj_init(slave)) in bond_alloc_slave()
1841 SLAVE_AD_INFO(slave) = kzalloc(sizeof(struct ad_slave_info), in bond_alloc_slave()
1843 if (!SLAVE_AD_INFO(slave)) { in bond_alloc_slave()
1844 kobject_put(&slave->kobj); in bond_alloc_slave()
1849 return slave; in bond_alloc_slave()
1859 static void bond_fill_ifslave(struct slave *slave, struct ifslave *info) in bond_fill_ifslave() argument
1861 strcpy(info->slave_name, slave->dev->name); in bond_fill_ifslave()
1862 info->link = slave->link; in bond_fill_ifslave()
1863 info->state = bond_slave_state(slave); in bond_fill_ifslave()
1864 info->link_failure_count = slave->link_failure_count; in bond_fill_ifslave()
1869 struct slave *slave = container_of(_work, struct slave, in bond_netdev_notify_work() local
1875 bond_fill_ifslave(slave, &binfo.slave); in bond_netdev_notify_work()
1876 bond_fill_ifbond(slave->bond, &binfo.master); in bond_netdev_notify_work()
1877 netdev_bonding_info_change(slave->dev, &binfo); in bond_netdev_notify_work()
1880 queue_delayed_work(slave->bond->wq, &slave->notify_work, 1); in bond_netdev_notify_work()
1884 void bond_queue_slave_event(struct slave *slave) in bond_queue_slave_event() argument
1886 queue_delayed_work(slave->bond->wq, &slave->notify_work, 0); in bond_queue_slave_event()
1889 void bond_lower_state_changed(struct slave *slave) in bond_lower_state_changed() argument
1893 info.link_up = slave->link == BOND_LINK_UP || in bond_lower_state_changed()
1894 slave->link == BOND_LINK_FAIL; in bond_lower_state_changed()
1895 info.tx_enabled = bond_is_active_slave(slave); in bond_lower_state_changed()
1896 netdev_lower_state_changed(slave->dev, &info); in bond_lower_state_changed()
1932 struct slave *slave; in bond_xdp_set_features() local
1941 bond_for_each_slave(bond, slave, iter) in bond_xdp_set_features()
1942 val &= slave->dev->xdp_features; in bond_xdp_set_features()
1949 /* enslave device <slave> to bond device <master> */
1955 struct slave *new_slave = NULL, *prev_slave; in bond_enslave()
1994 …slave_warn(bond_dev, slave_dev, "enslaved VLAN challenged slave. Adding VLANs will be blocked as l… in bond_enslave()
2004 * be identified with moderate accuracy by the state of the slave: in bond_enslave()
2014 /* set bonding device ether type by slave - bonding netdevices are in bond_enslave()
2015 * created with ether_setup, so when the slave type is not ARPHRD_ETHER in bond_enslave()
2062 …slave_warn(bond_dev, slave_dev, "The slave device specified does not support setting the MAC addre… in bond_enslave()
2070 … "Slave device does not support setting the MAC address, but fail_over_mac is not set to active"); in bond_enslave()
2079 /* If this is the first slave, then we need to set the master's hardware in bond_enslave()
2080 * address to be the same as the slave's. in bond_enslave()
2100 /* Save slave's original mtu and then set it to match the bond */ in bond_enslave()
2108 /* Save slave's original ("permanent") mac address for modes in bond_enslave()
2117 /* Set slave to master's mac address. The application already in bond_enslave()
2118 * set the master's mac address to that of the first slave in bond_enslave()
2133 /* open the slave since the application closed it */ in bond_enslave()
2136 slave_err(bond_dev, slave_dev, "Opening slave failed\n"); in bond_enslave()
2141 /* initialize slave stats */ in bond_enslave()
2187 …slave_warn(bond_dev, slave_dev, "MII and ETHTOOL support not available for slave, and arp_interval… in bond_enslave()
2190 …slave_warn(bond_dev, slave_dev, "can't get link status from slave; the network driver associated w… in bond_enslave()
2224 slave_dbg(bond_dev, slave_dev, "Initial state of slave is BOND_LINK_%s\n", in bond_enslave()
2229 /* if there is a primary slave, remember it */ in bond_enslave()
2247 /* if this is the first slave */ in bond_enslave()
2267 slave_dbg(bond_dev, slave_dev, "This slave is always active in trunk mode\n"); in bond_enslave()
2286 …slave_info(bond_dev, slave_dev, "master_dev is using netpoll, but new slave device does not suppor… in bond_enslave()
2321 /* set promiscuity level to new slave */ in bond_enslave()
2328 /* set allmulti level to new slave */ in bond_enslave()
2354 * remove the maddrs if the slave is selected as active slave. in bond_enslave()
2371 "Slave does not support XDP"); in bond_enslave()
2385 "Slave has XDP program loaded, please unload before enslaving"); in bond_enslave()
2444 * MAC if this slave's MAC is in use by the bond, or at in bond_enslave()
2460 /* Enslave of first slave has failed and we need to fix master's mac */ in bond_enslave()
2474 /* Try to release the slave device <slave> from the bond device <master>
2479 * The rules for slave state should be:
2490 struct slave *slave, *oldcurrent; in __bond_release_one() local
2495 /* slave is not a slave or master is not master of this slave */ in __bond_release_one()
2498 slave_dbg(bond_dev, slave_dev, "cannot release slave\n"); in __bond_release_one()
2504 slave = bond_get_slave_by_dev(bond, slave_dev); in __bond_release_one()
2505 if (!slave) { in __bond_release_one()
2506 /* not a slave of this bond */ in __bond_release_one()
2512 bond_set_slave_inactive_flags(slave, BOND_SLAVE_NOTIFY_NOW); in __bond_release_one()
2514 bond_sysfs_slave_del(slave); in __bond_release_one()
2516 /* recompute stats just before removing the slave */ in __bond_release_one()
2531 * for this slave anymore. in __bond_release_one()
2536 bond_3ad_unbind_slave(slave); in __bond_release_one()
2538 bond_upper_dev_unlink(bond, slave); in __bond_release_one()
2541 bond_update_slave_arr(bond, slave); in __bond_release_one()
2544 bond_is_active_slave(slave) ? "active" : "backup"); in __bond_release_one()
2552 if (ether_addr_equal_64bits(bond_dev->dev_addr, slave->perm_hwaddr) && in __bond_release_one()
2554 …ond_dev, slave_dev, "the permanent HWaddr of slave - %pM - is still in use by bond - set the HWadd… in __bond_release_one()
2555 slave->perm_hwaddr); in __bond_release_one()
2558 if (rtnl_dereference(bond->primary_slave) == slave) in __bond_release_one()
2561 if (oldcurrent == slave) in __bond_release_one()
2564 /* Must be called after bond_change_active_slave () as the slave in __bond_release_one()
2565 * might change from an active slave to a backup slave. Then it is in __bond_release_one()
2566 * necessary to clear the maddrs on the backup slave. in __bond_release_one()
2568 bond_slave_ns_maddrs_del(bond, slave); in __bond_release_one()
2571 /* Must be called only after the slave has been in __bond_release_one()
2574 * but before a new active slave is selected. in __bond_release_one()
2576 bond_alb_deinit_slave(bond, slave); in __bond_release_one()
2581 } else if (oldcurrent == slave) { in __bond_release_one()
2583 * is no concern that another slave add/remove event in __bond_release_one()
2605 …slave_info(bond_dev, slave_dev, "last VLAN challenged slave left bond - VLAN blocking is removed\n… in __bond_release_one()
2613 /* unset promiscuity level from slave in __bond_release_one()
2617 * when this slave was attached, so we cache at the start of the in __bond_release_one()
2623 /* unset allmulti level from slave */ in __bond_release_one()
2631 slave_disable_netpoll(slave); in __bond_release_one()
2633 /* close slave before restoring its mac address */ in __bond_release_one()
2641 bond_hw_addr_copy(ss.__data, slave->perm_hwaddr, in __bond_release_one()
2642 slave->dev->addr_len); in __bond_release_one()
2649 __dev_set_mtu(slave_dev, slave->original_mtu); in __bond_release_one()
2652 dev_set_mtu(slave_dev, slave->original_mtu); in __bond_release_one()
2659 kobject_put(&slave->kobj); in __bond_release_one()
2670 /* First release a slave and then destroy the bond if no more slaves are left.
2702 struct slave *slave; in bond_slave_info_query() local
2704 bond_for_each_slave(bond, slave, iter) { in bond_slave_info_query()
2707 bond_fill_ifslave(slave, info); in bond_slave_info_query()
2723 struct slave *slave; in bond_miimon_inspect() local
2736 bond_for_each_slave_rcu(bond, slave, iter) { in bond_miimon_inspect()
2737 bond_propose_link_state(slave, BOND_LINK_NOCHANGE); in bond_miimon_inspect()
2739 link_state = bond_check_dev_link(bond, slave->dev, 0); in bond_miimon_inspect()
2741 switch (slave->link) { in bond_miimon_inspect()
2746 bond_propose_link_state(slave, BOND_LINK_FAIL); in bond_miimon_inspect()
2748 slave->delay = bond->params.downdelay; in bond_miimon_inspect()
2749 if (slave->delay && net_ratelimit()) { in bond_miimon_inspect()
2750 slave_info(bond->dev, slave->dev, "link status down for %sinterface, disabling it in %d ms\n", in bond_miimon_inspect()
2753 (bond_is_active_slave(slave) ? in bond_miimon_inspect()
2761 bond_propose_link_state(slave, BOND_LINK_UP); in bond_miimon_inspect()
2762 slave->last_link_up = jiffies; in bond_miimon_inspect()
2764 slave_info(bond->dev, slave->dev, "link status up again after %d ms\n", in bond_miimon_inspect()
2765 (bond->params.downdelay - slave->delay) * in bond_miimon_inspect()
2771 if (slave->delay <= 0) { in bond_miimon_inspect()
2772 bond_propose_link_state(slave, BOND_LINK_DOWN); in bond_miimon_inspect()
2777 slave->delay--; in bond_miimon_inspect()
2784 bond_propose_link_state(slave, BOND_LINK_BACK); in bond_miimon_inspect()
2786 slave->delay = bond->params.updelay; in bond_miimon_inspect()
2788 if (slave->delay && net_ratelimit()) { in bond_miimon_inspect()
2789 slave_info(bond->dev, slave->dev, "link status up, enabling it in %d ms\n", in bond_miimon_inspect()
2797 bond_propose_link_state(slave, BOND_LINK_DOWN); in bond_miimon_inspect()
2799 slave_info(bond->dev, slave->dev, "link status down again after %d ms\n", in bond_miimon_inspect()
2800 (bond->params.updelay - slave->delay) * in bond_miimon_inspect()
2807 slave->delay = 0; in bond_miimon_inspect()
2809 if (slave->delay <= 0) { in bond_miimon_inspect()
2810 bond_propose_link_state(slave, BOND_LINK_UP); in bond_miimon_inspect()
2816 slave->delay--; in bond_miimon_inspect()
2825 struct slave *slave, in bond_miimon_link_change() argument
2830 bond_3ad_handle_link_change(slave, link); in bond_miimon_link_change()
2834 bond_alb_handle_link_change(bond, slave, link); in bond_miimon_link_change()
2844 struct slave *slave, *primary, *active; in bond_miimon_commit() local
2850 bond_for_each_slave(bond, slave, iter) { in bond_miimon_commit()
2851 switch (slave->link_new_state) { in bond_miimon_commit()
2853 /* For 802.3ad mode, check current slave speed and in bond_miimon_commit()
2860 slave->link == BOND_LINK_UP) in bond_miimon_commit()
2861 bond_3ad_adapter_speed_duplex_changed(slave); in bond_miimon_commit()
2865 if (bond_update_speed_duplex(slave) && in bond_miimon_commit()
2867 slave->link = BOND_LINK_DOWN; in bond_miimon_commit()
2869 slave_warn(bond->dev, slave->dev, in bond_miimon_commit()
2873 bond_set_slave_link_state(slave, BOND_LINK_UP, in bond_miimon_commit()
2875 slave->last_link_up = jiffies; in bond_miimon_commit()
2880 bond_set_backup_slave(slave); in bond_miimon_commit()
2883 bond_set_active_slave(slave); in bond_miimon_commit()
2886 slave_info(bond->dev, slave->dev, "link status definitely up, %u Mbps %s duplex\n", in bond_miimon_commit()
2887 slave->speed == SPEED_UNKNOWN ? 0 : slave->speed, in bond_miimon_commit()
2888 slave->duplex ? "full" : "half"); in bond_miimon_commit()
2890 bond_miimon_link_change(bond, slave, BOND_LINK_UP); in bond_miimon_commit()
2893 if (!active || slave == primary || slave->prio > active->prio) in bond_miimon_commit()
2899 if (slave->link_failure_count < UINT_MAX) in bond_miimon_commit()
2900 slave->link_failure_count++; in bond_miimon_commit()
2902 bond_set_slave_link_state(slave, BOND_LINK_DOWN, in bond_miimon_commit()
2907 bond_set_slave_inactive_flags(slave, in bond_miimon_commit()
2910 slave_info(bond->dev, slave->dev, "link status definitely down, disabling slave\n"); in bond_miimon_commit()
2912 bond_miimon_link_change(bond, slave, BOND_LINK_DOWN); in bond_miimon_commit()
2914 if (slave == rcu_access_pointer(bond->curr_active_slave)) in bond_miimon_commit()
2920 slave_err(bond->dev, slave->dev, "invalid new link %d on slave\n", in bond_miimon_commit()
2921 slave->link_new_state); in bond_miimon_commit()
2922 bond_propose_link_state(slave, BOND_LINK_NOCHANGE); in bond_miimon_commit()
2951 struct slave *slave; in bond_mii_monitor() local
2980 bond_for_each_slave(bond, slave, iter) { in bond_mii_monitor()
2981 bond_commit_link_state(slave, BOND_SLAVE_NOTIFY_LATER); in bond_mii_monitor()
3028 static bool bond_handle_vlan(struct slave *slave, struct bond_vlan_tag *tags, in bond_handle_vlan() argument
3031 struct net_device *bond_dev = slave->bond->dev; in bond_handle_vlan()
3032 struct net_device *slave_dev = slave->dev; in bond_handle_vlan()
3073 static void bond_arp_send(struct slave *slave, int arp_op, __be32 dest_ip, in bond_arp_send() argument
3076 struct net_device *bond_dev = slave->bond->dev; in bond_arp_send()
3077 struct net_device *slave_dev = slave->dev; in bond_arp_send()
3080 slave_dbg(bond_dev, slave_dev, "arp %d on slave: dst %pI4 src %pI4\n", in bond_arp_send()
3091 if (bond_handle_vlan(slave, tags, skb)) { in bond_arp_send()
3092 slave_update_last_tx(slave); in bond_arp_send()
3139 static void bond_arp_send_all(struct bonding *bond, struct slave *slave) in bond_arp_send_all() argument
3147 slave_dbg(bond->dev, slave->dev, "%s: target %pI4\n", in bond_arp_send_all()
3162 bond_arp_send(slave, ARPOP_REQUEST, targets[i], in bond_arp_send_all()
3179 slave_dbg(bond->dev, slave->dev, "no path to arp_ip_target %pI4 via rt.dev %s\n", in bond_arp_send_all()
3188 bond_arp_send(slave, ARPOP_REQUEST, targets[i], addr, tags); in bond_arp_send_all()
3193 static void bond_validate_arp(struct bonding *bond, struct slave *slave, __be32 sip, __be32 tip) in bond_validate_arp() argument
3198 slave_dbg(bond->dev, slave->dev, "%s: sip %pI4 tip %pI4 not found\n", in bond_validate_arp()
3205 slave_dbg(bond->dev, slave->dev, "%s: sip %pI4 not found in targets\n", in bond_validate_arp()
3209 slave->last_rx = jiffies; in bond_validate_arp()
3210 slave->target_last_arp_rx[i] = jiffies; in bond_validate_arp()
3214 struct slave *slave) in bond_arp_rcv() argument
3217 struct slave *curr_active_slave, *curr_arp_slave; in bond_arp_rcv()
3246 slave_dbg(bond->dev, slave->dev, "%s: %s/%d av %d sv %d sip %pI4 tip %pI4\n", in bond_arp_rcv()
3247 __func__, slave->dev->name, bond_slave_state(slave), in bond_arp_rcv()
3248 bond->params.arp_validate, slave_do_arp_validate(bond, slave), in bond_arp_rcv()
3256 * (a) the slave receiving the ARP is active (which includes the in bond_arp_rcv()
3257 * current ARP slave, if any), or in bond_arp_rcv()
3259 * (b) the receiving slave isn't active, but there is a currently in bond_arp_rcv()
3260 * active slave and it received valid arp reply(s) after it became in bond_arp_rcv()
3261 * the currently active slave, or in bond_arp_rcv()
3263 * (c) there is an ARP slave that sent an ARP during the prior ARP in bond_arp_rcv()
3264 * interval, and we receive an ARP reply on any slave. We accept in bond_arp_rcv()
3266 * reply to a slave other than the sender of the ARP request. in bond_arp_rcv()
3270 * slave through the L2 switch(es) to the receiving slave. Since in bond_arp_rcv()
3277 if (bond_is_active_slave(slave)) in bond_arp_rcv()
3278 bond_validate_arp(bond, slave, sip, tip); in bond_arp_rcv()
3282 bond_validate_arp(bond, slave, tip, sip); in bond_arp_rcv()
3285 bond_validate_arp(bond, slave, sip, tip); in bond_arp_rcv()
3294 static void bond_ns_send(struct slave *slave, const struct in6_addr *daddr, in bond_ns_send() argument
3297 struct net_device *bond_dev = slave->bond->dev; in bond_ns_send()
3298 struct net_device *slave_dev = slave->dev; in bond_ns_send()
3302 slave_dbg(bond_dev, slave_dev, "NS on slave: dst %pI6c src %pI6c\n", in bond_ns_send()
3312 if (bond_handle_vlan(slave, tags, skb)) { in bond_ns_send()
3313 slave_update_last_tx(slave); in bond_ns_send()
3318 static void bond_ns_send_all(struct bonding *bond, struct slave *slave) in bond_ns_send_all() argument
3328 slave_dbg(bond->dev, slave->dev, "%s: target %pI6c\n", in bond_ns_send_all()
3347 bond_ns_send(slave, &targets[i], &in6addr_any, tags); in bond_ns_send_all()
3363 slave_dbg(bond->dev, slave->dev, "no path to ns_ip6_target %pI6c via dst->dev %s\n", in bond_ns_send_all()
3371 bond_ns_send(slave, &targets[i], &saddr, tags); in bond_ns_send_all()
3373 bond_ns_send(slave, &targets[i], &in6addr_any, tags); in bond_ns_send_all()
3406 static void bond_validate_na(struct bonding *bond, struct slave *slave, in bond_validate_na() argument
3419 slave_dbg(bond->dev, slave->dev, "%s: sip %pI6c tip %pI6c not found\n", in bond_validate_na()
3426 slave_dbg(bond->dev, slave->dev, "%s: sip %pI6c not found in targets\n", in bond_validate_na()
3430 slave->last_rx = jiffies; in bond_validate_na()
3431 slave->target_last_arp_rx[i] = jiffies; in bond_validate_na()
3435 struct slave *slave) in bond_na_rcv() argument
3437 struct slave *curr_active_slave, *curr_arp_slave; in bond_na_rcv()
3457 slave_dbg(bond->dev, slave->dev, "%s: %s/%d av %d sv %d sip %pI6c tip %pI6c\n", in bond_na_rcv()
3458 __func__, slave->dev->name, bond_slave_state(slave), in bond_na_rcv()
3459 bond->params.arp_validate, slave_do_arp_validate(bond, slave), in bond_na_rcv()
3468 if (bond_is_active_slave(slave)) in bond_na_rcv()
3469 bond_validate_na(bond, slave, saddr, daddr); in bond_na_rcv()
3473 bond_validate_na(bond, slave, daddr, saddr); in bond_na_rcv()
3476 bond_validate_na(bond, slave, saddr, daddr); in bond_na_rcv()
3484 struct slave *slave) in bond_rcv_validate() argument
3491 slave_dbg(bond->dev, slave->dev, "%s: skb->dev %s\n", in bond_rcv_validate()
3495 if (!slave_do_arp_validate(bond, slave)) { in bond_rcv_validate()
3501 slave->last_rx = jiffies; in bond_rcv_validate()
3504 return bond_arp_rcv(skb, bond, slave); in bond_rcv_validate()
3507 return bond_na_rcv(skb, bond, slave); in bond_rcv_validate()
3514 static void bond_send_validate(struct bonding *bond, struct slave *slave) in bond_send_validate() argument
3516 bond_arp_send_all(bond, slave); in bond_send_validate()
3518 bond_ns_send_all(bond, slave); in bond_send_validate()
3536 /* This function is called regularly to monitor each slave's link
3544 struct slave *slave, *oldcurrent; in bond_loadbalance_arp_mon() local
3556 * the picture unless it is null. also, slave->last_link_up is not in bond_loadbalance_arp_mon()
3557 * needed here because we send an arp on each slave and give a slave in bond_loadbalance_arp_mon()
3562 bond_for_each_slave_rcu(bond, slave, iter) { in bond_loadbalance_arp_mon()
3563 unsigned long last_tx = slave_last_tx(slave); in bond_loadbalance_arp_mon()
3565 bond_propose_link_state(slave, BOND_LINK_NOCHANGE); in bond_loadbalance_arp_mon()
3567 if (slave->link != BOND_LINK_UP) { in bond_loadbalance_arp_mon()
3569 bond_time_in_interval(bond, slave->last_rx, 1)) { in bond_loadbalance_arp_mon()
3571 bond_propose_link_state(slave, BOND_LINK_UP); in bond_loadbalance_arp_mon()
3575 * mode. the window of a slave being up and in bond_loadbalance_arp_mon()
3580 slave_info(bond->dev, slave->dev, "link status definitely up\n"); in bond_loadbalance_arp_mon()
3583 slave_info(bond->dev, slave->dev, "interface is now up\n"); in bond_loadbalance_arp_mon()
3587 /* slave->link == BOND_LINK_UP */ in bond_loadbalance_arp_mon()
3594 !bond_time_in_interval(bond, slave->last_rx, bond->params.missed_max)) { in bond_loadbalance_arp_mon()
3596 bond_propose_link_state(slave, BOND_LINK_DOWN); in bond_loadbalance_arp_mon()
3599 if (slave->link_failure_count < UINT_MAX) in bond_loadbalance_arp_mon()
3600 slave->link_failure_count++; in bond_loadbalance_arp_mon()
3602 slave_info(bond->dev, slave->dev, "interface is now down\n"); in bond_loadbalance_arp_mon()
3604 if (slave == oldcurrent) in bond_loadbalance_arp_mon()
3616 if (bond_slave_is_up(slave)) in bond_loadbalance_arp_mon()
3617 bond_send_validate(bond, slave); in bond_loadbalance_arp_mon()
3626 bond_for_each_slave(bond, slave, iter) { in bond_loadbalance_arp_mon()
3627 if (slave->link_new_state != BOND_LINK_NOCHANGE) in bond_loadbalance_arp_mon()
3628 slave->link = slave->link_new_state; in bond_loadbalance_arp_mon()
3652 * should take place for the slave. Returns 0 if no changes are found, >0
3661 struct slave *slave; in bond_ab_arp_inspect() local
3664 bond_for_each_slave_rcu(bond, slave, iter) { in bond_ab_arp_inspect()
3665 bond_propose_link_state(slave, BOND_LINK_NOCHANGE); in bond_ab_arp_inspect()
3666 last_rx = slave_last_rx(bond, slave); in bond_ab_arp_inspect()
3668 if (slave->link != BOND_LINK_UP) { in bond_ab_arp_inspect()
3670 bond_propose_link_state(slave, BOND_LINK_UP); in bond_ab_arp_inspect()
3672 } else if (slave->link == BOND_LINK_BACK) { in bond_ab_arp_inspect()
3673 bond_propose_link_state(slave, BOND_LINK_FAIL); in bond_ab_arp_inspect()
3683 if (bond_time_in_interval(bond, slave->last_link_up, 2)) in bond_ab_arp_inspect()
3686 /* Backup slave is down if: in bond_ab_arp_inspect()
3695 * gives each slave a chance to tx/rx traffic in bond_ab_arp_inspect()
3698 if (!bond_is_active_slave(slave) && in bond_ab_arp_inspect()
3701 bond_propose_link_state(slave, BOND_LINK_DOWN); in bond_ab_arp_inspect()
3705 /* Active slave is down if: in bond_ab_arp_inspect()
3710 last_tx = slave_last_tx(slave); in bond_ab_arp_inspect()
3711 if (bond_is_active_slave(slave) && in bond_ab_arp_inspect()
3714 bond_propose_link_state(slave, BOND_LINK_DOWN); in bond_ab_arp_inspect()
3732 struct slave *slave; in bond_ab_arp_commit() local
3734 bond_for_each_slave(bond, slave, iter) { in bond_ab_arp_commit()
3735 switch (slave->link_new_state) { in bond_ab_arp_commit()
3740 last_tx = slave_last_tx(slave); in bond_ab_arp_commit()
3741 if (rtnl_dereference(bond->curr_active_slave) != slave || in bond_ab_arp_commit()
3744 struct slave *current_arp_slave; in bond_ab_arp_commit()
3747 bond_set_slave_link_state(slave, BOND_LINK_UP, in bond_ab_arp_commit()
3756 slave_info(bond->dev, slave->dev, "link status definitely up\n"); in bond_ab_arp_commit()
3759 slave == rtnl_dereference(bond->primary_slave) || in bond_ab_arp_commit()
3760 slave->prio > rtnl_dereference(bond->curr_active_slave)->prio) in bond_ab_arp_commit()
3768 if (slave->link_failure_count < UINT_MAX) in bond_ab_arp_commit()
3769 slave->link_failure_count++; in bond_ab_arp_commit()
3771 bond_set_slave_link_state(slave, BOND_LINK_DOWN, in bond_ab_arp_commit()
3773 bond_set_slave_inactive_flags(slave, in bond_ab_arp_commit()
3776 slave_info(bond->dev, slave->dev, "link status definitely down, disabling slave\n"); in bond_ab_arp_commit()
3778 if (slave == rtnl_dereference(bond->curr_active_slave)) { in bond_ab_arp_commit()
3786 bond_set_slave_link_state(slave, BOND_LINK_FAIL, in bond_ab_arp_commit()
3788 bond_set_slave_inactive_flags(slave, in bond_ab_arp_commit()
3791 /* A slave has just been enslaved and has become in bond_ab_arp_commit()
3792 * the current active slave. in bond_ab_arp_commit()
3799 slave_err(bond->dev, slave->dev, in bond_ab_arp_commit()
3800 "impossible: link_new_state %d on slave\n", in bond_ab_arp_commit()
3801 slave->link_new_state); in bond_ab_arp_commit()
3821 struct slave *slave, *before = NULL, *new_slave = NULL, in bond_ab_arp_probe() local
3839 * backup slave from the current_arp_slave and make it the candidate in bond_ab_arp_probe()
3849 bond_for_each_slave_rcu(bond, slave, iter) { in bond_ab_arp_probe()
3850 if (!found && !before && bond_slave_is_up(slave)) in bond_ab_arp_probe()
3851 before = slave; in bond_ab_arp_probe()
3853 if (found && !new_slave && bond_slave_is_up(slave)) in bond_ab_arp_probe()
3854 new_slave = slave; in bond_ab_arp_probe()
3859 * one the current slave so it is still marked in bond_ab_arp_probe()
3862 if (!bond_slave_is_up(slave) && slave->link == BOND_LINK_UP) { in bond_ab_arp_probe()
3863 bond_set_slave_link_state(slave, BOND_LINK_DOWN, in bond_ab_arp_probe()
3865 if (slave->link_failure_count < UINT_MAX) in bond_ab_arp_probe()
3866 slave->link_failure_count++; in bond_ab_arp_probe()
3868 bond_set_slave_inactive_flags(slave, in bond_ab_arp_probe()
3871 slave_info(bond->dev, slave->dev, "backup interface is now down\n"); in bond_ab_arp_probe()
3873 if (slave == curr_arp_slave) in bond_ab_arp_probe()
3891 bond_for_each_slave_rcu(bond, slave, iter) { in bond_ab_arp_probe()
3892 if (slave->should_notify || slave->should_notify_link) { in bond_ab_arp_probe()
4009 struct slave *slave = bond_slave_get_rtnl(slave_dev), *primary; in bond_slave_netdev_event() local
4015 * slave will be NULL in bond_slave_netdev_event()
4017 if (!slave) { in bond_slave_netdev_event()
4018 netdev_dbg(slave_dev, "%s called on NULL slave\n", __func__); in bond_slave_netdev_event()
4022 bond_dev = slave->bond->dev; in bond_slave_netdev_event()
4023 bond = slave->bond; in bond_slave_netdev_event()
4038 * Getting invalid Speed/Duplex values here will put slave in bond_slave_netdev_event()
4044 if (bond_update_speed_duplex(slave) && in bond_slave_netdev_event()
4046 if (slave->last_link_up) in bond_slave_netdev_event()
4047 slave->link = BOND_LINK_FAIL; in bond_slave_netdev_event()
4049 slave->link = BOND_LINK_DOWN; in bond_slave_netdev_event()
4053 bond_3ad_adapter_speed_duplex_changed(slave); in bond_slave_netdev_event()
4056 /* Refresh slave-array if applicable! in bond_slave_netdev_event()
4058 * then these events will not cause the slave-array to be in bond_slave_netdev_event()
4059 * refreshed. This will cause xmit to use a slave that is not in bond_slave_netdev_event()
4075 * take over the slave's change_mtu in bond_slave_netdev_event()
4086 if (slave == primary) { in bond_slave_netdev_event()
4087 /* slave's name changed - he's no longer primary */ in bond_slave_netdev_event()
4090 /* we have a new primary slave */ in bond_slave_netdev_event()
4091 rcu_assign_pointer(bond->primary_slave, slave); in bond_slave_netdev_event()
4096 netdev_info(bond->dev, "Primary slave changed to %s, reselecting active slave\n", in bond_slave_netdev_event()
4112 call_netdevice_notifiers(event, slave->bond->dev); in bond_slave_netdev_event()
4128 * locks for us to safely manipulate the slave devices (RTNL lock,
4405 struct slave *slave; in bond_open() local
4413 /* reset slave->backup and slave->inactive */ in bond_open()
4415 bond_for_each_slave(bond, slave, iter) { in bond_open()
4417 slave != rcu_access_pointer(bond->curr_active_slave)) { in bond_open()
4418 bond_set_slave_inactive_flags(slave, in bond_open()
4421 bond_set_slave_active_flags(slave, in bond_open()
4451 bond_for_each_slave(bond, slave, iter) in bond_open()
4452 dev_mc_add(slave->dev, lacpdu_mcast_addr); in bond_open()
4464 struct slave *slave; in bond_close() local
4474 slave = rcu_dereference(bond->curr_active_slave); in bond_close()
4475 if (slave) in bond_close()
4476 bond_hw_addr_flush(bond_dev, slave->dev); in bond_close()
4481 bond_for_each_slave(bond, slave, iter) in bond_close()
4482 bond_hw_addr_flush(bond_dev, slave->dev); in bond_close()
4564 struct slave *slave; in bond_get_stats() local
4576 bond_for_each_slave_rcu(bond, slave, iter) { in bond_get_stats()
4578 dev_get_stats(slave->dev, &temp); in bond_get_stats()
4580 bond_fold_stats(stats, new, &slave->slave_stats); in bond_get_stats()
4582 /* save off the slave stats for the next run */ in bond_get_stats()
4583 memcpy(&slave->slave_stats, new, sizeof(*new)); in bond_get_stats()
4744 struct slave *slave; in bond_set_rx_mode() local
4748 slave = rcu_dereference(bond->curr_active_slave); in bond_set_rx_mode()
4749 if (slave) { in bond_set_rx_mode()
4750 dev_uc_sync(slave->dev, bond_dev); in bond_set_rx_mode()
4751 dev_mc_sync(slave->dev, bond_dev); in bond_set_rx_mode()
4754 bond_for_each_slave_rcu(bond, slave, iter) { in bond_set_rx_mode()
4755 dev_uc_sync_multiple(slave->dev, bond_dev); in bond_set_rx_mode()
4756 dev_mc_sync_multiple(slave->dev, bond_dev); in bond_set_rx_mode()
4767 struct slave *slave; in bond_neigh_init() local
4771 slave = bond_first_slave_rcu(bond); in bond_neigh_init()
4772 if (!slave) in bond_neigh_init()
4774 slave_ops = slave->dev->netdev_ops; in bond_neigh_init()
4787 ret = slave_ops->ndo_neigh_setup(slave->dev, &parms); in bond_neigh_init()
4800 * slave exists. So we must declare proxy setup function which will
4801 * be used at run time to resolve the actual slave neigh param setup.
4821 struct slave *slave, *rollback_slave; in bond_change_mtu() local
4827 bond_for_each_slave(bond, slave, iter) { in bond_change_mtu()
4828 slave_dbg(bond_dev, slave->dev, "s %p c_m %p\n", in bond_change_mtu()
4829 slave, slave->dev->netdev_ops->ndo_change_mtu); in bond_change_mtu()
4831 res = dev_set_mtu(slave->dev, new_mtu); in bond_change_mtu()
4834 /* If we failed to set the slave's mtu to the new value in bond_change_mtu()
4837 * different mtu values than the active slave we'll in bond_change_mtu()
4842 slave_dbg(bond_dev, slave->dev, "err %d setting mtu to %d\n", in bond_change_mtu()
4853 /* unwind from head to the slave that failed */ in bond_change_mtu()
4857 if (rollback_slave == slave) in bond_change_mtu()
4878 struct slave *slave, *rollback_slave; in bond_set_mac_address() local
4899 bond_for_each_slave(bond, slave, iter) { in bond_set_mac_address()
4900 slave_dbg(bond_dev, slave->dev, "%s: slave=%p\n", in bond_set_mac_address()
4901 __func__, slave); in bond_set_mac_address()
4902 res = dev_set_mac_address(slave->dev, addr, NULL); in bond_set_mac_address()
4904 /* TODO: consider downing the slave in bond_set_mac_address()
4910 slave_dbg(bond_dev, slave->dev, "%s: err %d\n", in bond_set_mac_address()
4924 /* unwind from head to the slave that failed */ in bond_set_mac_address()
4928 if (rollback_slave == slave) in bond_set_mac_address()
4943 * bond_get_slave_by_id - get xmit slave with slave_id
4945 * @slave_id: slave id up to slave_cnt-1 through which to transmit
4947 * This function tries to get slave with slave_id but in case
4948 * it fails, it tries to find the first available slave for transmission.
4950 static struct slave *bond_get_slave_by_id(struct bonding *bond, in bond_get_slave_by_id()
4954 struct slave *slave; in bond_get_slave_by_id() local
4957 /* Here we start from the slave with slave_id */ in bond_get_slave_by_id()
4958 bond_for_each_slave_rcu(bond, slave, iter) { in bond_get_slave_by_id()
4960 if (bond_slave_can_tx(slave)) in bond_get_slave_by_id()
4961 return slave; in bond_get_slave_by_id()
4965 /* Here we start from the first slave up to slave_id */ in bond_get_slave_by_id()
4967 bond_for_each_slave_rcu(bond, slave, iter) { in bond_get_slave_by_id()
4970 if (bond_slave_can_tx(slave)) in bond_get_slave_by_id()
4971 return slave; in bond_get_slave_by_id()
4973 /* no slave that can tx has been found */ in bond_get_slave_by_id()
4978 * bond_rr_gen_slave_id - generate slave id based on packets_per_slave
4982 * this function generates a slave id, which is usually used as the next
4983 * slave to transmit through.
5010 static struct slave *bond_xmit_roundrobin_slave_get(struct bonding *bond, in bond_xmit_roundrobin_slave_get()
5013 struct slave *slave; in bond_xmit_roundrobin_slave_get() local
5032 slave = rcu_dereference(bond->curr_active_slave); in bond_xmit_roundrobin_slave_get()
5033 if (slave) in bond_xmit_roundrobin_slave_get()
5034 return slave; in bond_xmit_roundrobin_slave_get()
5048 static struct slave *bond_xdp_xmit_roundrobin_slave_get(struct bonding *bond, in bond_xdp_xmit_roundrobin_slave_get()
5051 struct slave *slave; in bond_xdp_xmit_roundrobin_slave_get() local
5073 slave = rcu_dereference(bond->curr_active_slave); in bond_xdp_xmit_roundrobin_slave_get()
5074 if (slave) in bond_xdp_xmit_roundrobin_slave_get()
5075 return slave; in bond_xdp_xmit_roundrobin_slave_get()
5093 struct slave *slave; in bond_xmit_roundrobin() local
5095 slave = bond_xmit_roundrobin_slave_get(bond, skb); in bond_xmit_roundrobin()
5096 if (likely(slave)) in bond_xmit_roundrobin()
5097 return bond_dev_queue_xmit(bond, skb, slave->dev); in bond_xmit_roundrobin()
5102 static struct slave *bond_xmit_activebackup_slave_get(struct bonding *bond) in bond_xmit_activebackup_slave_get()
5114 struct slave *slave; in bond_xmit_activebackup() local
5116 slave = bond_xmit_activebackup_slave_get(bond); in bond_xmit_activebackup()
5117 if (slave) in bond_xmit_activebackup()
5118 return bond_dev_queue_xmit(bond, skb, slave->dev); in bond_xmit_activebackup()
5132 /* Slave array work handler. Holds only RTNL */
5145 pr_warn_ratelimited("Failed to update slave array from WT\n"); in bond_slave_arr_handler()
5155 struct slave *skipslave) in bond_skip_slave()
5160 * slave but allocation failed (most likely!). BTW this is in bond_skip_slave()
5165 * this to-be-skipped slave to send a packet out. in bond_skip_slave()
5198 * to determine the slave interface -
5205 int bond_update_slave_arr(struct bonding *bond, struct slave *skipslave) in bond_update_slave_arr()
5208 struct slave *slave; in bond_update_slave_arr() local
5239 bond_for_each_slave(bond, slave, iter) { in bond_update_slave_arr()
5240 if (skipslave == slave) in bond_update_slave_arr()
5243 all_slaves->arr[all_slaves->count++] = slave; in bond_update_slave_arr()
5247 agg = SLAVE_AD_INFO(slave)->port.aggregator; in bond_update_slave_arr()
5251 if (!bond_slave_can_tx(slave)) in bond_update_slave_arr()
5254 slave_dbg(bond->dev, slave->dev, "Adding slave to tx hash array[%d]\n", in bond_update_slave_arr()
5257 usable_slaves->arr[usable_slaves->count++] = slave; in bond_update_slave_arr()
5275 static struct slave *bond_xmit_3ad_xor_slave_get(struct bonding *bond, in bond_xmit_3ad_xor_slave_get()
5279 struct slave *slave; in bond_xmit_3ad_xor_slave_get() local
5288 slave = slaves->arr[hash % count]; in bond_xmit_3ad_xor_slave_get()
5289 return slave; in bond_xmit_3ad_xor_slave_get()
5292 static struct slave *bond_xdp_xmit_3ad_xor_slave_get(struct bonding *bond, in bond_xdp_xmit_3ad_xor_slave_get()
5309 * usable slave array is formed in the control path. The xmit function
5317 struct slave *slave; in bond_3ad_xor_xmit() local
5320 slave = bond_xmit_3ad_xor_slave_get(bond, skb, slaves); in bond_3ad_xor_xmit()
5321 if (likely(slave)) in bond_3ad_xor_xmit()
5322 return bond_dev_queue_xmit(bond, skb, slave->dev); in bond_3ad_xor_xmit()
5332 struct slave *slave = NULL; in bond_xmit_broadcast() local
5337 bond_for_each_slave_rcu(bond, slave, iter) { in bond_xmit_broadcast()
5340 if (!(bond_slave_is_up(slave) && slave->link == BOND_LINK_UP)) in bond_xmit_broadcast()
5343 if (bond_is_last_slave(bond, slave)) { in bond_xmit_broadcast()
5355 if (bond_dev_queue_xmit(bond, skb2, slave->dev) == NETDEV_TX_OK) in bond_xmit_broadcast()
5371 /* Lookup the slave that corresponds to a qid */
5375 struct slave *slave = NULL; in bond_slave_override() local
5382 bond_for_each_slave_rcu(bond, slave, iter) { in bond_slave_override()
5383 if (READ_ONCE(slave->queue_id) == skb_get_queue_mapping(skb)) { in bond_slave_override()
5384 if (bond_slave_is_up(slave) && in bond_slave_override()
5385 slave->link == BOND_LINK_UP) { in bond_slave_override()
5386 bond_dev_queue_xmit(bond, skb, slave->dev); in bond_slave_override()
5389 /* If the slave isn't UP, use default transmit policy. */ in bond_slave_override()
5425 struct slave *slave = NULL; in bond_xmit_get_slave() local
5429 slave = bond_xmit_roundrobin_slave_get(bond, skb); in bond_xmit_get_slave()
5432 slave = bond_xmit_activebackup_slave_get(bond); in bond_xmit_get_slave()
5440 slave = bond_xmit_3ad_xor_slave_get(bond, skb, slaves); in bond_xmit_get_slave()
5445 slave = bond_xmit_alb_slave_get(bond, skb); in bond_xmit_get_slave()
5448 slave = bond_xmit_tlb_slave_get(bond, skb); in bond_xmit_get_slave()
5456 if (slave) in bond_xmit_get_slave()
5457 return slave->dev; in bond_xmit_get_slave()
5511 struct slave *slave; in __bond_sk_get_lower_dev() local
5521 slave = slaves->arr[hash % count]; in __bond_sk_get_lower_dev()
5523 return slave->dev; in __bond_sk_get_lower_dev()
5616 struct slave *slave; in bond_xdp_get_xmit_slave() local
5622 slave = bond_xdp_xmit_roundrobin_slave_get(bond, xdp); in bond_xdp_get_xmit_slave()
5626 slave = bond_xmit_activebackup_slave_get(bond); in bond_xdp_get_xmit_slave()
5631 slave = bond_xdp_xmit_3ad_xor_slave_get(bond, xdp); in bond_xdp_get_xmit_slave()
5641 if (slave) in bond_xdp_get_xmit_slave()
5642 return slave->dev; in bond_xdp_get_xmit_slave()
5689 struct slave *slave, *rollback_slave; in bond_xdp_set() local
5710 bond_for_each_slave(bond, slave, iter) { in bond_xdp_set()
5711 struct net_device *slave_dev = slave->dev; in bond_xdp_set()
5716 "Slave device does not support XDP"); in bond_xdp_set()
5723 "Slave has XDP program loaded, please unload before enslaving"); in bond_xdp_set()
5757 if (slave == rollback_slave) in bond_xdp_set()
5780 static u32 bond_mode_bcast_speed(struct slave *slave, u32 speed) in bond_mode_bcast_speed() argument
5783 speed = slave->speed; in bond_mode_bcast_speed()
5785 speed = min(speed, slave->speed); in bond_mode_bcast_speed()
5856 struct slave *slave; in bond_ethtool_get_link_ksettings() local
5867 bond_for_each_slave(bond, slave, iter) { in bond_ethtool_get_link_ksettings()
5868 if (bond_slave_can_tx(slave)) { in bond_ethtool_get_link_ksettings()
5869 bond_update_speed_duplex(slave); in bond_ethtool_get_link_ksettings()
5870 if (slave->speed != SPEED_UNKNOWN) { in bond_ethtool_get_link_ksettings()
5872 speed = bond_mode_bcast_speed(slave, in bond_ethtool_get_link_ksettings()
5875 speed += slave->speed; in bond_ethtool_get_link_ksettings()
5878 slave->duplex != DUPLEX_UNKNOWN) in bond_ethtool_get_link_ksettings()
5879 cmd->base.duplex = slave->duplex; in bond_ethtool_get_link_ksettings()
5903 struct slave *slave; in bond_ethtool_get_ts_info() local
5916 bond_for_each_slave_rcu(bond, slave, iter) { in bond_ethtool_get_ts_info()
5917 ret = ethtool_get_ts_info_by_layer(slave->dev, &ts_info); in bond_ethtool_get_ts_info()
6064 struct slave *slave; in bond_uninit() local
6069 bond_for_each_slave(bond, slave, iter) in bond_uninit()
6070 __bond_release_one(bond_dev, slave->dev, true, true); in bond_uninit()