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.");
298 * @slave_dev: slave that is supposed to xmit this skbuff
350 * We don't protect the slave list iteration with a lock because:
375 struct slave *slave, *rollback_slave; in bond_vlan_rx_add_vid() local
379 bond_for_each_slave(bond, slave, iter) { in bond_vlan_rx_add_vid()
380 res = vlan_vid_add(slave->dev, proto, vid); in bond_vlan_rx_add_vid()
388 /* unwind to the slave that failed */ in bond_vlan_rx_add_vid()
390 if (rollback_slave == slave) in bond_vlan_rx_add_vid()
410 struct slave *slave; in bond_vlan_rx_kill_vid() local
412 bond_for_each_slave(bond, slave, iter) in bond_vlan_rx_kill_vid()
413 vlan_vid_del(slave->dev, proto, vid); in bond_vlan_rx_kill_vid()
436 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()
470 struct slave *slave; in bond_ipsec_add_sa() local
478 slave = rcu_dereference(bond->curr_active_slave); in bond_ipsec_add_sa()
479 real_dev = slave ? slave->dev : NULL; in bond_ipsec_add_sa()
490 NL_SET_ERR_MSG_MOD(extack, "Slave does not support ipsec offload"); in bond_ipsec_add_sa()
522 struct slave *slave; in bond_ipsec_add_sa_all() local
524 slave = rtnl_dereference(bond->curr_active_slave); in bond_ipsec_add_sa_all()
525 real_dev = slave ? slave->dev : NULL; in bond_ipsec_add_sa_all()
535 "%s: no slave xdo_dev_state_add\n", in bond_ipsec_add_sa_all()
587 slave_warn(bond_dev, real_dev, "%s: no slave xdo_dev_state_delete\n", __func__); in bond_ipsec_del_sa()
599 struct slave *slave; in bond_ipsec_del_sa_all() local
601 slave = rtnl_dereference(bond->curr_active_slave); in bond_ipsec_del_sa_all()
602 real_dev = slave ? slave->dev : NULL; in bond_ipsec_del_sa_all()
615 "%s: no slave xdo_dev_state_delete\n", in bond_ipsec_del_sa_all()
757 struct slave *slave; in bond_set_carrier() local
765 bond_for_each_slave(bond, slave, iter) { in bond_set_carrier()
766 if (slave->link == BOND_LINK_UP) { in bond_set_carrier()
783 /* Get link speed and duplex from the slave's base driver
789 static int bond_update_speed_duplex(struct slave *slave) in bond_update_speed_duplex() argument
791 struct net_device *slave_dev = slave->dev; in bond_update_speed_duplex()
795 slave->speed = SPEED_UNKNOWN; in bond_update_speed_duplex()
796 slave->duplex = DUPLEX_UNKNOWN; in bond_update_speed_duplex()
811 slave->speed = ecmd.base.speed; in bond_update_speed_duplex()
812 slave->duplex = ecmd.base.duplex; in bond_update_speed_duplex()
913 struct slave *curr_active = rtnl_dereference(bond->curr_active_slave); in bond_set_promiscuity()
918 struct slave *slave; in bond_set_promiscuity() local
920 bond_for_each_slave(bond, slave, iter) { in bond_set_promiscuity()
921 err = dev_set_promiscuity(slave->dev, inc); in bond_set_promiscuity()
936 struct slave *curr_active = rtnl_dereference(bond->curr_active_slave); in bond_set_allmulti()
941 struct slave *slave; in bond_set_allmulti() local
943 bond_for_each_slave(bond, slave, iter) { in bond_set_allmulti()
944 err = dev_set_allmulti(slave->dev, inc); in bond_set_allmulti()
954 * slave.
974 /* Flush bond's hardware addresses from slave */
987 /*--------------------------- Active slave change ---------------------------*/
994 static void bond_hw_addr_swap(struct bonding *bond, struct slave *new_active, in bond_hw_addr_swap()
995 struct slave *old_active) in bond_hw_addr_swap()
1030 * bond_set_dev_addr - clone slave's address to bond
1032 * @slave_dev: slave net device
1053 static struct slave *bond_get_old_active(struct bonding *bond, in bond_get_old_active()
1054 struct slave *new_active) in bond_get_old_active()
1056 struct slave *slave; in bond_get_old_active() local
1059 bond_for_each_slave(bond, slave, iter) { in bond_get_old_active()
1060 if (slave == new_active) in bond_get_old_active()
1063 if (ether_addr_equal(bond->dev->dev_addr, slave->dev->dev_addr)) in bond_get_old_active()
1064 return slave; in bond_get_old_active()
1077 struct slave *new_active, in bond_do_fail_over_mac()
1078 struct slave *old_active) in bond_do_fail_over_mac()
1089 slave_err(bond->dev, new_active->dev, "Error %d setting bond MAC from slave\n", in bond_do_fail_over_mac()
1095 * if just old_active, do nothing (going to no active slave) in bond_do_fail_over_mac()
1119 slave_err(bond->dev, new_active->dev, "Error %d setting MAC of new active slave\n", in bond_do_fail_over_mac()
1133 slave_err(bond->dev, old_active->dev, "Error %d setting MAC of old active slave\n", in bond_do_fail_over_mac()
1146 * bond_choose_primary_or_current - select the primary or high priority slave
1153 * If the highest priority link is not current slave, set it as primary
1156 static struct slave *bond_choose_primary_or_current(struct bonding *bond) in bond_choose_primary_or_current()
1158 struct slave *prim = rtnl_dereference(bond->primary_slave); in bond_choose_primary_or_current()
1159 struct slave *curr = rtnl_dereference(bond->curr_active_slave); in bond_choose_primary_or_current()
1160 struct slave *slave, *hprio = NULL; in bond_choose_primary_or_current() local
1164 bond_for_each_slave(bond, slave, iter) { in bond_choose_primary_or_current()
1165 if (slave->link == BOND_LINK_UP) { in bond_choose_primary_or_current()
1166 hprio = hprio ?: slave; in bond_choose_primary_or_current()
1167 if (slave->prio > hprio->prio) in bond_choose_primary_or_current()
1168 hprio = slave; in bond_choose_primary_or_current()
1211 * bond_find_best_slave - select the best available slave to be the active one
1214 static struct slave *bond_find_best_slave(struct bonding *bond) in bond_find_best_slave()
1216 struct slave *slave, *bestslave = NULL; in bond_find_best_slave() local
1220 slave = bond_choose_primary_or_current(bond); in bond_find_best_slave()
1221 if (slave) in bond_find_best_slave()
1222 return slave; in bond_find_best_slave()
1224 bond_for_each_slave(bond, slave, iter) { in bond_find_best_slave()
1225 if (slave->link == BOND_LINK_UP) in bond_find_best_slave()
1226 return slave; in bond_find_best_slave()
1227 if (slave->link == BOND_LINK_BACK && bond_slave_is_up(slave) && in bond_find_best_slave()
1228 slave->delay < mintime) { in bond_find_best_slave()
1229 mintime = slave->delay; in bond_find_best_slave()
1230 bestslave = slave; in bond_find_best_slave()
1241 struct slave *slave = NULL; in bond_should_notify_peers() local
1258 slave = rcu_dereference_rtnl(bond->curr_active_slave); in bond_should_notify_peers()
1259 if (!slave || test_bit(__LINK_STATE_LINKWATCH_PENDING, in bond_should_notify_peers()
1260 &slave->dev->state)) in bond_should_notify_peers()
1264 netdev_dbg(bond->dev, "bond_should_notify_peers: slave %s\n", in bond_should_notify_peers()
1265 slave ? slave->dev->name : "all"); in bond_should_notify_peers()
1271 * bond_change_active_slave - change the active slave into the specified one
1273 * @new_active: the new slave to make the active one
1275 * Set the new slave to the bond's settings and unset them on the old
1280 * because it is apparently the best available slave we have, even though its
1285 void bond_change_active_slave(struct bonding *bond, struct slave *new_active) in bond_change_active_slave()
1287 struct slave *old_active; in bond_change_active_slave()
1375 /* resend IGMP joins since active slave has changed or in bond_change_active_slave()
1389 * bond_select_active_slave - select a new active slave, if needed
1395 * - A slave has got its link back and there's no old curr_active_slave.
1401 struct slave *best_slave; in bond_select_active_slave()
1421 static inline int slave_enable_netpoll(struct slave *slave) in slave_enable_netpoll() argument
1431 err = __netpoll_setup(np, slave->dev); in slave_enable_netpoll()
1436 slave->np = np; in slave_enable_netpoll()
1440 static inline void slave_disable_netpoll(struct slave *slave) in slave_disable_netpoll() argument
1442 struct netpoll *np = slave->np; in slave_disable_netpoll()
1447 slave->np = NULL; in slave_disable_netpoll()
1455 struct slave *slave = NULL; in bond_poll_controller() local
1463 bond_for_each_slave_rcu(bond, slave, iter) { in bond_poll_controller()
1464 if (!bond_slave_is_up(slave)) in bond_poll_controller()
1469 SLAVE_AD_INFO(slave)->port.aggregator; in bond_poll_controller()
1476 netpoll_poll_dev(slave->dev); in bond_poll_controller()
1484 struct slave *slave; in bond_netpoll_cleanup() local
1486 bond_for_each_slave(bond, slave, iter) in bond_netpoll_cleanup()
1487 if (bond_slave_is_up(slave)) in bond_netpoll_cleanup()
1488 slave_disable_netpoll(slave); in bond_netpoll_cleanup()
1495 struct slave *slave; in bond_netpoll_setup() local
1498 bond_for_each_slave(bond, slave, iter) { in bond_netpoll_setup()
1499 err = slave_enable_netpoll(slave); in bond_netpoll_setup()
1508 static inline int slave_enable_netpoll(struct slave *slave) in slave_enable_netpoll() argument
1512 static inline void slave_disable_netpoll(struct slave *slave) in slave_disable_netpoll() argument
1528 struct slave *slave; in bond_fix_features() local
1533 bond_for_each_slave(bond, slave, iter) { in bond_fix_features()
1535 slave->dev->features, in bond_fix_features()
1571 struct slave *slave; in bond_compute_features() local
1582 bond_for_each_slave(bond, slave, iter) { in bond_compute_features()
1584 slave->dev->vlan_features, BOND_VLAN_FEATURES); in bond_compute_features()
1587 slave->dev->hw_enc_features, in bond_compute_features()
1592 slave->dev->hw_enc_features, in bond_compute_features()
1597 slave->dev->gso_partial_features, in bond_compute_features()
1601 slave->dev->mpls_features, in bond_compute_features()
1604 dst_release_flag &= slave->dev->priv_flags; in bond_compute_features()
1605 if (slave->dev->hard_header_len > max_hard_header_len) in bond_compute_features()
1606 max_hard_header_len = slave->dev->hard_header_len; in bond_compute_features()
1608 tso_max_size = min(tso_max_size, slave->dev->tso_max_size); in bond_compute_features()
1609 tso_max_segs = min(tso_max_segs, slave->dev->tso_max_segs); in bond_compute_features()
1659 /* On bonding slaves other than the currently active slave, suppress
1663 struct slave *slave, in bond_should_deliver_exact_match() argument
1666 if (bond_is_slave_inactive(slave)) { in bond_should_deliver_exact_match()
1679 struct slave *slave; in bond_handle_frame() local
1682 struct slave *); in bond_handle_frame()
1691 slave = bond_slave_get_rcu(skb->dev); in bond_handle_frame()
1692 bond = slave->bond; in bond_handle_frame()
1696 ret = recv_probe(skb, bond, slave); in bond_handle_frame()
1707 * inactive slave links without being forced to bind to them in bond_handle_frame()
1714 if (bond_should_deliver_exact_match(skb, slave, bond)) { in bond_handle_frame()
1779 static int bond_master_upper_dev_link(struct bonding *bond, struct slave *slave, in bond_master_upper_dev_link() argument
1790 err = netdev_master_upper_dev_link(slave->dev, bond->dev, slave, in bond_master_upper_dev_link()
1795 slave->dev->flags |= IFF_SLAVE; in bond_master_upper_dev_link()
1799 static void bond_upper_dev_unlink(struct bonding *bond, struct slave *slave) in bond_upper_dev_unlink() argument
1801 netdev_upper_dev_unlink(slave->dev, bond->dev); in bond_upper_dev_unlink()
1802 slave->dev->flags &= ~IFF_SLAVE; in bond_upper_dev_unlink()
1807 struct slave *slave = to_slave(kobj); in slave_kobj_release() local
1808 struct bonding *bond = bond_get_bond_by_slave(slave); in slave_kobj_release()
1810 cancel_delayed_work_sync(&slave->notify_work); in slave_kobj_release()
1812 kfree(SLAVE_AD_INFO(slave)); in slave_kobj_release()
1814 kfree(slave); in slave_kobj_release()
1824 static int bond_kobj_init(struct slave *slave) in bond_kobj_init() argument
1828 err = kobject_init_and_add(&slave->kobj, &slave_ktype, in bond_kobj_init()
1829 &(slave->dev->dev.kobj), "bonding_slave"); in bond_kobj_init()
1831 kobject_put(&slave->kobj); in bond_kobj_init()
1836 static struct slave *bond_alloc_slave(struct bonding *bond, in bond_alloc_slave()
1839 struct slave *slave = NULL; in bond_alloc_slave() local
1841 slave = kzalloc(sizeof(*slave), GFP_KERNEL); in bond_alloc_slave()
1842 if (!slave) in bond_alloc_slave()
1845 slave->bond = bond; in bond_alloc_slave()
1846 slave->dev = slave_dev; in bond_alloc_slave()
1847 INIT_DELAYED_WORK(&slave->notify_work, bond_netdev_notify_work); in bond_alloc_slave()
1849 if (bond_kobj_init(slave)) in bond_alloc_slave()
1853 SLAVE_AD_INFO(slave) = kzalloc(sizeof(struct ad_slave_info), in bond_alloc_slave()
1855 if (!SLAVE_AD_INFO(slave)) { in bond_alloc_slave()
1856 kobject_put(&slave->kobj); in bond_alloc_slave()
1861 return slave; in bond_alloc_slave()
1871 static void bond_fill_ifslave(struct slave *slave, struct ifslave *info) in bond_fill_ifslave() argument
1873 strcpy(info->slave_name, slave->dev->name); in bond_fill_ifslave()
1874 info->link = slave->link; in bond_fill_ifslave()
1875 info->state = bond_slave_state(slave); in bond_fill_ifslave()
1876 info->link_failure_count = slave->link_failure_count; in bond_fill_ifslave()
1881 struct slave *slave = container_of(_work, struct slave, in bond_netdev_notify_work() local
1887 bond_fill_ifslave(slave, &binfo.slave); in bond_netdev_notify_work()
1888 bond_fill_ifbond(slave->bond, &binfo.master); in bond_netdev_notify_work()
1889 netdev_bonding_info_change(slave->dev, &binfo); in bond_netdev_notify_work()
1892 queue_delayed_work(slave->bond->wq, &slave->notify_work, 1); in bond_netdev_notify_work()
1896 void bond_queue_slave_event(struct slave *slave) in bond_queue_slave_event() argument
1898 queue_delayed_work(slave->bond->wq, &slave->notify_work, 0); in bond_queue_slave_event()
1901 void bond_lower_state_changed(struct slave *slave) in bond_lower_state_changed() argument
1905 info.link_up = slave->link == BOND_LINK_UP || in bond_lower_state_changed()
1906 slave->link == BOND_LINK_FAIL; in bond_lower_state_changed()
1907 info.tx_enabled = bond_is_active_slave(slave); in bond_lower_state_changed()
1908 netdev_lower_state_changed(slave->dev, &info); in bond_lower_state_changed()
1944 struct slave *slave; in bond_xdp_set_features() local
1953 bond_for_each_slave(bond, slave, iter) in bond_xdp_set_features()
1954 val &= slave->dev->xdp_features; in bond_xdp_set_features()
1961 /* enslave device <slave> to bond device <master> */
1967 struct slave *new_slave = NULL, *prev_slave; in bond_enslave()
2006 …slave_warn(bond_dev, slave_dev, "enslaved VLAN challenged slave. Adding VLANs will be blocked as l… in bond_enslave()
2016 * be identified with moderate accuracy by the state of the slave: in bond_enslave()
2026 /* set bonding device ether type by slave - bonding netdevices are in bond_enslave()
2027 * created with ether_setup, so when the slave type is not ARPHRD_ETHER in bond_enslave()
2074 …slave_warn(bond_dev, slave_dev, "The slave device specified does not support setting the MAC addre… in bond_enslave()
2082 … "Slave device does not support setting the MAC address, but fail_over_mac is not set to active"); in bond_enslave()
2091 /* If this is the first slave, then we need to set the master's hardware in bond_enslave()
2092 * address to be the same as the slave's. in bond_enslave()
2112 /* Save slave's original mtu and then set it to match the bond */ in bond_enslave()
2120 /* Save slave's original ("permanent") mac address for modes in bond_enslave()
2129 /* Set slave to master's mac address. The application already in bond_enslave()
2130 * set the master's mac address to that of the first slave in bond_enslave()
2137 /* Set slave to random address to avoid duplicate mac in bond_enslave()
2157 /* open the slave since the application closed it */ in bond_enslave()
2160 slave_err(bond_dev, slave_dev, "Opening slave failed\n"); in bond_enslave()
2165 /* initialize slave stats */ in bond_enslave()
2211 …slave_warn(bond_dev, slave_dev, "MII and ETHTOOL support not available for slave, and arp_interval… in bond_enslave()
2214 …slave_warn(bond_dev, slave_dev, "can't get link status from slave; the network driver associated w… in bond_enslave()
2248 slave_dbg(bond_dev, slave_dev, "Initial state of slave is BOND_LINK_%s\n", in bond_enslave()
2253 /* if there is a primary slave, remember it */ in bond_enslave()
2271 /* if this is the first slave */ in bond_enslave()
2291 slave_dbg(bond_dev, slave_dev, "This slave is always active in trunk mode\n"); in bond_enslave()
2310 …slave_info(bond_dev, slave_dev, "master_dev is using netpoll, but new slave device does not suppor… in bond_enslave()
2345 /* set promiscuity level to new slave */ in bond_enslave()
2352 /* set allmulti level to new slave */ in bond_enslave()
2378 * remove the maddrs if the slave is selected as active slave. in bond_enslave()
2395 "Slave does not support XDP"); in bond_enslave()
2409 "Slave has XDP program loaded, please unload before enslaving"); in bond_enslave()
2468 * MAC if this slave's MAC is in use by the bond, or at in bond_enslave()
2484 /* Enslave of first slave has failed and we need to fix master's mac */ in bond_enslave()
2498 /* Try to release the slave device <slave> from the bond device <master>
2503 * The rules for slave state should be:
2514 struct slave *slave, *oldcurrent; in __bond_release_one() local
2519 /* slave is not a slave or master is not master of this slave */ in __bond_release_one()
2522 slave_dbg(bond_dev, slave_dev, "cannot release slave\n"); in __bond_release_one()
2528 slave = bond_get_slave_by_dev(bond, slave_dev); in __bond_release_one()
2529 if (!slave) { in __bond_release_one()
2530 /* not a slave of this bond */ in __bond_release_one()
2536 bond_set_slave_inactive_flags(slave, BOND_SLAVE_NOTIFY_NOW); in __bond_release_one()
2538 bond_sysfs_slave_del(slave); in __bond_release_one()
2540 /* recompute stats just before removing the slave */ in __bond_release_one()
2555 * for this slave anymore. in __bond_release_one()
2560 bond_3ad_unbind_slave(slave); in __bond_release_one()
2562 bond_upper_dev_unlink(bond, slave); in __bond_release_one()
2565 bond_update_slave_arr(bond, slave); in __bond_release_one()
2568 bond_is_active_slave(slave) ? "active" : "backup"); in __bond_release_one()
2576 if (ether_addr_equal_64bits(bond_dev->dev_addr, slave->perm_hwaddr) && in __bond_release_one()
2578 …ond_dev, slave_dev, "the permanent HWaddr of slave - %pM - is still in use by bond - set the HWadd… in __bond_release_one()
2579 slave->perm_hwaddr); in __bond_release_one()
2582 if (rtnl_dereference(bond->primary_slave) == slave) in __bond_release_one()
2585 if (oldcurrent == slave) in __bond_release_one()
2588 /* Must be called after bond_change_active_slave () as the slave in __bond_release_one()
2589 * might change from an active slave to a backup slave. Then it is in __bond_release_one()
2590 * necessary to clear the maddrs on the backup slave. in __bond_release_one()
2592 bond_slave_ns_maddrs_del(bond, slave); in __bond_release_one()
2595 /* Must be called only after the slave has been in __bond_release_one()
2598 * but before a new active slave is selected. in __bond_release_one()
2600 bond_alb_deinit_slave(bond, slave); in __bond_release_one()
2605 } else if (oldcurrent == slave) { in __bond_release_one()
2607 * is no concern that another slave add/remove event in __bond_release_one()
2629 …slave_info(bond_dev, slave_dev, "last VLAN challenged slave left bond - VLAN blocking is removed\n… in __bond_release_one()
2637 /* unset promiscuity level from slave in __bond_release_one()
2641 * when this slave was attached, so we cache at the start of the in __bond_release_one()
2647 /* unset allmulti level from slave */ in __bond_release_one()
2655 slave_disable_netpoll(slave); in __bond_release_one()
2657 /* close slave before restoring its mac address */ in __bond_release_one()
2665 bond_hw_addr_copy(ss.__data, slave->perm_hwaddr, in __bond_release_one()
2666 slave->dev->addr_len); in __bond_release_one()
2673 __netif_set_mtu(slave_dev, slave->original_mtu); in __bond_release_one()
2676 dev_set_mtu(slave_dev, slave->original_mtu); in __bond_release_one()
2683 kobject_put(&slave->kobj); in __bond_release_one()
2694 /* First release a slave and then destroy the bond if no more slaves are left.
2726 struct slave *slave; in bond_slave_info_query() local
2728 bond_for_each_slave(bond, slave, iter) { in bond_slave_info_query()
2731 bond_fill_ifslave(slave, info); in bond_slave_info_query()
2747 struct slave *slave; in bond_miimon_inspect() local
2760 bond_for_each_slave_rcu(bond, slave, iter) { in bond_miimon_inspect()
2761 bond_propose_link_state(slave, BOND_LINK_NOCHANGE); in bond_miimon_inspect()
2763 link_state = bond_check_dev_link(bond, slave->dev, 0); in bond_miimon_inspect()
2765 switch (slave->link) { in bond_miimon_inspect()
2770 bond_propose_link_state(slave, BOND_LINK_FAIL); in bond_miimon_inspect()
2772 slave->delay = bond->params.downdelay; in bond_miimon_inspect()
2773 if (slave->delay && net_ratelimit()) { in bond_miimon_inspect()
2774 slave_info(bond->dev, slave->dev, "link status down for %sinterface, disabling it in %d ms\n", in bond_miimon_inspect()
2777 (bond_is_active_slave(slave) ? in bond_miimon_inspect()
2785 bond_propose_link_state(slave, BOND_LINK_UP); in bond_miimon_inspect()
2786 slave->last_link_up = jiffies; in bond_miimon_inspect()
2788 slave_info(bond->dev, slave->dev, "link status up again after %d ms\n", in bond_miimon_inspect()
2789 (bond->params.downdelay - slave->delay) * in bond_miimon_inspect()
2795 if (slave->delay <= 0) { in bond_miimon_inspect()
2796 bond_propose_link_state(slave, BOND_LINK_DOWN); in bond_miimon_inspect()
2801 slave->delay--; in bond_miimon_inspect()
2808 bond_propose_link_state(slave, BOND_LINK_BACK); in bond_miimon_inspect()
2810 slave->delay = bond->params.updelay; in bond_miimon_inspect()
2812 if (slave->delay && net_ratelimit()) { in bond_miimon_inspect()
2813 slave_info(bond->dev, slave->dev, "link status up, enabling it in %d ms\n", in bond_miimon_inspect()
2821 bond_propose_link_state(slave, BOND_LINK_DOWN); in bond_miimon_inspect()
2823 slave_info(bond->dev, slave->dev, "link status down again after %d ms\n", in bond_miimon_inspect()
2824 (bond->params.updelay - slave->delay) * in bond_miimon_inspect()
2831 slave->delay = 0; in bond_miimon_inspect()
2833 if (slave->delay <= 0) { in bond_miimon_inspect()
2834 bond_propose_link_state(slave, BOND_LINK_UP); in bond_miimon_inspect()
2840 slave->delay--; in bond_miimon_inspect()
2849 struct slave *slave, in bond_miimon_link_change() argument
2854 bond_3ad_handle_link_change(slave, link); in bond_miimon_link_change()
2858 bond_alb_handle_link_change(bond, slave, link); in bond_miimon_link_change()
2868 struct slave *slave, *primary, *active; in bond_miimon_commit() local
2874 bond_for_each_slave(bond, slave, iter) { in bond_miimon_commit()
2875 switch (slave->link_new_state) { in bond_miimon_commit()
2877 /* For 802.3ad mode, check current slave speed and in bond_miimon_commit()
2884 slave->link == BOND_LINK_UP) in bond_miimon_commit()
2885 bond_3ad_adapter_speed_duplex_changed(slave); in bond_miimon_commit()
2889 if (bond_update_speed_duplex(slave) && in bond_miimon_commit()
2891 slave->link = BOND_LINK_DOWN; in bond_miimon_commit()
2893 slave_warn(bond->dev, slave->dev, in bond_miimon_commit()
2897 bond_set_slave_link_state(slave, BOND_LINK_UP, in bond_miimon_commit()
2899 slave->last_link_up = jiffies; in bond_miimon_commit()
2904 bond_set_backup_slave(slave); in bond_miimon_commit()
2907 bond_set_active_slave(slave); in bond_miimon_commit()
2910 slave_info(bond->dev, slave->dev, "link status definitely up, %u Mbps %s duplex\n", in bond_miimon_commit()
2911 slave->speed == SPEED_UNKNOWN ? 0 : slave->speed, in bond_miimon_commit()
2912 slave->duplex ? "full" : "half"); in bond_miimon_commit()
2914 bond_miimon_link_change(bond, slave, BOND_LINK_UP); in bond_miimon_commit()
2917 if (!active || slave == primary || slave->prio > active->prio) in bond_miimon_commit()
2923 if (slave->link_failure_count < UINT_MAX) in bond_miimon_commit()
2924 slave->link_failure_count++; in bond_miimon_commit()
2926 bond_set_slave_link_state(slave, BOND_LINK_DOWN, in bond_miimon_commit()
2931 bond_set_slave_inactive_flags(slave, in bond_miimon_commit()
2934 slave_info(bond->dev, slave->dev, "link status definitely down, disabling slave\n"); in bond_miimon_commit()
2936 bond_miimon_link_change(bond, slave, BOND_LINK_DOWN); in bond_miimon_commit()
2938 if (slave == rcu_access_pointer(bond->curr_active_slave)) in bond_miimon_commit()
2944 slave_err(bond->dev, slave->dev, "invalid new link %d on slave\n", in bond_miimon_commit()
2945 slave->link_new_state); in bond_miimon_commit()
2946 bond_propose_link_state(slave, BOND_LINK_NOCHANGE); in bond_miimon_commit()
2975 struct slave *slave; in bond_mii_monitor() local
3004 bond_for_each_slave(bond, slave, iter) { in bond_mii_monitor()
3005 bond_commit_link_state(slave, BOND_SLAVE_NOTIFY_LATER); in bond_mii_monitor()
3052 static bool bond_handle_vlan(struct slave *slave, struct bond_vlan_tag *tags, in bond_handle_vlan() argument
3055 struct net_device *bond_dev = slave->bond->dev; in bond_handle_vlan()
3056 struct net_device *slave_dev = slave->dev; in bond_handle_vlan()
3097 static void bond_arp_send(struct slave *slave, int arp_op, __be32 dest_ip, in bond_arp_send() argument
3100 struct net_device *bond_dev = slave->bond->dev; in bond_arp_send()
3101 struct net_device *slave_dev = slave->dev; in bond_arp_send()
3104 slave_dbg(bond_dev, slave_dev, "arp %d on slave: dst %pI4 src %pI4\n", in bond_arp_send()
3115 if (bond_handle_vlan(slave, tags, skb)) { in bond_arp_send()
3116 slave_update_last_tx(slave); in bond_arp_send()
3163 static void bond_arp_send_all(struct bonding *bond, struct slave *slave) in bond_arp_send_all() argument
3171 slave_dbg(bond->dev, slave->dev, "%s: target %pI4\n", in bond_arp_send_all()
3186 bond_arp_send(slave, ARPOP_REQUEST, targets[i], in bond_arp_send_all()
3203 slave_dbg(bond->dev, slave->dev, "no path to arp_ip_target %pI4 via rt.dev %s\n", in bond_arp_send_all()
3212 bond_arp_send(slave, ARPOP_REQUEST, targets[i], addr, tags); in bond_arp_send_all()
3217 static void bond_validate_arp(struct bonding *bond, struct slave *slave, __be32 sip, __be32 tip) in bond_validate_arp() argument
3222 slave_dbg(bond->dev, slave->dev, "%s: sip %pI4 tip %pI4 not found\n", in bond_validate_arp()
3229 slave_dbg(bond->dev, slave->dev, "%s: sip %pI4 not found in targets\n", in bond_validate_arp()
3233 slave->last_rx = jiffies; in bond_validate_arp()
3234 slave->target_last_arp_rx[i] = jiffies; in bond_validate_arp()
3238 struct slave *slave) in bond_arp_rcv() argument
3241 struct slave *curr_active_slave, *curr_arp_slave; in bond_arp_rcv()
3270 slave_dbg(bond->dev, slave->dev, "%s: %s/%d av %d sv %d sip %pI4 tip %pI4\n", in bond_arp_rcv()
3271 __func__, slave->dev->name, bond_slave_state(slave), in bond_arp_rcv()
3272 bond->params.arp_validate, slave_do_arp_validate(bond, slave), in bond_arp_rcv()
3280 * (a) the slave receiving the ARP is active (which includes the in bond_arp_rcv()
3281 * current ARP slave, if any), or in bond_arp_rcv()
3283 * (b) the receiving slave isn't active, but there is a currently in bond_arp_rcv()
3284 * active slave and it received valid arp reply(s) after it became in bond_arp_rcv()
3285 * the currently active slave, or in bond_arp_rcv()
3287 * (c) there is an ARP slave that sent an ARP during the prior ARP in bond_arp_rcv()
3288 * interval, and we receive an ARP reply on any slave. We accept in bond_arp_rcv()
3290 * reply to a slave other than the sender of the ARP request. in bond_arp_rcv()
3294 * slave through the L2 switch(es) to the receiving slave. Since in bond_arp_rcv()
3301 if (bond_is_active_slave(slave)) in bond_arp_rcv()
3302 bond_validate_arp(bond, slave, sip, tip); in bond_arp_rcv()
3306 bond_validate_arp(bond, slave, tip, sip); in bond_arp_rcv()
3309 bond_validate_arp(bond, slave, sip, tip); in bond_arp_rcv()
3318 static void bond_ns_send(struct slave *slave, const struct in6_addr *daddr, in bond_ns_send() argument
3321 struct net_device *bond_dev = slave->bond->dev; in bond_ns_send()
3322 struct net_device *slave_dev = slave->dev; in bond_ns_send()
3326 slave_dbg(bond_dev, slave_dev, "NS on slave: dst %pI6c src %pI6c\n", in bond_ns_send()
3336 if (bond_handle_vlan(slave, tags, skb)) { in bond_ns_send()
3337 slave_update_last_tx(slave); in bond_ns_send()
3342 static void bond_ns_send_all(struct bonding *bond, struct slave *slave) in bond_ns_send_all() argument
3352 slave_dbg(bond->dev, slave->dev, "%s: target %pI6c\n", in bond_ns_send_all()
3370 bond_ns_send(slave, &targets[i], &in6addr_any, tags); in bond_ns_send_all()
3386 slave_dbg(bond->dev, slave->dev, "no path to ns_ip6_target %pI6c via dst->dev %s\n", in bond_ns_send_all()
3394 bond_ns_send(slave, &targets[i], &saddr, tags); in bond_ns_send_all()
3396 bond_ns_send(slave, &targets[i], &in6addr_any, tags); in bond_ns_send_all()
3429 static void bond_validate_na(struct bonding *bond, struct slave *slave, in bond_validate_na() argument
3442 slave_dbg(bond->dev, slave->dev, "%s: sip %pI6c tip %pI6c not found\n", in bond_validate_na()
3449 slave_dbg(bond->dev, slave->dev, "%s: sip %pI6c not found in targets\n", in bond_validate_na()
3453 slave->last_rx = jiffies; in bond_validate_na()
3454 slave->target_last_arp_rx[i] = jiffies; in bond_validate_na()
3458 struct slave *slave) in bond_na_rcv() argument
3460 struct slave *curr_active_slave, *curr_arp_slave; in bond_na_rcv()
3480 slave_dbg(bond->dev, slave->dev, "%s: %s/%d av %d sv %d sip %pI6c tip %pI6c\n", in bond_na_rcv()
3481 __func__, slave->dev->name, bond_slave_state(slave), in bond_na_rcv()
3482 bond->params.arp_validate, slave_do_arp_validate(bond, slave), in bond_na_rcv()
3491 if (bond_is_active_slave(slave)) in bond_na_rcv()
3492 bond_validate_na(bond, slave, saddr, daddr); in bond_na_rcv()
3496 bond_validate_na(bond, slave, daddr, saddr); in bond_na_rcv()
3499 bond_validate_na(bond, slave, saddr, daddr); in bond_na_rcv()
3507 struct slave *slave) in bond_rcv_validate() argument
3514 slave_dbg(bond->dev, slave->dev, "%s: skb->dev %s\n", in bond_rcv_validate()
3518 if (!slave_do_arp_validate(bond, slave)) { in bond_rcv_validate()
3524 slave->last_rx = jiffies; in bond_rcv_validate()
3527 return bond_arp_rcv(skb, bond, slave); in bond_rcv_validate()
3530 return bond_na_rcv(skb, bond, slave); in bond_rcv_validate()
3537 static void bond_send_validate(struct bonding *bond, struct slave *slave) in bond_send_validate() argument
3539 bond_arp_send_all(bond, slave); in bond_send_validate()
3541 bond_ns_send_all(bond, slave); in bond_send_validate()
3559 /* This function is called regularly to monitor each slave's link
3567 struct slave *slave, *oldcurrent; in bond_loadbalance_arp_mon() local
3579 * the picture unless it is null. also, slave->last_link_up is not in bond_loadbalance_arp_mon()
3580 * needed here because we send an arp on each slave and give a slave in bond_loadbalance_arp_mon()
3585 bond_for_each_slave_rcu(bond, slave, iter) { in bond_loadbalance_arp_mon()
3586 unsigned long last_tx = slave_last_tx(slave); in bond_loadbalance_arp_mon()
3588 bond_propose_link_state(slave, BOND_LINK_NOCHANGE); in bond_loadbalance_arp_mon()
3590 if (slave->link != BOND_LINK_UP) { in bond_loadbalance_arp_mon()
3592 bond_time_in_interval(bond, slave->last_rx, 1)) { in bond_loadbalance_arp_mon()
3594 bond_propose_link_state(slave, BOND_LINK_UP); in bond_loadbalance_arp_mon()
3598 * mode. the window of a slave being up and in bond_loadbalance_arp_mon()
3603 slave_info(bond->dev, slave->dev, "link status definitely up\n"); in bond_loadbalance_arp_mon()
3606 slave_info(bond->dev, slave->dev, "interface is now up\n"); in bond_loadbalance_arp_mon()
3610 /* slave->link == BOND_LINK_UP */ in bond_loadbalance_arp_mon()
3617 !bond_time_in_interval(bond, slave->last_rx, bond->params.missed_max)) { in bond_loadbalance_arp_mon()
3619 bond_propose_link_state(slave, BOND_LINK_DOWN); in bond_loadbalance_arp_mon()
3622 if (slave->link_failure_count < UINT_MAX) in bond_loadbalance_arp_mon()
3623 slave->link_failure_count++; in bond_loadbalance_arp_mon()
3625 slave_info(bond->dev, slave->dev, "interface is now down\n"); in bond_loadbalance_arp_mon()
3627 if (slave == oldcurrent) in bond_loadbalance_arp_mon()
3639 if (bond_slave_is_up(slave)) in bond_loadbalance_arp_mon()
3640 bond_send_validate(bond, slave); in bond_loadbalance_arp_mon()
3649 bond_for_each_slave(bond, slave, iter) { in bond_loadbalance_arp_mon()
3650 if (slave->link_new_state != BOND_LINK_NOCHANGE) in bond_loadbalance_arp_mon()
3651 slave->link = slave->link_new_state; in bond_loadbalance_arp_mon()
3675 * should take place for the slave. Returns 0 if no changes are found, >0
3684 struct slave *slave; in bond_ab_arp_inspect() local
3687 bond_for_each_slave_rcu(bond, slave, iter) { in bond_ab_arp_inspect()
3688 bond_propose_link_state(slave, BOND_LINK_NOCHANGE); in bond_ab_arp_inspect()
3689 last_rx = slave_last_rx(bond, slave); in bond_ab_arp_inspect()
3691 if (slave->link != BOND_LINK_UP) { in bond_ab_arp_inspect()
3693 bond_propose_link_state(slave, BOND_LINK_UP); in bond_ab_arp_inspect()
3695 } else if (slave->link == BOND_LINK_BACK) { in bond_ab_arp_inspect()
3696 bond_propose_link_state(slave, BOND_LINK_FAIL); in bond_ab_arp_inspect()
3706 if (bond_time_in_interval(bond, slave->last_link_up, 2)) in bond_ab_arp_inspect()
3709 /* Backup slave is down if: in bond_ab_arp_inspect()
3718 * gives each slave a chance to tx/rx traffic in bond_ab_arp_inspect()
3721 if (!bond_is_active_slave(slave) && in bond_ab_arp_inspect()
3724 bond_propose_link_state(slave, BOND_LINK_DOWN); in bond_ab_arp_inspect()
3728 /* Active slave is down if: in bond_ab_arp_inspect()
3733 last_tx = slave_last_tx(slave); in bond_ab_arp_inspect()
3734 if (bond_is_active_slave(slave) && in bond_ab_arp_inspect()
3737 bond_propose_link_state(slave, BOND_LINK_DOWN); in bond_ab_arp_inspect()
3755 struct slave *slave; in bond_ab_arp_commit() local
3757 bond_for_each_slave(bond, slave, iter) { in bond_ab_arp_commit()
3758 switch (slave->link_new_state) { in bond_ab_arp_commit()
3763 last_tx = slave_last_tx(slave); in bond_ab_arp_commit()
3764 if (rtnl_dereference(bond->curr_active_slave) != slave || in bond_ab_arp_commit()
3767 struct slave *current_arp_slave; in bond_ab_arp_commit()
3770 bond_set_slave_link_state(slave, BOND_LINK_UP, in bond_ab_arp_commit()
3779 slave_info(bond->dev, slave->dev, "link status definitely up\n"); in bond_ab_arp_commit()
3782 slave == rtnl_dereference(bond->primary_slave) || in bond_ab_arp_commit()
3783 slave->prio > rtnl_dereference(bond->curr_active_slave)->prio) in bond_ab_arp_commit()
3791 if (slave->link_failure_count < UINT_MAX) in bond_ab_arp_commit()
3792 slave->link_failure_count++; in bond_ab_arp_commit()
3794 bond_set_slave_link_state(slave, BOND_LINK_DOWN, in bond_ab_arp_commit()
3796 bond_set_slave_inactive_flags(slave, in bond_ab_arp_commit()
3799 slave_info(bond->dev, slave->dev, "link status definitely down, disabling slave\n"); in bond_ab_arp_commit()
3801 if (slave == rtnl_dereference(bond->curr_active_slave)) { in bond_ab_arp_commit()
3809 bond_set_slave_link_state(slave, BOND_LINK_FAIL, in bond_ab_arp_commit()
3811 bond_set_slave_inactive_flags(slave, in bond_ab_arp_commit()
3814 /* A slave has just been enslaved and has become in bond_ab_arp_commit()
3815 * the current active slave. in bond_ab_arp_commit()
3822 slave_err(bond->dev, slave->dev, in bond_ab_arp_commit()
3823 "impossible: link_new_state %d on slave\n", in bond_ab_arp_commit()
3824 slave->link_new_state); in bond_ab_arp_commit()
3844 struct slave *slave, *before = NULL, *new_slave = NULL, in bond_ab_arp_probe() local
3862 * backup slave from the current_arp_slave and make it the candidate in bond_ab_arp_probe()
3872 bond_for_each_slave_rcu(bond, slave, iter) { in bond_ab_arp_probe()
3873 if (!found && !before && bond_slave_is_up(slave)) in bond_ab_arp_probe()
3874 before = slave; in bond_ab_arp_probe()
3876 if (found && !new_slave && bond_slave_is_up(slave)) in bond_ab_arp_probe()
3877 new_slave = slave; in bond_ab_arp_probe()
3882 * one the current slave so it is still marked in bond_ab_arp_probe()
3885 if (!bond_slave_is_up(slave) && slave->link == BOND_LINK_UP) { in bond_ab_arp_probe()
3886 bond_set_slave_link_state(slave, BOND_LINK_DOWN, in bond_ab_arp_probe()
3888 if (slave->link_failure_count < UINT_MAX) in bond_ab_arp_probe()
3889 slave->link_failure_count++; in bond_ab_arp_probe()
3891 bond_set_slave_inactive_flags(slave, in bond_ab_arp_probe()
3894 slave_info(bond->dev, slave->dev, "backup interface is now down\n"); in bond_ab_arp_probe()
3896 if (slave == curr_arp_slave) in bond_ab_arp_probe()
3914 bond_for_each_slave_rcu(bond, slave, iter) { in bond_ab_arp_probe()
3915 if (slave->should_notify || slave->should_notify_link) { in bond_ab_arp_probe()
4032 struct slave *slave = bond_slave_get_rtnl(slave_dev), *primary; in bond_slave_netdev_event() local
4038 * slave will be NULL in bond_slave_netdev_event()
4040 if (!slave) { in bond_slave_netdev_event()
4041 netdev_dbg(slave_dev, "%s called on NULL slave\n", __func__); in bond_slave_netdev_event()
4045 bond_dev = slave->bond->dev; in bond_slave_netdev_event()
4046 bond = slave->bond; in bond_slave_netdev_event()
4061 * Getting invalid Speed/Duplex values here will put slave in bond_slave_netdev_event()
4067 if (bond_update_speed_duplex(slave) && in bond_slave_netdev_event()
4069 if (slave->last_link_up) in bond_slave_netdev_event()
4070 slave->link = BOND_LINK_FAIL; in bond_slave_netdev_event()
4072 slave->link = BOND_LINK_DOWN; in bond_slave_netdev_event()
4076 bond_3ad_adapter_speed_duplex_changed(slave); in bond_slave_netdev_event()
4079 /* Refresh slave-array if applicable! in bond_slave_netdev_event()
4081 * then these events will not cause the slave-array to be in bond_slave_netdev_event()
4082 * refreshed. This will cause xmit to use a slave that is not in bond_slave_netdev_event()
4098 * take over the slave's change_mtu in bond_slave_netdev_event()
4109 if (slave == primary) { in bond_slave_netdev_event()
4110 /* slave's name changed - he's no longer primary */ in bond_slave_netdev_event()
4113 /* we have a new primary slave */ in bond_slave_netdev_event()
4114 rcu_assign_pointer(bond->primary_slave, slave); in bond_slave_netdev_event()
4119 netdev_info(bond->dev, "Primary slave changed to %s, reselecting active slave\n", in bond_slave_netdev_event()
4135 call_netdevice_notifiers(event, slave->bond->dev); in bond_slave_netdev_event()
4151 * locks for us to safely manipulate the slave devices (RTNL lock,
4428 struct slave *slave; in bond_open() local
4436 /* reset slave->backup and slave->inactive */ in bond_open()
4438 bond_for_each_slave(bond, slave, iter) { in bond_open()
4440 slave != rcu_access_pointer(bond->curr_active_slave)) { in bond_open()
4441 bond_set_slave_inactive_flags(slave, in bond_open()
4444 bond_set_slave_active_flags(slave, in bond_open()
4474 bond_for_each_slave(bond, slave, iter) in bond_open()
4475 dev_mc_add(slave->dev, lacpdu_mcast_addr); in bond_open()
4490 struct slave *slave; in bond_close() local
4504 slave = rcu_dereference(bond->curr_active_slave); in bond_close()
4505 if (slave) in bond_close()
4506 bond_hw_addr_flush(bond_dev, slave->dev); in bond_close()
4511 bond_for_each_slave(bond, slave, iter) in bond_close()
4512 bond_hw_addr_flush(bond_dev, slave->dev); in bond_close()
4594 struct slave *slave; in bond_get_stats() local
4606 bond_for_each_slave_rcu(bond, slave, iter) { in bond_get_stats()
4608 dev_get_stats(slave->dev, &temp); in bond_get_stats()
4610 bond_fold_stats(stats, new, &slave->slave_stats); in bond_get_stats()
4612 /* save off the slave stats for the next run */ in bond_get_stats()
4613 memcpy(&slave->slave_stats, new, sizeof(*new)); in bond_get_stats()
4774 struct slave *slave; in bond_set_rx_mode() local
4778 slave = rcu_dereference(bond->curr_active_slave); in bond_set_rx_mode()
4779 if (slave) { in bond_set_rx_mode()
4780 dev_uc_sync(slave->dev, bond_dev); in bond_set_rx_mode()
4781 dev_mc_sync(slave->dev, bond_dev); in bond_set_rx_mode()
4784 bond_for_each_slave_rcu(bond, slave, iter) { in bond_set_rx_mode()
4785 dev_uc_sync_multiple(slave->dev, bond_dev); in bond_set_rx_mode()
4786 dev_mc_sync_multiple(slave->dev, bond_dev); in bond_set_rx_mode()
4797 struct slave *slave; in bond_neigh_init() local
4801 slave = bond_first_slave_rcu(bond); in bond_neigh_init()
4802 if (!slave) in bond_neigh_init()
4804 slave_ops = slave->dev->netdev_ops; in bond_neigh_init()
4817 ret = slave_ops->ndo_neigh_setup(slave->dev, &parms); in bond_neigh_init()
4830 * slave exists. So we must declare proxy setup function which will
4831 * be used at run time to resolve the actual slave neigh param setup.
4851 struct slave *slave, *rollback_slave; in bond_change_mtu() local
4857 bond_for_each_slave(bond, slave, iter) { in bond_change_mtu()
4858 slave_dbg(bond_dev, slave->dev, "s %p c_m %p\n", in bond_change_mtu()
4859 slave, slave->dev->netdev_ops->ndo_change_mtu); in bond_change_mtu()
4861 res = dev_set_mtu(slave->dev, new_mtu); in bond_change_mtu()
4864 /* If we failed to set the slave's mtu to the new value in bond_change_mtu()
4867 * different mtu values than the active slave we'll in bond_change_mtu()
4872 slave_dbg(bond_dev, slave->dev, "err %d setting mtu to %d\n", in bond_change_mtu()
4883 /* unwind from head to the slave that failed */ in bond_change_mtu()
4887 if (rollback_slave == slave) in bond_change_mtu()
4908 struct slave *slave, *rollback_slave; in bond_set_mac_address() local
4929 bond_for_each_slave(bond, slave, iter) { in bond_set_mac_address()
4930 slave_dbg(bond_dev, slave->dev, "%s: slave=%p\n", in bond_set_mac_address()
4931 __func__, slave); in bond_set_mac_address()
4932 res = dev_set_mac_address(slave->dev, addr, NULL); in bond_set_mac_address()
4934 /* TODO: consider downing the slave in bond_set_mac_address()
4940 slave_dbg(bond_dev, slave->dev, "%s: err %d\n", in bond_set_mac_address()
4954 /* unwind from head to the slave that failed */ in bond_set_mac_address()
4958 if (rollback_slave == slave) in bond_set_mac_address()
4972 * bond_get_slave_by_id - get xmit slave with slave_id
4974 * @slave_id: slave id up to slave_cnt-1 through which to transmit
4976 * This function tries to get slave with slave_id but in case
4977 * it fails, it tries to find the first available slave for transmission.
4979 static struct slave *bond_get_slave_by_id(struct bonding *bond, in bond_get_slave_by_id()
4983 struct slave *slave; in bond_get_slave_by_id() local
4986 /* Here we start from the slave with slave_id */ in bond_get_slave_by_id()
4987 bond_for_each_slave_rcu(bond, slave, iter) { in bond_get_slave_by_id()
4989 if (bond_slave_can_tx(slave)) in bond_get_slave_by_id()
4990 return slave; in bond_get_slave_by_id()
4994 /* Here we start from the first slave up to slave_id */ in bond_get_slave_by_id()
4996 bond_for_each_slave_rcu(bond, slave, iter) { in bond_get_slave_by_id()
4999 if (bond_slave_can_tx(slave)) in bond_get_slave_by_id()
5000 return slave; in bond_get_slave_by_id()
5002 /* no slave that can tx has been found */ in bond_get_slave_by_id()
5007 * bond_rr_gen_slave_id - generate slave id based on packets_per_slave
5011 * this function generates a slave id, which is usually used as the next
5012 * slave to transmit through.
5039 static struct slave *bond_xmit_roundrobin_slave_get(struct bonding *bond, in bond_xmit_roundrobin_slave_get()
5042 struct slave *slave; in bond_xmit_roundrobin_slave_get() local
5061 slave = rcu_dereference(bond->curr_active_slave); in bond_xmit_roundrobin_slave_get()
5062 if (slave) in bond_xmit_roundrobin_slave_get()
5063 return slave; in bond_xmit_roundrobin_slave_get()
5077 static struct slave *bond_xdp_xmit_roundrobin_slave_get(struct bonding *bond, in bond_xdp_xmit_roundrobin_slave_get()
5080 struct slave *slave; in bond_xdp_xmit_roundrobin_slave_get() local
5102 slave = rcu_dereference(bond->curr_active_slave); in bond_xdp_xmit_roundrobin_slave_get()
5103 if (slave) in bond_xdp_xmit_roundrobin_slave_get()
5104 return slave; in bond_xdp_xmit_roundrobin_slave_get()
5122 struct slave *slave; in bond_xmit_roundrobin() local
5124 slave = bond_xmit_roundrobin_slave_get(bond, skb); in bond_xmit_roundrobin()
5125 if (likely(slave)) in bond_xmit_roundrobin()
5126 return bond_dev_queue_xmit(bond, skb, slave->dev); in bond_xmit_roundrobin()
5131 static struct slave *bond_xmit_activebackup_slave_get(struct bonding *bond) in bond_xmit_activebackup_slave_get()
5143 struct slave *slave; in bond_xmit_activebackup() local
5145 slave = bond_xmit_activebackup_slave_get(bond); in bond_xmit_activebackup()
5146 if (slave) in bond_xmit_activebackup()
5147 return bond_dev_queue_xmit(bond, skb, slave->dev); in bond_xmit_activebackup()
5161 /* Slave array work handler. Holds only RTNL */
5174 pr_warn_ratelimited("Failed to update slave array from WT\n"); in bond_slave_arr_handler()
5184 struct slave *skipslave) in bond_skip_slave()
5189 * slave but allocation failed (most likely!). BTW this is in bond_skip_slave()
5194 * this to-be-skipped slave to send a packet out. in bond_skip_slave()
5227 * to determine the slave interface -
5234 int bond_update_slave_arr(struct bonding *bond, struct slave *skipslave) in bond_update_slave_arr()
5237 struct slave *slave; in bond_update_slave_arr() local
5268 bond_for_each_slave(bond, slave, iter) { in bond_update_slave_arr()
5269 if (skipslave == slave) in bond_update_slave_arr()
5272 all_slaves->arr[all_slaves->count++] = slave; in bond_update_slave_arr()
5276 agg = SLAVE_AD_INFO(slave)->port.aggregator; in bond_update_slave_arr()
5280 if (!bond_slave_can_tx(slave)) in bond_update_slave_arr()
5283 slave_dbg(bond->dev, slave->dev, "Adding slave to tx hash array[%d]\n", in bond_update_slave_arr()
5286 usable_slaves->arr[usable_slaves->count++] = slave; in bond_update_slave_arr()
5304 static struct slave *bond_xmit_3ad_xor_slave_get(struct bonding *bond, in bond_xmit_3ad_xor_slave_get()
5308 struct slave *slave; in bond_xmit_3ad_xor_slave_get() local
5317 slave = slaves->arr[hash % count]; in bond_xmit_3ad_xor_slave_get()
5318 return slave; in bond_xmit_3ad_xor_slave_get()
5321 static struct slave *bond_xdp_xmit_3ad_xor_slave_get(struct bonding *bond, in bond_xdp_xmit_3ad_xor_slave_get()
5369 * usable slave array is formed in the control path. The xmit function
5377 struct slave *slave; in bond_3ad_xor_xmit() local
5380 slave = bond_xmit_3ad_xor_slave_get(bond, skb, slaves); in bond_3ad_xor_xmit()
5381 if (likely(slave)) in bond_3ad_xor_xmit()
5382 return bond_dev_queue_xmit(bond, skb, slave->dev); in bond_3ad_xor_xmit()
5387 /* in broadcast mode, we send everything to all or usable slave interfaces.
5407 struct slave *slave = slaves->arr[i]; in bond_xmit_broadcast() local
5410 if (!(bond_slave_is_up(slave) && slave->link == BOND_LINK_UP)) in bond_xmit_broadcast()
5413 if (bond_is_last_slave(bond, slave)) { in bond_xmit_broadcast()
5425 if (bond_dev_queue_xmit(bond, skb2, slave->dev) == NETDEV_TX_OK) in bond_xmit_broadcast()
5441 /* Lookup the slave that corresponds to a qid */
5445 struct slave *slave = NULL; in bond_slave_override() local
5452 bond_for_each_slave_rcu(bond, slave, iter) { in bond_slave_override()
5453 if (READ_ONCE(slave->queue_id) == skb_get_queue_mapping(skb)) { in bond_slave_override()
5454 if (bond_slave_is_up(slave) && in bond_slave_override()
5455 slave->link == BOND_LINK_UP) { in bond_slave_override()
5456 bond_dev_queue_xmit(bond, skb, slave->dev); in bond_slave_override()
5459 /* If the slave isn't UP, use default transmit policy. */ in bond_slave_override()
5495 struct slave *slave = NULL; in bond_xmit_get_slave() local
5499 slave = bond_xmit_roundrobin_slave_get(bond, skb); in bond_xmit_get_slave()
5502 slave = bond_xmit_activebackup_slave_get(bond); in bond_xmit_get_slave()
5510 slave = bond_xmit_3ad_xor_slave_get(bond, skb, slaves); in bond_xmit_get_slave()
5515 slave = bond_xmit_alb_slave_get(bond, skb); in bond_xmit_get_slave()
5518 slave = bond_xmit_tlb_slave_get(bond, skb); in bond_xmit_get_slave()
5526 if (slave) in bond_xmit_get_slave()
5527 return slave->dev; in bond_xmit_get_slave()
5581 struct slave *slave; in __bond_sk_get_lower_dev() local
5591 slave = slaves->arr[hash % count]; in __bond_sk_get_lower_dev()
5593 return slave->dev; in __bond_sk_get_lower_dev()
5689 struct slave *slave; in bond_xdp_get_xmit_slave() local
5695 slave = bond_xdp_xmit_roundrobin_slave_get(bond, xdp); in bond_xdp_get_xmit_slave()
5699 slave = bond_xmit_activebackup_slave_get(bond); in bond_xdp_get_xmit_slave()
5704 slave = bond_xdp_xmit_3ad_xor_slave_get(bond, xdp); in bond_xdp_get_xmit_slave()
5714 if (slave) in bond_xdp_get_xmit_slave()
5715 return slave->dev; in bond_xdp_get_xmit_slave()
5762 struct slave *slave, *rollback_slave; in bond_xdp_set() local
5783 bond_for_each_slave(bond, slave, iter) { in bond_xdp_set()
5784 struct net_device *slave_dev = slave->dev; in bond_xdp_set()
5789 "Slave device does not support XDP"); in bond_xdp_set()
5796 "Slave has XDP program loaded, please unload before enslaving"); in bond_xdp_set()
5830 if (slave == rollback_slave) in bond_xdp_set()
5853 static u32 bond_mode_bcast_speed(struct slave *slave, u32 speed) in bond_mode_bcast_speed() argument
5856 speed = slave->speed; in bond_mode_bcast_speed()
5858 speed = min(speed, slave->speed); in bond_mode_bcast_speed()
5929 struct slave *slave; in bond_ethtool_get_link_ksettings() local
5940 bond_for_each_slave(bond, slave, iter) { in bond_ethtool_get_link_ksettings()
5941 if (bond_slave_can_tx(slave)) { in bond_ethtool_get_link_ksettings()
5942 bond_update_speed_duplex(slave); in bond_ethtool_get_link_ksettings()
5943 if (slave->speed != SPEED_UNKNOWN) { in bond_ethtool_get_link_ksettings()
5945 speed = bond_mode_bcast_speed(slave, in bond_ethtool_get_link_ksettings()
5948 speed += slave->speed; in bond_ethtool_get_link_ksettings()
5951 slave->duplex != DUPLEX_UNKNOWN) in bond_ethtool_get_link_ksettings()
5952 cmd->base.duplex = slave->duplex; in bond_ethtool_get_link_ksettings()
5976 struct slave *slave; in bond_ethtool_get_ts_info() local
5989 bond_for_each_slave_rcu(bond, slave, iter) { in bond_ethtool_get_ts_info()
5990 ret = ethtool_get_ts_info_by_layer(slave->dev, &ts_info); in bond_ethtool_get_ts_info()
6137 struct slave *slave; in bond_uninit() local
6142 bond_for_each_slave(bond, slave, iter) in bond_uninit()
6143 __bond_release_one(bond_dev, slave->dev, true, true); in bond_uninit()