Lines Matching refs:slave

372 	struct slave *slave, *rollback_slave;  in bond_vlan_rx_add_vid()  local
376 bond_for_each_slave(bond, slave, iter) { in bond_vlan_rx_add_vid()
377 res = vlan_vid_add(slave->dev, proto, vid); in bond_vlan_rx_add_vid()
387 if (rollback_slave == slave) in bond_vlan_rx_add_vid()
407 struct slave *slave; in bond_vlan_rx_kill_vid() local
409 bond_for_each_slave(bond, slave, iter) in bond_vlan_rx_kill_vid()
410 vlan_vid_del(slave->dev, proto, vid); in bond_vlan_rx_kill_vid()
433 struct slave *slave; in bond_ipsec_dev() local
442 slave = rcu_dereference(bond->curr_active_slave); in bond_ipsec_dev()
443 if (!slave) in bond_ipsec_dev()
449 if (xs->xso.real_dev != slave->dev) in bond_ipsec_dev()
451 bond_dev->name, slave->dev->name, xs->xso.real_dev->name); in bond_ipsec_dev()
453 return slave->dev; in bond_ipsec_dev()
469 struct slave *slave; in bond_ipsec_add_sa() local
477 slave = rcu_dereference(bond->curr_active_slave); in bond_ipsec_add_sa()
478 real_dev = slave ? slave->dev : NULL; in bond_ipsec_add_sa()
521 struct slave *slave; in bond_ipsec_add_sa_all() local
523 slave = rtnl_dereference(bond->curr_active_slave); in bond_ipsec_add_sa_all()
524 real_dev = slave ? slave->dev : NULL; in bond_ipsec_add_sa_all()
565 struct slave *slave; in bond_ipsec_del_sa() local
572 slave = rcu_dereference(bond->curr_active_slave); in bond_ipsec_del_sa()
573 real_dev = slave ? slave->dev : NULL; in bond_ipsec_del_sa()
577 if (!slave) in bond_ipsec_del_sa()
611 struct slave *slave; in bond_ipsec_del_sa_all() local
613 slave = rtnl_dereference(bond->curr_active_slave); in bond_ipsec_del_sa_all()
614 real_dev = slave ? slave->dev : NULL; in bond_ipsec_del_sa_all()
644 struct slave *slave; in bond_ipsec_free_sa() local
651 slave = rcu_dereference(bond->curr_active_slave); in bond_ipsec_free_sa()
652 real_dev = slave ? slave->dev : NULL; in bond_ipsec_free_sa()
656 if (!slave) in bond_ipsec_free_sa()
766 struct slave *slave; in bond_set_carrier() local
774 bond_for_each_slave(bond, slave, iter) { in bond_set_carrier()
775 if (slave->link == BOND_LINK_UP) { in bond_set_carrier()
798 static int bond_update_speed_duplex(struct slave *slave) in bond_update_speed_duplex() argument
800 struct net_device *slave_dev = slave->dev; in bond_update_speed_duplex()
804 slave->speed = SPEED_UNKNOWN; in bond_update_speed_duplex()
805 slave->duplex = DUPLEX_UNKNOWN; in bond_update_speed_duplex()
820 slave->speed = ecmd.base.speed; in bond_update_speed_duplex()
821 slave->duplex = ecmd.base.duplex; in bond_update_speed_duplex()
918 struct slave *curr_active = rtnl_dereference(bond->curr_active_slave); in bond_set_promiscuity()
923 struct slave *slave; in bond_set_promiscuity() local
925 bond_for_each_slave(bond, slave, iter) { in bond_set_promiscuity()
926 err = dev_set_promiscuity(slave->dev, inc); in bond_set_promiscuity()
941 struct slave *curr_active = rtnl_dereference(bond->curr_active_slave); in bond_set_allmulti()
946 struct slave *slave; in bond_set_allmulti() local
948 bond_for_each_slave(bond, slave, iter) { in bond_set_allmulti()
949 err = dev_set_allmulti(slave->dev, inc); in bond_set_allmulti()
999 static void bond_hw_addr_swap(struct bonding *bond, struct slave *new_active, in bond_hw_addr_swap()
1000 struct slave *old_active) in bond_hw_addr_swap()
1058 static struct slave *bond_get_old_active(struct bonding *bond, in bond_get_old_active()
1059 struct slave *new_active) in bond_get_old_active()
1061 struct slave *slave; in bond_get_old_active() local
1064 bond_for_each_slave(bond, slave, iter) { in bond_get_old_active()
1065 if (slave == new_active) in bond_get_old_active()
1068 if (ether_addr_equal(bond->dev->dev_addr, slave->dev->dev_addr)) in bond_get_old_active()
1069 return slave; in bond_get_old_active()
1082 struct slave *new_active, in bond_do_fail_over_mac()
1083 struct slave *old_active) in bond_do_fail_over_mac()
1163 static struct slave *bond_choose_primary_or_current(struct bonding *bond) in bond_choose_primary_or_current()
1165 struct slave *prim = rtnl_dereference(bond->primary_slave); in bond_choose_primary_or_current()
1166 struct slave *curr = rtnl_dereference(bond->curr_active_slave); in bond_choose_primary_or_current()
1167 struct slave *slave, *hprio = NULL; in bond_choose_primary_or_current() local
1171 bond_for_each_slave(bond, slave, iter) { in bond_choose_primary_or_current()
1172 if (slave->link == BOND_LINK_UP) { in bond_choose_primary_or_current()
1173 hprio = hprio ?: slave; in bond_choose_primary_or_current()
1174 if (slave->prio > hprio->prio) in bond_choose_primary_or_current()
1175 hprio = slave; in bond_choose_primary_or_current()
1221 static struct slave *bond_find_best_slave(struct bonding *bond) in bond_find_best_slave()
1223 struct slave *slave, *bestslave = NULL; in bond_find_best_slave() local
1227 slave = bond_choose_primary_or_current(bond); in bond_find_best_slave()
1228 if (slave) in bond_find_best_slave()
1229 return slave; in bond_find_best_slave()
1231 bond_for_each_slave(bond, slave, iter) { in bond_find_best_slave()
1232 if (slave->link == BOND_LINK_UP) in bond_find_best_slave()
1233 return slave; in bond_find_best_slave()
1234 if (slave->link == BOND_LINK_BACK && bond_slave_is_up(slave) && in bond_find_best_slave()
1235 slave->delay < mintime) { in bond_find_best_slave()
1236 mintime = slave->delay; in bond_find_best_slave()
1237 bestslave = slave; in bond_find_best_slave()
1247 struct slave *slave = rcu_dereference_rtnl(bond->curr_active_slave); in bond_should_notify_peers() local
1249 if (!slave || !bond->send_peer_notif || in bond_should_notify_peers()
1253 test_bit(__LINK_STATE_LINKWATCH_PENDING, &slave->dev->state)) in bond_should_notify_peers()
1257 slave ? slave->dev->name : "NULL"); in bond_should_notify_peers()
1277 void bond_change_active_slave(struct bonding *bond, struct slave *new_active) in bond_change_active_slave()
1279 struct slave *old_active; in bond_change_active_slave()
1393 struct slave *best_slave; in bond_select_active_slave()
1413 static inline int slave_enable_netpoll(struct slave *slave) in slave_enable_netpoll() argument
1423 err = __netpoll_setup(np, slave->dev); in slave_enable_netpoll()
1428 slave->np = np; in slave_enable_netpoll()
1432 static inline void slave_disable_netpoll(struct slave *slave) in slave_disable_netpoll() argument
1434 struct netpoll *np = slave->np; in slave_disable_netpoll()
1439 slave->np = NULL; in slave_disable_netpoll()
1447 struct slave *slave = NULL; in bond_poll_controller() local
1455 bond_for_each_slave_rcu(bond, slave, iter) { in bond_poll_controller()
1456 if (!bond_slave_is_up(slave)) in bond_poll_controller()
1461 SLAVE_AD_INFO(slave)->port.aggregator; in bond_poll_controller()
1468 netpoll_poll_dev(slave->dev); in bond_poll_controller()
1476 struct slave *slave; in bond_netpoll_cleanup() local
1478 bond_for_each_slave(bond, slave, iter) in bond_netpoll_cleanup()
1479 if (bond_slave_is_up(slave)) in bond_netpoll_cleanup()
1480 slave_disable_netpoll(slave); in bond_netpoll_cleanup()
1487 struct slave *slave; in bond_netpoll_setup() local
1490 bond_for_each_slave(bond, slave, iter) { in bond_netpoll_setup()
1491 err = slave_enable_netpoll(slave); in bond_netpoll_setup()
1500 static inline int slave_enable_netpoll(struct slave *slave) in slave_enable_netpoll() argument
1504 static inline void slave_disable_netpoll(struct slave *slave) in slave_disable_netpoll() argument
1520 struct slave *slave; in bond_fix_features() local
1525 bond_for_each_slave(bond, slave, iter) { in bond_fix_features()
1527 slave->dev->features, in bond_fix_features()
1563 struct slave *slave; in bond_compute_features() local
1574 bond_for_each_slave(bond, slave, iter) { in bond_compute_features()
1576 slave->dev->vlan_features, BOND_VLAN_FEATURES); in bond_compute_features()
1579 slave->dev->hw_enc_features, in bond_compute_features()
1584 slave->dev->hw_enc_features, in bond_compute_features()
1589 slave->dev->gso_partial_features, in bond_compute_features()
1593 slave->dev->mpls_features, in bond_compute_features()
1596 dst_release_flag &= slave->dev->priv_flags; in bond_compute_features()
1597 if (slave->dev->hard_header_len > max_hard_header_len) in bond_compute_features()
1598 max_hard_header_len = slave->dev->hard_header_len; in bond_compute_features()
1600 tso_max_size = min(tso_max_size, slave->dev->tso_max_size); in bond_compute_features()
1601 tso_max_segs = min(tso_max_segs, slave->dev->tso_max_segs); in bond_compute_features()
1655 struct slave *slave, in bond_should_deliver_exact_match() argument
1658 if (bond_is_slave_inactive(slave)) { in bond_should_deliver_exact_match()
1671 struct slave *slave; in bond_handle_frame() local
1674 struct slave *); in bond_handle_frame()
1683 slave = bond_slave_get_rcu(skb->dev); in bond_handle_frame()
1684 bond = slave->bond; in bond_handle_frame()
1688 ret = recv_probe(skb, bond, slave); in bond_handle_frame()
1706 if (bond_should_deliver_exact_match(skb, slave, bond)) { in bond_handle_frame()
1771 static int bond_master_upper_dev_link(struct bonding *bond, struct slave *slave, in bond_master_upper_dev_link() argument
1782 err = netdev_master_upper_dev_link(slave->dev, bond->dev, slave, in bond_master_upper_dev_link()
1787 slave->dev->flags |= IFF_SLAVE; in bond_master_upper_dev_link()
1791 static void bond_upper_dev_unlink(struct bonding *bond, struct slave *slave) in bond_upper_dev_unlink() argument
1793 netdev_upper_dev_unlink(slave->dev, bond->dev); in bond_upper_dev_unlink()
1794 slave->dev->flags &= ~IFF_SLAVE; in bond_upper_dev_unlink()
1799 struct slave *slave = to_slave(kobj); in slave_kobj_release() local
1800 struct bonding *bond = bond_get_bond_by_slave(slave); in slave_kobj_release()
1802 cancel_delayed_work_sync(&slave->notify_work); in slave_kobj_release()
1804 kfree(SLAVE_AD_INFO(slave)); in slave_kobj_release()
1806 kfree(slave); in slave_kobj_release()
1816 static int bond_kobj_init(struct slave *slave) in bond_kobj_init() argument
1820 err = kobject_init_and_add(&slave->kobj, &slave_ktype, in bond_kobj_init()
1821 &(slave->dev->dev.kobj), "bonding_slave"); in bond_kobj_init()
1823 kobject_put(&slave->kobj); in bond_kobj_init()
1828 static struct slave *bond_alloc_slave(struct bonding *bond, in bond_alloc_slave()
1831 struct slave *slave = NULL; in bond_alloc_slave() local
1833 slave = kzalloc(sizeof(*slave), GFP_KERNEL); in bond_alloc_slave()
1834 if (!slave) in bond_alloc_slave()
1837 slave->bond = bond; in bond_alloc_slave()
1838 slave->dev = slave_dev; in bond_alloc_slave()
1839 INIT_DELAYED_WORK(&slave->notify_work, bond_netdev_notify_work); in bond_alloc_slave()
1841 if (bond_kobj_init(slave)) in bond_alloc_slave()
1845 SLAVE_AD_INFO(slave) = kzalloc(sizeof(struct ad_slave_info), in bond_alloc_slave()
1847 if (!SLAVE_AD_INFO(slave)) { in bond_alloc_slave()
1848 kobject_put(&slave->kobj); in bond_alloc_slave()
1853 return slave; in bond_alloc_slave()
1863 static void bond_fill_ifslave(struct slave *slave, struct ifslave *info) in bond_fill_ifslave() argument
1865 strcpy(info->slave_name, slave->dev->name); in bond_fill_ifslave()
1866 info->link = slave->link; in bond_fill_ifslave()
1867 info->state = bond_slave_state(slave); in bond_fill_ifslave()
1868 info->link_failure_count = slave->link_failure_count; in bond_fill_ifslave()
1873 struct slave *slave = container_of(_work, struct slave, in bond_netdev_notify_work() local
1879 bond_fill_ifslave(slave, &binfo.slave); in bond_netdev_notify_work()
1880 bond_fill_ifbond(slave->bond, &binfo.master); in bond_netdev_notify_work()
1881 netdev_bonding_info_change(slave->dev, &binfo); in bond_netdev_notify_work()
1884 queue_delayed_work(slave->bond->wq, &slave->notify_work, 1); in bond_netdev_notify_work()
1888 void bond_queue_slave_event(struct slave *slave) in bond_queue_slave_event() argument
1890 queue_delayed_work(slave->bond->wq, &slave->notify_work, 0); in bond_queue_slave_event()
1893 void bond_lower_state_changed(struct slave *slave) in bond_lower_state_changed() argument
1897 info.link_up = slave->link == BOND_LINK_UP || in bond_lower_state_changed()
1898 slave->link == BOND_LINK_FAIL; in bond_lower_state_changed()
1899 info.tx_enabled = bond_is_active_slave(slave); in bond_lower_state_changed()
1900 netdev_lower_state_changed(slave->dev, &info); in bond_lower_state_changed()
1936 struct slave *slave; in bond_xdp_set_features() local
1945 bond_for_each_slave(bond, slave, iter) in bond_xdp_set_features()
1946 val &= slave->dev->xdp_features; in bond_xdp_set_features()
1959 struct slave *new_slave = NULL, *prev_slave; in bond_enslave()
2494 struct slave *slave, *oldcurrent; in __bond_release_one() local
2508 slave = bond_get_slave_by_dev(bond, slave_dev); in __bond_release_one()
2509 if (!slave) { in __bond_release_one()
2516 bond_set_slave_inactive_flags(slave, BOND_SLAVE_NOTIFY_NOW); in __bond_release_one()
2518 bond_sysfs_slave_del(slave); in __bond_release_one()
2540 bond_3ad_unbind_slave(slave); in __bond_release_one()
2542 bond_upper_dev_unlink(bond, slave); in __bond_release_one()
2545 bond_update_slave_arr(bond, slave); in __bond_release_one()
2548 bond_is_active_slave(slave) ? "active" : "backup"); in __bond_release_one()
2556 if (ether_addr_equal_64bits(bond_dev->dev_addr, slave->perm_hwaddr) && in __bond_release_one()
2559 slave->perm_hwaddr); in __bond_release_one()
2562 if (rtnl_dereference(bond->primary_slave) == slave) in __bond_release_one()
2565 if (oldcurrent == slave) in __bond_release_one()
2572 bond_slave_ns_maddrs_del(bond, slave); in __bond_release_one()
2580 bond_alb_deinit_slave(bond, slave); in __bond_release_one()
2585 } else if (oldcurrent == slave) { in __bond_release_one()
2635 slave_disable_netpoll(slave); in __bond_release_one()
2645 bond_hw_addr_copy(ss.__data, slave->perm_hwaddr, in __bond_release_one()
2646 slave->dev->addr_len); in __bond_release_one()
2652 __dev_set_mtu(slave_dev, slave->original_mtu); in __bond_release_one()
2654 dev_set_mtu(slave_dev, slave->original_mtu); in __bond_release_one()
2660 kobject_put(&slave->kobj); in __bond_release_one()
2703 struct slave *slave; in bond_slave_info_query() local
2705 bond_for_each_slave(bond, slave, iter) { in bond_slave_info_query()
2708 bond_fill_ifslave(slave, info); in bond_slave_info_query()
2724 struct slave *slave; in bond_miimon_inspect() local
2737 bond_for_each_slave_rcu(bond, slave, iter) { in bond_miimon_inspect()
2738 bond_propose_link_state(slave, BOND_LINK_NOCHANGE); in bond_miimon_inspect()
2740 link_state = bond_check_dev_link(bond, slave->dev, 0); in bond_miimon_inspect()
2742 switch (slave->link) { in bond_miimon_inspect()
2747 bond_propose_link_state(slave, BOND_LINK_FAIL); in bond_miimon_inspect()
2749 slave->delay = bond->params.downdelay; in bond_miimon_inspect()
2750 if (slave->delay && net_ratelimit()) { in bond_miimon_inspect()
2751 slave_info(bond->dev, slave->dev, "link status down for %sinterface, disabling it in %d ms\n", in bond_miimon_inspect()
2754 (bond_is_active_slave(slave) ? in bond_miimon_inspect()
2762 bond_propose_link_state(slave, BOND_LINK_UP); in bond_miimon_inspect()
2763 slave->last_link_up = jiffies; in bond_miimon_inspect()
2765 slave_info(bond->dev, slave->dev, "link status up again after %d ms\n", in bond_miimon_inspect()
2766 (bond->params.downdelay - slave->delay) * in bond_miimon_inspect()
2772 if (slave->delay <= 0) { in bond_miimon_inspect()
2773 bond_propose_link_state(slave, BOND_LINK_DOWN); in bond_miimon_inspect()
2778 slave->delay--; in bond_miimon_inspect()
2785 bond_propose_link_state(slave, BOND_LINK_BACK); in bond_miimon_inspect()
2787 slave->delay = bond->params.updelay; in bond_miimon_inspect()
2789 if (slave->delay && net_ratelimit()) { in bond_miimon_inspect()
2790 slave_info(bond->dev, slave->dev, "link status up, enabling it in %d ms\n", in bond_miimon_inspect()
2798 bond_propose_link_state(slave, BOND_LINK_DOWN); in bond_miimon_inspect()
2800 slave_info(bond->dev, slave->dev, "link status down again after %d ms\n", in bond_miimon_inspect()
2801 (bond->params.updelay - slave->delay) * in bond_miimon_inspect()
2808 slave->delay = 0; in bond_miimon_inspect()
2810 if (slave->delay <= 0) { in bond_miimon_inspect()
2811 bond_propose_link_state(slave, BOND_LINK_UP); in bond_miimon_inspect()
2817 slave->delay--; in bond_miimon_inspect()
2826 struct slave *slave, in bond_miimon_link_change() argument
2831 bond_3ad_handle_link_change(slave, link); in bond_miimon_link_change()
2835 bond_alb_handle_link_change(bond, slave, link); in bond_miimon_link_change()
2845 struct slave *slave, *primary, *active; in bond_miimon_commit() local
2851 bond_for_each_slave(bond, slave, iter) { in bond_miimon_commit()
2852 switch (slave->link_new_state) { in bond_miimon_commit()
2861 slave->link == BOND_LINK_UP) in bond_miimon_commit()
2862 bond_3ad_adapter_speed_duplex_changed(slave); in bond_miimon_commit()
2866 if (bond_update_speed_duplex(slave) && in bond_miimon_commit()
2868 slave->link = BOND_LINK_DOWN; in bond_miimon_commit()
2870 slave_warn(bond->dev, slave->dev, in bond_miimon_commit()
2874 bond_set_slave_link_state(slave, BOND_LINK_UP, in bond_miimon_commit()
2876 slave->last_link_up = jiffies; in bond_miimon_commit()
2881 bond_set_backup_slave(slave); in bond_miimon_commit()
2884 bond_set_active_slave(slave); in bond_miimon_commit()
2887 slave_info(bond->dev, slave->dev, "link status definitely up, %u Mbps %s duplex\n", in bond_miimon_commit()
2888 slave->speed == SPEED_UNKNOWN ? 0 : slave->speed, in bond_miimon_commit()
2889 slave->duplex ? "full" : "half"); in bond_miimon_commit()
2891 bond_miimon_link_change(bond, slave, BOND_LINK_UP); in bond_miimon_commit()
2894 if (!active || slave == primary || slave->prio > active->prio) in bond_miimon_commit()
2900 if (slave->link_failure_count < UINT_MAX) in bond_miimon_commit()
2901 slave->link_failure_count++; in bond_miimon_commit()
2903 bond_set_slave_link_state(slave, BOND_LINK_DOWN, in bond_miimon_commit()
2908 bond_set_slave_inactive_flags(slave, in bond_miimon_commit()
2911 slave_info(bond->dev, slave->dev, "link status definitely down, disabling slave\n"); in bond_miimon_commit()
2913 bond_miimon_link_change(bond, slave, BOND_LINK_DOWN); in bond_miimon_commit()
2915 if (slave == rcu_access_pointer(bond->curr_active_slave)) in bond_miimon_commit()
2921 slave_err(bond->dev, slave->dev, "invalid new link %d on slave\n", in bond_miimon_commit()
2922 slave->link_new_state); in bond_miimon_commit()
2923 bond_propose_link_state(slave, BOND_LINK_NOCHANGE); in bond_miimon_commit()
2952 struct slave *slave; in bond_mii_monitor() local
2981 bond_for_each_slave(bond, slave, iter) { in bond_mii_monitor()
2982 bond_commit_link_state(slave, BOND_SLAVE_NOTIFY_LATER); in bond_mii_monitor()
3029 static bool bond_handle_vlan(struct slave *slave, struct bond_vlan_tag *tags, in bond_handle_vlan() argument
3032 struct net_device *bond_dev = slave->bond->dev; in bond_handle_vlan()
3033 struct net_device *slave_dev = slave->dev; in bond_handle_vlan()
3074 static void bond_arp_send(struct slave *slave, int arp_op, __be32 dest_ip, in bond_arp_send() argument
3077 struct net_device *bond_dev = slave->bond->dev; in bond_arp_send()
3078 struct net_device *slave_dev = slave->dev; in bond_arp_send()
3092 if (bond_handle_vlan(slave, tags, skb)) { in bond_arp_send()
3093 slave_update_last_tx(slave); in bond_arp_send()
3140 static void bond_arp_send_all(struct bonding *bond, struct slave *slave) in bond_arp_send_all() argument
3148 slave_dbg(bond->dev, slave->dev, "%s: target %pI4\n", in bond_arp_send_all()
3163 bond_arp_send(slave, ARPOP_REQUEST, targets[i], in bond_arp_send_all()
3180 slave_dbg(bond->dev, slave->dev, "no path to arp_ip_target %pI4 via rt.dev %s\n", in bond_arp_send_all()
3189 bond_arp_send(slave, ARPOP_REQUEST, targets[i], addr, tags); in bond_arp_send_all()
3194 static void bond_validate_arp(struct bonding *bond, struct slave *slave, __be32 sip, __be32 tip) in bond_validate_arp() argument
3199 slave_dbg(bond->dev, slave->dev, "%s: sip %pI4 tip %pI4 not found\n", in bond_validate_arp()
3206 slave_dbg(bond->dev, slave->dev, "%s: sip %pI4 not found in targets\n", in bond_validate_arp()
3210 slave->last_rx = jiffies; in bond_validate_arp()
3211 slave->target_last_arp_rx[i] = jiffies; in bond_validate_arp()
3215 struct slave *slave) in bond_arp_rcv() argument
3218 struct slave *curr_active_slave, *curr_arp_slave; in bond_arp_rcv()
3247 slave_dbg(bond->dev, slave->dev, "%s: %s/%d av %d sv %d sip %pI4 tip %pI4\n", in bond_arp_rcv()
3248 __func__, slave->dev->name, bond_slave_state(slave), in bond_arp_rcv()
3249 bond->params.arp_validate, slave_do_arp_validate(bond, slave), in bond_arp_rcv()
3278 if (bond_is_active_slave(slave)) in bond_arp_rcv()
3279 bond_validate_arp(bond, slave, sip, tip); in bond_arp_rcv()
3283 bond_validate_arp(bond, slave, tip, sip); in bond_arp_rcv()
3286 bond_validate_arp(bond, slave, sip, tip); in bond_arp_rcv()
3295 static void bond_ns_send(struct slave *slave, const struct in6_addr *daddr, in bond_ns_send() argument
3298 struct net_device *bond_dev = slave->bond->dev; in bond_ns_send()
3299 struct net_device *slave_dev = slave->dev; in bond_ns_send()
3313 if (bond_handle_vlan(slave, tags, skb)) { in bond_ns_send()
3314 slave_update_last_tx(slave); in bond_ns_send()
3319 static void bond_ns_send_all(struct bonding *bond, struct slave *slave) in bond_ns_send_all() argument
3329 slave_dbg(bond->dev, slave->dev, "%s: target %pI6c\n", in bond_ns_send_all()
3348 bond_ns_send(slave, &targets[i], &in6addr_any, tags); in bond_ns_send_all()
3364 slave_dbg(bond->dev, slave->dev, "no path to ns_ip6_target %pI6c via dst->dev %s\n", in bond_ns_send_all()
3372 bond_ns_send(slave, &targets[i], &saddr, tags); in bond_ns_send_all()
3374 bond_ns_send(slave, &targets[i], &in6addr_any, tags); in bond_ns_send_all()
3407 static void bond_validate_na(struct bonding *bond, struct slave *slave, in bond_validate_na() argument
3420 slave_dbg(bond->dev, slave->dev, "%s: sip %pI6c tip %pI6c not found\n", in bond_validate_na()
3427 slave_dbg(bond->dev, slave->dev, "%s: sip %pI6c not found in targets\n", in bond_validate_na()
3431 slave->last_rx = jiffies; in bond_validate_na()
3432 slave->target_last_arp_rx[i] = jiffies; in bond_validate_na()
3436 struct slave *slave) in bond_na_rcv() argument
3438 struct slave *curr_active_slave, *curr_arp_slave; in bond_na_rcv()
3458 slave_dbg(bond->dev, slave->dev, "%s: %s/%d av %d sv %d sip %pI6c tip %pI6c\n", in bond_na_rcv()
3459 __func__, slave->dev->name, bond_slave_state(slave), in bond_na_rcv()
3460 bond->params.arp_validate, slave_do_arp_validate(bond, slave), in bond_na_rcv()
3469 if (bond_is_active_slave(slave)) in bond_na_rcv()
3470 bond_validate_na(bond, slave, saddr, daddr); in bond_na_rcv()
3474 bond_validate_na(bond, slave, daddr, saddr); in bond_na_rcv()
3477 bond_validate_na(bond, slave, saddr, daddr); in bond_na_rcv()
3485 struct slave *slave) in bond_rcv_validate() argument
3492 slave_dbg(bond->dev, slave->dev, "%s: skb->dev %s\n", in bond_rcv_validate()
3496 if (!slave_do_arp_validate(bond, slave)) { in bond_rcv_validate()
3502 slave->last_rx = jiffies; in bond_rcv_validate()
3505 return bond_arp_rcv(skb, bond, slave); in bond_rcv_validate()
3508 return bond_na_rcv(skb, bond, slave); in bond_rcv_validate()
3515 static void bond_send_validate(struct bonding *bond, struct slave *slave) in bond_send_validate() argument
3517 bond_arp_send_all(bond, slave); in bond_send_validate()
3519 bond_ns_send_all(bond, slave); in bond_send_validate()
3545 struct slave *slave, *oldcurrent; in bond_loadbalance_arp_mon() local
3563 bond_for_each_slave_rcu(bond, slave, iter) { in bond_loadbalance_arp_mon()
3564 unsigned long last_tx = slave_last_tx(slave); in bond_loadbalance_arp_mon()
3566 bond_propose_link_state(slave, BOND_LINK_NOCHANGE); in bond_loadbalance_arp_mon()
3568 if (slave->link != BOND_LINK_UP) { in bond_loadbalance_arp_mon()
3570 bond_time_in_interval(bond, slave->last_rx, 1)) { in bond_loadbalance_arp_mon()
3572 bond_propose_link_state(slave, BOND_LINK_UP); in bond_loadbalance_arp_mon()
3581 slave_info(bond->dev, slave->dev, "link status definitely up\n"); in bond_loadbalance_arp_mon()
3584 slave_info(bond->dev, slave->dev, "interface is now up\n"); in bond_loadbalance_arp_mon()
3595 !bond_time_in_interval(bond, slave->last_rx, bond->params.missed_max)) { in bond_loadbalance_arp_mon()
3597 bond_propose_link_state(slave, BOND_LINK_DOWN); in bond_loadbalance_arp_mon()
3600 if (slave->link_failure_count < UINT_MAX) in bond_loadbalance_arp_mon()
3601 slave->link_failure_count++; in bond_loadbalance_arp_mon()
3603 slave_info(bond->dev, slave->dev, "interface is now down\n"); in bond_loadbalance_arp_mon()
3605 if (slave == oldcurrent) in bond_loadbalance_arp_mon()
3617 if (bond_slave_is_up(slave)) in bond_loadbalance_arp_mon()
3618 bond_send_validate(bond, slave); in bond_loadbalance_arp_mon()
3627 bond_for_each_slave(bond, slave, iter) { in bond_loadbalance_arp_mon()
3628 if (slave->link_new_state != BOND_LINK_NOCHANGE) in bond_loadbalance_arp_mon()
3629 slave->link = slave->link_new_state; in bond_loadbalance_arp_mon()
3662 struct slave *slave; in bond_ab_arp_inspect() local
3665 bond_for_each_slave_rcu(bond, slave, iter) { in bond_ab_arp_inspect()
3666 bond_propose_link_state(slave, BOND_LINK_NOCHANGE); in bond_ab_arp_inspect()
3667 last_rx = slave_last_rx(bond, slave); in bond_ab_arp_inspect()
3669 if (slave->link != BOND_LINK_UP) { in bond_ab_arp_inspect()
3671 bond_propose_link_state(slave, BOND_LINK_UP); in bond_ab_arp_inspect()
3673 } else if (slave->link == BOND_LINK_BACK) { in bond_ab_arp_inspect()
3674 bond_propose_link_state(slave, BOND_LINK_FAIL); in bond_ab_arp_inspect()
3684 if (bond_time_in_interval(bond, slave->last_link_up, 2)) in bond_ab_arp_inspect()
3699 if (!bond_is_active_slave(slave) && in bond_ab_arp_inspect()
3702 bond_propose_link_state(slave, BOND_LINK_DOWN); in bond_ab_arp_inspect()
3711 last_tx = slave_last_tx(slave); in bond_ab_arp_inspect()
3712 if (bond_is_active_slave(slave) && in bond_ab_arp_inspect()
3715 bond_propose_link_state(slave, BOND_LINK_DOWN); in bond_ab_arp_inspect()
3733 struct slave *slave; in bond_ab_arp_commit() local
3735 bond_for_each_slave(bond, slave, iter) { in bond_ab_arp_commit()
3736 switch (slave->link_new_state) { in bond_ab_arp_commit()
3741 last_tx = slave_last_tx(slave); in bond_ab_arp_commit()
3742 if (rtnl_dereference(bond->curr_active_slave) != slave || in bond_ab_arp_commit()
3745 struct slave *current_arp_slave; in bond_ab_arp_commit()
3748 bond_set_slave_link_state(slave, BOND_LINK_UP, in bond_ab_arp_commit()
3757 slave_info(bond->dev, slave->dev, "link status definitely up\n"); in bond_ab_arp_commit()
3760 slave == rtnl_dereference(bond->primary_slave) || in bond_ab_arp_commit()
3761 slave->prio > rtnl_dereference(bond->curr_active_slave)->prio) in bond_ab_arp_commit()
3769 if (slave->link_failure_count < UINT_MAX) in bond_ab_arp_commit()
3770 slave->link_failure_count++; in bond_ab_arp_commit()
3772 bond_set_slave_link_state(slave, BOND_LINK_DOWN, in bond_ab_arp_commit()
3774 bond_set_slave_inactive_flags(slave, in bond_ab_arp_commit()
3777 slave_info(bond->dev, slave->dev, "link status definitely down, disabling slave\n"); in bond_ab_arp_commit()
3779 if (slave == rtnl_dereference(bond->curr_active_slave)) { in bond_ab_arp_commit()
3787 bond_set_slave_link_state(slave, BOND_LINK_FAIL, in bond_ab_arp_commit()
3789 bond_set_slave_inactive_flags(slave, in bond_ab_arp_commit()
3800 slave_err(bond->dev, slave->dev, in bond_ab_arp_commit()
3802 slave->link_new_state); in bond_ab_arp_commit()
3822 struct slave *slave, *before = NULL, *new_slave = NULL, in bond_ab_arp_probe() local
3850 bond_for_each_slave_rcu(bond, slave, iter) { in bond_ab_arp_probe()
3851 if (!found && !before && bond_slave_is_up(slave)) in bond_ab_arp_probe()
3852 before = slave; in bond_ab_arp_probe()
3854 if (found && !new_slave && bond_slave_is_up(slave)) in bond_ab_arp_probe()
3855 new_slave = slave; in bond_ab_arp_probe()
3863 if (!bond_slave_is_up(slave) && slave->link == BOND_LINK_UP) { in bond_ab_arp_probe()
3864 bond_set_slave_link_state(slave, BOND_LINK_DOWN, in bond_ab_arp_probe()
3866 if (slave->link_failure_count < UINT_MAX) in bond_ab_arp_probe()
3867 slave->link_failure_count++; in bond_ab_arp_probe()
3869 bond_set_slave_inactive_flags(slave, in bond_ab_arp_probe()
3872 slave_info(bond->dev, slave->dev, "backup interface is now down\n"); in bond_ab_arp_probe()
3874 if (slave == curr_arp_slave) in bond_ab_arp_probe()
3892 bond_for_each_slave_rcu(bond, slave, iter) { in bond_ab_arp_probe()
3893 if (slave->should_notify || slave->should_notify_link) { in bond_ab_arp_probe()
4010 struct slave *slave = bond_slave_get_rtnl(slave_dev), *primary; in bond_slave_netdev_event() local
4018 if (!slave) { in bond_slave_netdev_event()
4023 bond_dev = slave->bond->dev; in bond_slave_netdev_event()
4024 bond = slave->bond; in bond_slave_netdev_event()
4045 if (bond_update_speed_duplex(slave) && in bond_slave_netdev_event()
4047 if (slave->last_link_up) in bond_slave_netdev_event()
4048 slave->link = BOND_LINK_FAIL; in bond_slave_netdev_event()
4050 slave->link = BOND_LINK_DOWN; in bond_slave_netdev_event()
4054 bond_3ad_adapter_speed_duplex_changed(slave); in bond_slave_netdev_event()
4087 if (slave == primary) { in bond_slave_netdev_event()
4092 rcu_assign_pointer(bond->primary_slave, slave); in bond_slave_netdev_event()
4113 call_netdevice_notifiers(event, slave->bond->dev); in bond_slave_netdev_event()
4406 struct slave *slave; in bond_open() local
4416 bond_for_each_slave(bond, slave, iter) { in bond_open()
4418 slave != rcu_access_pointer(bond->curr_active_slave)) { in bond_open()
4419 bond_set_slave_inactive_flags(slave, in bond_open()
4422 bond_set_slave_active_flags(slave, in bond_open()
4452 bond_for_each_slave(bond, slave, iter) in bond_open()
4453 dev_mc_add(slave->dev, lacpdu_mcast_addr); in bond_open()
4465 struct slave *slave; in bond_close() local
4475 slave = rcu_dereference(bond->curr_active_slave); in bond_close()
4476 if (slave) in bond_close()
4477 bond_hw_addr_flush(bond_dev, slave->dev); in bond_close()
4482 bond_for_each_slave(bond, slave, iter) in bond_close()
4483 bond_hw_addr_flush(bond_dev, slave->dev); in bond_close()
4565 struct slave *slave; in bond_get_stats() local
4577 bond_for_each_slave_rcu(bond, slave, iter) { in bond_get_stats()
4579 dev_get_stats(slave->dev, &temp); in bond_get_stats()
4581 bond_fold_stats(stats, new, &slave->slave_stats); in bond_get_stats()
4584 memcpy(&slave->slave_stats, new, sizeof(*new)); in bond_get_stats()
4745 struct slave *slave; in bond_set_rx_mode() local
4749 slave = rcu_dereference(bond->curr_active_slave); in bond_set_rx_mode()
4750 if (slave) { in bond_set_rx_mode()
4751 dev_uc_sync(slave->dev, bond_dev); in bond_set_rx_mode()
4752 dev_mc_sync(slave->dev, bond_dev); in bond_set_rx_mode()
4755 bond_for_each_slave_rcu(bond, slave, iter) { in bond_set_rx_mode()
4756 dev_uc_sync_multiple(slave->dev, bond_dev); in bond_set_rx_mode()
4757 dev_mc_sync_multiple(slave->dev, bond_dev); in bond_set_rx_mode()
4768 struct slave *slave; in bond_neigh_init() local
4772 slave = bond_first_slave_rcu(bond); in bond_neigh_init()
4773 if (!slave) in bond_neigh_init()
4775 slave_ops = slave->dev->netdev_ops; in bond_neigh_init()
4788 ret = slave_ops->ndo_neigh_setup(slave->dev, &parms); in bond_neigh_init()
4822 struct slave *slave, *rollback_slave; in bond_change_mtu() local
4828 bond_for_each_slave(bond, slave, iter) { in bond_change_mtu()
4829 slave_dbg(bond_dev, slave->dev, "s %p c_m %p\n", in bond_change_mtu()
4830 slave, slave->dev->netdev_ops->ndo_change_mtu); in bond_change_mtu()
4832 res = dev_set_mtu(slave->dev, new_mtu); in bond_change_mtu()
4843 slave_dbg(bond_dev, slave->dev, "err %d setting mtu to %d\n", in bond_change_mtu()
4858 if (rollback_slave == slave) in bond_change_mtu()
4879 struct slave *slave, *rollback_slave; in bond_set_mac_address() local
4900 bond_for_each_slave(bond, slave, iter) { in bond_set_mac_address()
4901 slave_dbg(bond_dev, slave->dev, "%s: slave=%p\n", in bond_set_mac_address()
4902 __func__, slave); in bond_set_mac_address()
4903 res = dev_set_mac_address(slave->dev, addr, NULL); in bond_set_mac_address()
4911 slave_dbg(bond_dev, slave->dev, "%s: err %d\n", in bond_set_mac_address()
4929 if (rollback_slave == slave) in bond_set_mac_address()
4951 static struct slave *bond_get_slave_by_id(struct bonding *bond, in bond_get_slave_by_id()
4955 struct slave *slave; in bond_get_slave_by_id() local
4959 bond_for_each_slave_rcu(bond, slave, iter) { in bond_get_slave_by_id()
4961 if (bond_slave_can_tx(slave)) in bond_get_slave_by_id()
4962 return slave; in bond_get_slave_by_id()
4968 bond_for_each_slave_rcu(bond, slave, iter) { in bond_get_slave_by_id()
4971 if (bond_slave_can_tx(slave)) in bond_get_slave_by_id()
4972 return slave; in bond_get_slave_by_id()
5011 static struct slave *bond_xmit_roundrobin_slave_get(struct bonding *bond, in bond_xmit_roundrobin_slave_get()
5014 struct slave *slave; in bond_xmit_roundrobin_slave_get() local
5033 slave = rcu_dereference(bond->curr_active_slave); in bond_xmit_roundrobin_slave_get()
5034 if (slave) in bond_xmit_roundrobin_slave_get()
5035 return slave; in bond_xmit_roundrobin_slave_get()
5049 static struct slave *bond_xdp_xmit_roundrobin_slave_get(struct bonding *bond, in bond_xdp_xmit_roundrobin_slave_get()
5052 struct slave *slave; in bond_xdp_xmit_roundrobin_slave_get() local
5074 slave = rcu_dereference(bond->curr_active_slave); in bond_xdp_xmit_roundrobin_slave_get()
5075 if (slave) in bond_xdp_xmit_roundrobin_slave_get()
5076 return slave; in bond_xdp_xmit_roundrobin_slave_get()
5094 struct slave *slave; in bond_xmit_roundrobin() local
5096 slave = bond_xmit_roundrobin_slave_get(bond, skb); in bond_xmit_roundrobin()
5097 if (likely(slave)) in bond_xmit_roundrobin()
5098 return bond_dev_queue_xmit(bond, skb, slave->dev); in bond_xmit_roundrobin()
5103 static struct slave *bond_xmit_activebackup_slave_get(struct bonding *bond) in bond_xmit_activebackup_slave_get()
5115 struct slave *slave; in bond_xmit_activebackup() local
5117 slave = bond_xmit_activebackup_slave_get(bond); in bond_xmit_activebackup()
5118 if (slave) in bond_xmit_activebackup()
5119 return bond_dev_queue_xmit(bond, skb, slave->dev); in bond_xmit_activebackup()
5156 struct slave *skipslave) in bond_skip_slave()
5206 int bond_update_slave_arr(struct bonding *bond, struct slave *skipslave) in bond_update_slave_arr()
5209 struct slave *slave; in bond_update_slave_arr() local
5240 bond_for_each_slave(bond, slave, iter) { in bond_update_slave_arr()
5241 if (skipslave == slave) in bond_update_slave_arr()
5244 all_slaves->arr[all_slaves->count++] = slave; in bond_update_slave_arr()
5248 agg = SLAVE_AD_INFO(slave)->port.aggregator; in bond_update_slave_arr()
5252 if (!bond_slave_can_tx(slave)) in bond_update_slave_arr()
5255 slave_dbg(bond->dev, slave->dev, "Adding slave to tx hash array[%d]\n", in bond_update_slave_arr()
5258 usable_slaves->arr[usable_slaves->count++] = slave; in bond_update_slave_arr()
5276 static struct slave *bond_xmit_3ad_xor_slave_get(struct bonding *bond, in bond_xmit_3ad_xor_slave_get()
5280 struct slave *slave; in bond_xmit_3ad_xor_slave_get() local
5289 slave = slaves->arr[hash % count]; in bond_xmit_3ad_xor_slave_get()
5290 return slave; in bond_xmit_3ad_xor_slave_get()
5293 static struct slave *bond_xdp_xmit_3ad_xor_slave_get(struct bonding *bond, in bond_xdp_xmit_3ad_xor_slave_get()
5318 struct slave *slave; in bond_3ad_xor_xmit() local
5321 slave = bond_xmit_3ad_xor_slave_get(bond, skb, slaves); in bond_3ad_xor_xmit()
5322 if (likely(slave)) in bond_3ad_xor_xmit()
5323 return bond_dev_queue_xmit(bond, skb, slave->dev); in bond_3ad_xor_xmit()
5333 struct slave *slave = NULL; in bond_xmit_broadcast() local
5338 bond_for_each_slave_rcu(bond, slave, iter) { in bond_xmit_broadcast()
5341 if (!(bond_slave_is_up(slave) && slave->link == BOND_LINK_UP)) in bond_xmit_broadcast()
5344 if (bond_is_last_slave(bond, slave)) { in bond_xmit_broadcast()
5356 if (bond_dev_queue_xmit(bond, skb2, slave->dev) == NETDEV_TX_OK) in bond_xmit_broadcast()
5376 struct slave *slave = NULL; in bond_slave_override() local
5383 bond_for_each_slave_rcu(bond, slave, iter) { in bond_slave_override()
5384 if (READ_ONCE(slave->queue_id) == skb_get_queue_mapping(skb)) { in bond_slave_override()
5385 if (bond_slave_is_up(slave) && in bond_slave_override()
5386 slave->link == BOND_LINK_UP) { in bond_slave_override()
5387 bond_dev_queue_xmit(bond, skb, slave->dev); in bond_slave_override()
5426 struct slave *slave = NULL; in bond_xmit_get_slave() local
5430 slave = bond_xmit_roundrobin_slave_get(bond, skb); in bond_xmit_get_slave()
5433 slave = bond_xmit_activebackup_slave_get(bond); in bond_xmit_get_slave()
5441 slave = bond_xmit_3ad_xor_slave_get(bond, skb, slaves); in bond_xmit_get_slave()
5446 slave = bond_xmit_alb_slave_get(bond, skb); in bond_xmit_get_slave()
5449 slave = bond_xmit_tlb_slave_get(bond, skb); in bond_xmit_get_slave()
5457 if (slave) in bond_xmit_get_slave()
5458 return slave->dev; in bond_xmit_get_slave()
5512 struct slave *slave; in __bond_sk_get_lower_dev() local
5522 slave = slaves->arr[hash % count]; in __bond_sk_get_lower_dev()
5524 return slave->dev; in __bond_sk_get_lower_dev()
5617 struct slave *slave; in bond_xdp_get_xmit_slave() local
5623 slave = bond_xdp_xmit_roundrobin_slave_get(bond, xdp); in bond_xdp_get_xmit_slave()
5627 slave = bond_xmit_activebackup_slave_get(bond); in bond_xdp_get_xmit_slave()
5632 slave = bond_xdp_xmit_3ad_xor_slave_get(bond, xdp); in bond_xdp_get_xmit_slave()
5642 if (slave) in bond_xdp_get_xmit_slave()
5643 return slave->dev; in bond_xdp_get_xmit_slave()
5690 struct slave *slave, *rollback_slave; in bond_xdp_set() local
5711 bond_for_each_slave(bond, slave, iter) { in bond_xdp_set()
5712 struct net_device *slave_dev = slave->dev; in bond_xdp_set()
5758 if (slave == rollback_slave) in bond_xdp_set()
5781 static u32 bond_mode_bcast_speed(struct slave *slave, u32 speed) in bond_mode_bcast_speed() argument
5784 speed = slave->speed; in bond_mode_bcast_speed()
5786 speed = min(speed, slave->speed); in bond_mode_bcast_speed()
5857 struct slave *slave; in bond_ethtool_get_link_ksettings() local
5868 bond_for_each_slave(bond, slave, iter) { in bond_ethtool_get_link_ksettings()
5869 if (bond_slave_can_tx(slave)) { in bond_ethtool_get_link_ksettings()
5870 bond_update_speed_duplex(slave); in bond_ethtool_get_link_ksettings()
5871 if (slave->speed != SPEED_UNKNOWN) { in bond_ethtool_get_link_ksettings()
5873 speed = bond_mode_bcast_speed(slave, in bond_ethtool_get_link_ksettings()
5876 speed += slave->speed; in bond_ethtool_get_link_ksettings()
5879 slave->duplex != DUPLEX_UNKNOWN) in bond_ethtool_get_link_ksettings()
5880 cmd->base.duplex = slave->duplex; in bond_ethtool_get_link_ksettings()
5904 struct slave *slave; in bond_ethtool_get_ts_info() local
5917 bond_for_each_slave_rcu(bond, slave, iter) { in bond_ethtool_get_ts_info()
5918 ret = ethtool_get_ts_info_by_layer(slave->dev, &ts_info); in bond_ethtool_get_ts_info()
6065 struct slave *slave; in bond_uninit() local
6070 bond_for_each_slave(bond, slave, iter) in bond_uninit()
6071 __bond_release_one(bond_dev, slave->dev, true, true); in bond_uninit()