Lines Matching +full:mii +full:- +full:rt

1 // SPDX-License-Identifier: GPL-1.0+
72 #include <linux/mii.h>
97 /*---------------------------- Module parameters ----------------------------*/
144 MODULE_PARM_DESC(use_carrier, "Use netif_carrier_ok (vs MII ioctls) in miimon; "
147 MODULE_PARM_DESC(mode, "Mode of operation; 0 for balance-rr, "
148 "1 for active-backup, 2 for balance-xor, "
149 "3 for broadcast, 4 for 802.3ad, 5 for balance-tlb, "
150 "6 for balance-alb");
172 MODULE_PARM_DESC(xmit_hash_policy, "balance-alb, balance-tlb, balance-xor, 802.3ad hashing method; "
187 MODULE_PARM_DESC(fail_over_mac, "For active-backup, do not set all slaves to "
198 MODULE_PARM_DESC(packets_per_slave, "Packets to send per slave in balance-rr "
206 /*----------------------------- Global variables ----------------------------*/
259 /*-------------------------- Forward declarations ---------------------------*/
270 /*---------------------------- General routines -----------------------------*/
275 [BOND_MODE_ROUNDROBIN] = "load balancing (round-robin)", in bond_mode_name()
276 [BOND_MODE_ACTIVEBACKUP] = "fault-tolerance (active-backup)", in bond_mode_name()
278 [BOND_MODE_BROADCAST] = "fault-tolerance (broadcast)", in bond_mode_name()
291 * bond_dev_queue_xmit - Prepare skb for xmit.
300 skb->dev = slave_dev; in bond_dev_queue_xmit()
302 BUILD_BUG_ON(sizeof(skb->queue_mapping) != in bond_dev_queue_xmit()
303 sizeof(qdisc_skb_cb(skb)->slave_dev_queue_mapping)); in bond_dev_queue_xmit()
304 skb_set_queue_mapping(skb, qdisc_skb_cb(skb)->slave_dev_queue_mapping); in bond_dev_queue_xmit()
306 if (unlikely(netpoll_tx_running(bond->dev))) in bond_dev_queue_xmit()
317 if (bond->params.xmit_policy == BOND_XMIT_POLICY_LAYER34) in bond_sk_check()
336 if (bond->params.xmit_policy != BOND_XMIT_POLICY_VLAN_SRCMAC) in bond_xdp_check()
344 /*---------------------------------- VLAN -----------------------------------*/
363 * bond_vlan_rx_add_vid - Propagates adding an id to slaves
377 res = vlan_vid_add(slave->dev, proto, vid); in bond_vlan_rx_add_vid()
390 vlan_vid_del(rollback_slave->dev, proto, vid); in bond_vlan_rx_add_vid()
397 * bond_vlan_rx_kill_vid - Propagates deleting an id to slaves
410 vlan_vid_del(slave->dev, proto, vid); in bond_vlan_rx_kill_vid()
418 /*---------------------------------- XFRM -----------------------------------*/
422 * bond_ipsec_add_sa - program device with a security association
429 struct net_device *bond_dev = xs->xso.dev; in bond_ipsec_add_sa()
438 return -EINVAL; in bond_ipsec_add_sa()
442 slave = rcu_dereference(bond->curr_active_slave); in bond_ipsec_add_sa()
443 real_dev = slave ? slave->dev : NULL; in bond_ipsec_add_sa()
447 err = -ENODEV; in bond_ipsec_add_sa()
451 if (!real_dev->xfrmdev_ops || in bond_ipsec_add_sa()
452 !real_dev->xfrmdev_ops->xdo_dev_state_add || in bond_ipsec_add_sa()
455 err = -EINVAL; in bond_ipsec_add_sa()
461 err = -ENOMEM; in bond_ipsec_add_sa()
465 xs->xso.real_dev = real_dev; in bond_ipsec_add_sa()
466 err = real_dev->xfrmdev_ops->xdo_dev_state_add(xs, extack); in bond_ipsec_add_sa()
468 ipsec->xs = xs; in bond_ipsec_add_sa()
469 INIT_LIST_HEAD(&ipsec->list); in bond_ipsec_add_sa()
470 mutex_lock(&bond->ipsec_lock); in bond_ipsec_add_sa()
471 list_add(&ipsec->list, &bond->ipsec_list); in bond_ipsec_add_sa()
472 mutex_unlock(&bond->ipsec_lock); in bond_ipsec_add_sa()
483 struct net_device *bond_dev = bond->dev; in bond_ipsec_add_sa_all()
488 slave = rtnl_dereference(bond->curr_active_slave); in bond_ipsec_add_sa_all()
489 real_dev = slave ? slave->dev : NULL; in bond_ipsec_add_sa_all()
493 mutex_lock(&bond->ipsec_lock); in bond_ipsec_add_sa_all()
494 if (!real_dev->xfrmdev_ops || in bond_ipsec_add_sa_all()
495 !real_dev->xfrmdev_ops->xdo_dev_state_add || in bond_ipsec_add_sa_all()
497 if (!list_empty(&bond->ipsec_list)) in bond_ipsec_add_sa_all()
504 list_for_each_entry(ipsec, &bond->ipsec_list, list) { in bond_ipsec_add_sa_all()
506 if (ipsec->xs->xso.real_dev == real_dev) in bond_ipsec_add_sa_all()
509 ipsec->xs->xso.real_dev = real_dev; in bond_ipsec_add_sa_all()
510 if (real_dev->xfrmdev_ops->xdo_dev_state_add(ipsec->xs, NULL)) { in bond_ipsec_add_sa_all()
512 ipsec->xs->xso.real_dev = NULL; in bond_ipsec_add_sa_all()
516 mutex_unlock(&bond->ipsec_lock); in bond_ipsec_add_sa_all()
520 * bond_ipsec_del_sa - clear out this specific SA
525 struct net_device *bond_dev = xs->xso.dev; in bond_ipsec_del_sa()
537 slave = rcu_dereference(bond->curr_active_slave); in bond_ipsec_del_sa()
538 real_dev = slave ? slave->dev : NULL; in bond_ipsec_del_sa()
545 if (!xs->xso.real_dev) in bond_ipsec_del_sa()
548 WARN_ON(xs->xso.real_dev != real_dev); in bond_ipsec_del_sa()
550 if (!real_dev->xfrmdev_ops || in bond_ipsec_del_sa()
551 !real_dev->xfrmdev_ops->xdo_dev_state_delete || in bond_ipsec_del_sa()
557 real_dev->xfrmdev_ops->xdo_dev_state_delete(xs); in bond_ipsec_del_sa()
560 mutex_lock(&bond->ipsec_lock); in bond_ipsec_del_sa()
561 list_for_each_entry(ipsec, &bond->ipsec_list, list) { in bond_ipsec_del_sa()
562 if (ipsec->xs == xs) { in bond_ipsec_del_sa()
563 list_del(&ipsec->list); in bond_ipsec_del_sa()
568 mutex_unlock(&bond->ipsec_lock); in bond_ipsec_del_sa()
573 struct net_device *bond_dev = bond->dev; in bond_ipsec_del_sa_all()
578 slave = rtnl_dereference(bond->curr_active_slave); in bond_ipsec_del_sa_all()
579 real_dev = slave ? slave->dev : NULL; in bond_ipsec_del_sa_all()
583 mutex_lock(&bond->ipsec_lock); in bond_ipsec_del_sa_all()
584 list_for_each_entry(ipsec, &bond->ipsec_list, list) { in bond_ipsec_del_sa_all()
585 if (!ipsec->xs->xso.real_dev) in bond_ipsec_del_sa_all()
588 if (!real_dev->xfrmdev_ops || in bond_ipsec_del_sa_all()
589 !real_dev->xfrmdev_ops->xdo_dev_state_delete || in bond_ipsec_del_sa_all()
595 real_dev->xfrmdev_ops->xdo_dev_state_delete(ipsec->xs); in bond_ipsec_del_sa_all()
596 if (real_dev->xfrmdev_ops->xdo_dev_state_free) in bond_ipsec_del_sa_all()
597 real_dev->xfrmdev_ops->xdo_dev_state_free(ipsec->xs); in bond_ipsec_del_sa_all()
600 mutex_unlock(&bond->ipsec_lock); in bond_ipsec_del_sa_all()
605 struct net_device *bond_dev = xs->xso.dev; in bond_ipsec_free_sa()
616 slave = rcu_dereference(bond->curr_active_slave); in bond_ipsec_free_sa()
617 real_dev = slave ? slave->dev : NULL; in bond_ipsec_free_sa()
624 if (!xs->xso.real_dev) in bond_ipsec_free_sa()
627 WARN_ON(xs->xso.real_dev != real_dev); in bond_ipsec_free_sa()
629 if (real_dev && real_dev->xfrmdev_ops && in bond_ipsec_free_sa()
630 real_dev->xfrmdev_ops->xdo_dev_state_free) in bond_ipsec_free_sa()
631 real_dev->xfrmdev_ops->xdo_dev_state_free(xs); in bond_ipsec_free_sa()
637 * bond_ipsec_offload_ok - can this packet use the xfrm hw offload
643 struct net_device *bond_dev = xs->xso.dev; in bond_ipsec_offload_ok()
651 curr_active = rcu_dereference(bond->curr_active_slave); in bond_ipsec_offload_ok()
654 real_dev = curr_active->dev; in bond_ipsec_offload_ok()
659 if (!xs->xso.real_dev) in bond_ipsec_offload_ok()
662 if (!real_dev->xfrmdev_ops || in bond_ipsec_offload_ok()
663 !real_dev->xfrmdev_ops->xdo_dev_offload_ok || in bond_ipsec_offload_ok()
667 ok = real_dev->xfrmdev_ops->xdo_dev_offload_ok(skb, xs); in bond_ipsec_offload_ok()
681 /*------------------------------- Link status -------------------------------*/
701 if (slave->link == BOND_LINK_UP) { in bond_set_carrier()
702 if (!netif_carrier_ok(bond->dev)) { in bond_set_carrier()
703 netif_carrier_on(bond->dev); in bond_set_carrier()
711 if (netif_carrier_ok(bond->dev)) { in bond_set_carrier()
712 netif_carrier_off(bond->dev); in bond_set_carrier()
720 * values are invalid, set speed and duplex to -1,
726 struct net_device *slave_dev = slave->dev; in bond_update_speed_duplex()
730 slave->speed = SPEED_UNKNOWN; in bond_update_speed_duplex()
731 slave->duplex = DUPLEX_UNKNOWN; in bond_update_speed_duplex()
736 if (ecmd.base.speed == 0 || ecmd.base.speed == ((__u32)-1)) in bond_update_speed_duplex()
746 slave->speed = ecmd.base.speed; in bond_update_speed_duplex()
747 slave->duplex = ecmd.base.duplex; in bond_update_speed_duplex()
768 /* if <dev> supports MII link status reporting, check its link status.
770 * We either do MII/ETHTOOL ioctls, or check netif_carrier_ok(),
777 * If reporting is non-zero, instead of faking link up, return -1 if
778 * both ETHTOOL and MII ioctls fail (meaning the device does not
786 const struct net_device_ops *slave_ops = slave_dev->netdev_ops; in bond_check_dev_link()
789 struct mii_ioctl_data *mii; in bond_check_dev_link() local
794 if (bond->params.use_carrier) in bond_check_dev_link()
798 if (slave_dev->ethtool_ops->get_link) in bond_check_dev_link()
799 return slave_dev->ethtool_ops->get_link(slave_dev) ? in bond_check_dev_link()
802 /* Ethtool can't be used, fallback to MII ioctls. */ in bond_check_dev_link()
803 ioctl = slave_ops->ndo_eth_ioctl; in bond_check_dev_link()
817 /* Yes, the mii is overlaid on the ifreq.ifr_ifru */ in bond_check_dev_link()
818 strscpy_pad(ifr.ifr_name, slave_dev->name, IFNAMSIZ); in bond_check_dev_link()
819 mii = if_mii(&ifr); in bond_check_dev_link()
821 mii->reg_num = MII_BMSR; in bond_check_dev_link()
823 return mii->val_out & BMSR_LSTATUS; in bond_check_dev_link()
832 return reporting ? -1 : BMSR_LSTATUS; in bond_check_dev_link()
835 /*----------------------------- Multicast list ------------------------------*/
844 struct slave *curr_active = rtnl_dereference(bond->curr_active_slave); in bond_set_promiscuity()
847 err = dev_set_promiscuity(curr_active->dev, inc); in bond_set_promiscuity()
852 err = dev_set_promiscuity(slave->dev, inc); in bond_set_promiscuity()
867 struct slave *curr_active = rtnl_dereference(bond->curr_active_slave); in bond_set_allmulti()
870 err = dev_set_allmulti(curr_active->dev, inc); in bond_set_allmulti()
875 err = dev_set_allmulti(slave->dev, inc); in bond_set_allmulti()
893 queue_delayed_work(bond->wq, &bond->mcast_work, 1); in bond_resend_igmp_join_requests_delayed()
896 call_netdevice_notifiers(NETDEV_RESEND_IGMP, bond->dev); in bond_resend_igmp_join_requests_delayed()
898 if (bond->igmp_retrans > 1) { in bond_resend_igmp_join_requests_delayed()
899 bond->igmp_retrans--; in bond_resend_igmp_join_requests_delayed()
900 queue_delayed_work(bond->wq, &bond->mcast_work, HZ/5); in bond_resend_igmp_join_requests_delayed()
918 /*--------------------------- Active slave change ---------------------------*/
929 if (bond->dev->flags & IFF_PROMISC) in bond_hw_addr_swap()
930 dev_set_promiscuity(old_active->dev, -1); in bond_hw_addr_swap()
932 if (bond->dev->flags & IFF_ALLMULTI) in bond_hw_addr_swap()
933 dev_set_allmulti(old_active->dev, -1); in bond_hw_addr_swap()
935 if (bond->dev->flags & IFF_UP) in bond_hw_addr_swap()
936 bond_hw_addr_flush(bond->dev, old_active->dev); in bond_hw_addr_swap()
943 if (bond->dev->flags & IFF_PROMISC) in bond_hw_addr_swap()
944 dev_set_promiscuity(new_active->dev, 1); in bond_hw_addr_swap()
946 if (bond->dev->flags & IFF_ALLMULTI) in bond_hw_addr_swap()
947 dev_set_allmulti(new_active->dev, 1); in bond_hw_addr_swap()
949 if (bond->dev->flags & IFF_UP) { in bond_hw_addr_swap()
950 netif_addr_lock_bh(bond->dev); in bond_hw_addr_swap()
951 dev_uc_sync(new_active->dev, bond->dev); in bond_hw_addr_swap()
952 dev_mc_sync(new_active->dev, bond->dev); in bond_hw_addr_swap()
953 netif_addr_unlock_bh(bond->dev); in bond_hw_addr_swap()
961 * bond_set_dev_addr - clone slave's address to bond
972 slave_dbg(bond_dev, slave_dev, "bond_dev=%p slave_dev=%p slave_dev->addr_len=%d\n", in bond_set_dev_addr()
973 bond_dev, slave_dev, slave_dev->addr_len); in bond_set_dev_addr()
974 err = dev_pre_changeaddr_notify(bond_dev, slave_dev->dev_addr, NULL); in bond_set_dev_addr()
978 __dev_addr_set(bond_dev, slave_dev->dev_addr, slave_dev->addr_len); in bond_set_dev_addr()
979 bond_dev->addr_assign_type = NET_ADDR_STOLEN; in bond_set_dev_addr()
994 if (ether_addr_equal(bond->dev->dev_addr, slave->dev->dev_addr)) in bond_get_old_active()
1015 switch (bond->params.fail_over_mac) { in bond_do_fail_over_mac()
1018 rv = bond_set_dev_addr(bond->dev, new_active->dev); in bond_do_fail_over_mac()
1020 slave_err(bond->dev, new_active->dev, "Error %d setting bond MAC from slave\n", in bond_do_fail_over_mac()
1021 -rv); in bond_do_fail_over_mac()
1036 bond_hw_addr_copy(tmp_mac, new_active->dev->dev_addr, in bond_do_fail_over_mac()
1037 new_active->dev->addr_len); in bond_do_fail_over_mac()
1039 old_active->dev->dev_addr, in bond_do_fail_over_mac()
1040 old_active->dev->addr_len); in bond_do_fail_over_mac()
1041 ss.ss_family = new_active->dev->type; in bond_do_fail_over_mac()
1043 bond_hw_addr_copy(ss.__data, bond->dev->dev_addr, in bond_do_fail_over_mac()
1044 bond->dev->addr_len); in bond_do_fail_over_mac()
1045 ss.ss_family = bond->dev->type; in bond_do_fail_over_mac()
1048 rv = dev_set_mac_address(new_active->dev, in bond_do_fail_over_mac()
1051 slave_err(bond->dev, new_active->dev, "Error %d setting MAC of new active slave\n", in bond_do_fail_over_mac()
1052 -rv); in bond_do_fail_over_mac()
1060 new_active->dev->addr_len); in bond_do_fail_over_mac()
1061 ss.ss_family = old_active->dev->type; in bond_do_fail_over_mac()
1063 rv = dev_set_mac_address(old_active->dev, in bond_do_fail_over_mac()
1066 slave_err(bond->dev, old_active->dev, "Error %d setting MAC of old active slave\n", in bond_do_fail_over_mac()
1067 -rv); in bond_do_fail_over_mac()
1071 netdev_err(bond->dev, "bond_do_fail_over_mac impossible: bad policy %d\n", in bond_do_fail_over_mac()
1072 bond->params.fail_over_mac); in bond_do_fail_over_mac()
1079 * bond_choose_primary_or_current - select the primary or high priority slave
1082 * - Check if there is a primary link. If the primary link was set and is up,
1085 * - If primary link is not set or down, find the highest priority link.
1091 struct slave *prim = rtnl_dereference(bond->primary_slave); in bond_choose_primary_or_current()
1092 struct slave *curr = rtnl_dereference(bond->curr_active_slave); in bond_choose_primary_or_current()
1096 if (!prim || prim->link != BOND_LINK_UP) { in bond_choose_primary_or_current()
1098 if (slave->link == BOND_LINK_UP) { in bond_choose_primary_or_current()
1100 if (slave->prio > hprio->prio) in bond_choose_primary_or_current()
1110 if (!curr || curr->link != BOND_LINK_UP) in bond_choose_primary_or_current()
1115 if (bond->force_primary) { in bond_choose_primary_or_current()
1116 bond->force_primary = false; in bond_choose_primary_or_current()
1121 if (!curr || curr->link != BOND_LINK_UP) in bond_choose_primary_or_current()
1125 switch (bond->params.primary_reselect) { in bond_choose_primary_or_current()
1129 if (prim->speed < curr->speed) in bond_choose_primary_or_current()
1131 if (prim->speed == curr->speed && prim->duplex <= curr->duplex) in bond_choose_primary_or_current()
1137 netdev_err(bond->dev, "impossible primary_reselect %d\n", in bond_choose_primary_or_current()
1138 bond->params.primary_reselect); in bond_choose_primary_or_current()
1144 * bond_find_best_slave - select the best available slave to be the active one
1151 int mintime = bond->params.updelay; in bond_find_best_slave()
1158 if (slave->link == BOND_LINK_UP) in bond_find_best_slave()
1160 if (slave->link == BOND_LINK_BACK && bond_slave_is_up(slave) && in bond_find_best_slave()
1161 slave->delay < mintime) { in bond_find_best_slave()
1162 mintime = slave->delay; in bond_find_best_slave()
1173 struct slave *slave = rcu_dereference_rtnl(bond->curr_active_slave); in bond_should_notify_peers()
1175 if (!slave || !bond->send_peer_notif || in bond_should_notify_peers()
1176 bond->send_peer_notif % in bond_should_notify_peers()
1177 max(1, bond->params.peer_notif_delay) != 0 || in bond_should_notify_peers()
1178 !netif_carrier_ok(bond->dev) || in bond_should_notify_peers()
1179 test_bit(__LINK_STATE_LINKWATCH_PENDING, &slave->dev->state)) in bond_should_notify_peers()
1182 netdev_dbg(bond->dev, "bond_should_notify_peers: slave %s\n", in bond_should_notify_peers()
1183 slave ? slave->dev->name : "NULL"); in bond_should_notify_peers()
1189 * bond_change_active_slave - change the active slave into the specified one
1195 * Setting include flags, mc-list, promiscuity, allmulti, etc.
1209 old_active = rtnl_dereference(bond->curr_active_slave); in bond_change_active_slave()
1219 new_active->last_link_up = jiffies; in bond_change_active_slave()
1221 if (new_active->link == BOND_LINK_BACK) { in bond_change_active_slave()
1223 slave_info(bond->dev, new_active->dev, "making interface the new active one %d ms earlier\n", in bond_change_active_slave()
1224 (bond->params.updelay - new_active->delay) * bond->params.miimon); in bond_change_active_slave()
1227 new_active->delay = 0; in bond_change_active_slave()
1238 slave_info(bond->dev, new_active->dev, "making interface the new active one\n"); in bond_change_active_slave()
1254 rcu_assign_pointer(bond->curr_active_slave, new_active); in bond_change_active_slave()
1268 if (bond->params.fail_over_mac) in bond_change_active_slave()
1272 if (netif_running(bond->dev)) { in bond_change_active_slave()
1273 bond->send_peer_notif = in bond_change_active_slave()
1274 bond->params.num_peer_notif * in bond_change_active_slave()
1275 max(1, bond->params.peer_notif_delay); in bond_change_active_slave()
1280 call_netdevice_notifiers(NETDEV_BONDING_FAILOVER, bond->dev); in bond_change_active_slave()
1282 bond->send_peer_notif--; in bond_change_active_slave()
1284 bond->dev); in bond_change_active_slave()
1298 if (netif_running(bond->dev) && (bond->params.resend_igmp > 0) && in bond_change_active_slave()
1301 bond->igmp_retrans = bond->params.resend_igmp; in bond_change_active_slave()
1302 queue_delayed_work(bond->wq, &bond->mcast_work, 1); in bond_change_active_slave()
1307 * bond_select_active_slave - select a new active slave, if needed
1311 * - The old curr_active_slave has been released or lost its link.
1312 * - The primary_slave has got its link back.
1313 * - A slave has got its link back and there's no old curr_active_slave.
1325 if (best_slave != rtnl_dereference(bond->curr_active_slave)) { in bond_select_active_slave()
1331 if (netif_carrier_ok(bond->dev)) in bond_select_active_slave()
1332 netdev_info(bond->dev, "active interface up!\n"); in bond_select_active_slave()
1334 netdev_info(bond->dev, "now running without any active interface!\n"); in bond_select_active_slave()
1345 err = -ENOMEM; in slave_enable_netpoll()
1349 err = __netpoll_setup(np, slave->dev); in slave_enable_netpoll()
1354 slave->np = np; in slave_enable_netpoll()
1360 struct netpoll *np = slave->np; in slave_disable_netpoll()
1365 slave->np = NULL; in slave_disable_netpoll()
1387 SLAVE_AD_INFO(slave)->port.aggregator; in bond_poll_controller()
1390 agg->aggregator_identifier != ad_info.aggregator_id) in bond_poll_controller()
1394 netpoll_poll_dev(slave->dev); in bond_poll_controller()
1438 /*---------------------------------- IOCTL ----------------------------------*/
1455 slave->dev->features, in bond_fix_features()
1485 struct net_device *bond_dev = bond->dev; in bond_compute_features()
1499 slave->dev->vlan_features, BOND_VLAN_FEATURES); in bond_compute_features()
1502 slave->dev->hw_enc_features, in bond_compute_features()
1507 slave->dev->hw_enc_features, in bond_compute_features()
1512 slave->dev->mpls_features, in bond_compute_features()
1515 dst_release_flag &= slave->dev->priv_flags; in bond_compute_features()
1516 if (slave->dev->hard_header_len > max_hard_header_len) in bond_compute_features()
1517 max_hard_header_len = slave->dev->hard_header_len; in bond_compute_features()
1519 tso_max_size = min(tso_max_size, slave->dev->tso_max_size); in bond_compute_features()
1520 tso_max_segs = min(tso_max_segs, slave->dev->tso_max_segs); in bond_compute_features()
1522 bond_dev->hard_header_len = max_hard_header_len; in bond_compute_features()
1525 bond_dev->vlan_features = vlan_features; in bond_compute_features()
1526 bond_dev->hw_enc_features = enc_features | NETIF_F_GSO_ENCAP_ALL | in bond_compute_features()
1530 bond_dev->hw_enc_features |= xfrm_features; in bond_compute_features()
1532 bond_dev->mpls_features = mpls_features; in bond_compute_features()
1536 bond_dev->priv_flags &= ~IFF_XMIT_DST_RELEASE; in bond_compute_features()
1537 if ((bond_dev->priv_flags & IFF_XMIT_DST_RELEASE_PERM) && in bond_compute_features()
1539 bond_dev->priv_flags |= IFF_XMIT_DST_RELEASE; in bond_compute_features()
1547 bool was_up = !!(bond_dev->flags & IFF_UP); in bond_setup_by_slave()
1551 bond_dev->header_ops = slave_dev->header_ops; in bond_setup_by_slave()
1553 bond_dev->type = slave_dev->type; in bond_setup_by_slave()
1554 bond_dev->hard_header_len = slave_dev->hard_header_len; in bond_setup_by_slave()
1555 bond_dev->needed_headroom = slave_dev->needed_headroom; in bond_setup_by_slave()
1556 bond_dev->addr_len = slave_dev->addr_len; in bond_setup_by_slave()
1558 memcpy(bond_dev->broadcast, slave_dev->broadcast, in bond_setup_by_slave()
1559 slave_dev->addr_len); in bond_setup_by_slave()
1561 if (slave_dev->flags & IFF_POINTOPOINT) { in bond_setup_by_slave()
1562 bond_dev->flags &= ~(IFF_BROADCAST | IFF_MULTICAST); in bond_setup_by_slave()
1563 bond_dev->flags |= (IFF_POINTOPOINT | IFF_NOARP); in bond_setup_by_slave()
1570 * duplicates except for alb non-mcast/bcast.
1578 skb->pkt_type != PACKET_BROADCAST && in bond_should_deliver_exact_match()
1579 skb->pkt_type != PACKET_MULTICAST) in bond_should_deliver_exact_match()
1601 slave = bond_slave_get_rcu(skb->dev); in bond_handle_frame()
1602 bond = slave->bond; in bond_handle_frame()
1604 recv_probe = READ_ONCE(bond->recv_probe); in bond_handle_frame()
1615 * be suppressed we want to make an exception for link-local packets. in bond_handle_frame()
1621 * (including link-local ones) can have their originating interface in bond_handle_frame()
1625 if (is_link_local_ether_addr(eth_hdr(skb)->h_dest)) in bond_handle_frame()
1630 skb->dev = bond->dev; in bond_handle_frame()
1633 netif_is_bridge_port(bond->dev) && in bond_handle_frame()
1634 skb->pkt_type == PACKET_HOST) { in bond_handle_frame()
1637 skb->data - skb_mac_header(skb)))) { in bond_handle_frame()
1641 bond_hw_addr_copy(eth_hdr(skb)->h_dest, bond->dev->dev_addr, in bond_handle_frame()
1642 bond->dev->addr_len); in bond_handle_frame()
1671 switch (bond->params.xmit_policy) { in bond_lag_hash_type()
1700 err = netdev_master_upper_dev_link(slave->dev, bond->dev, slave, in bond_master_upper_dev_link()
1705 slave->dev->flags |= IFF_SLAVE; in bond_master_upper_dev_link()
1711 netdev_upper_dev_unlink(slave->dev, bond->dev); in bond_upper_dev_unlink()
1712 slave->dev->flags &= ~IFF_SLAVE; in bond_upper_dev_unlink()
1720 cancel_delayed_work_sync(&slave->notify_work); in slave_kobj_release()
1738 err = kobject_init_and_add(&slave->kobj, &slave_ktype, in bond_kobj_init()
1739 &(slave->dev->dev.kobj), "bonding_slave"); in bond_kobj_init()
1741 kobject_put(&slave->kobj); in bond_kobj_init()
1755 slave->bond = bond; in bond_alloc_slave()
1756 slave->dev = slave_dev; in bond_alloc_slave()
1757 INIT_DELAYED_WORK(&slave->notify_work, bond_netdev_notify_work); in bond_alloc_slave()
1766 kobject_put(&slave->kobj); in bond_alloc_slave()
1776 info->bond_mode = BOND_MODE(bond); in bond_fill_ifbond()
1777 info->miimon = bond->params.miimon; in bond_fill_ifbond()
1778 info->num_slaves = bond->slave_cnt; in bond_fill_ifbond()
1783 strcpy(info->slave_name, slave->dev->name); in bond_fill_ifslave()
1784 info->link = slave->link; in bond_fill_ifslave()
1785 info->state = bond_slave_state(slave); in bond_fill_ifslave()
1786 info->link_failure_count = slave->link_failure_count; in bond_fill_ifslave()
1798 bond_fill_ifbond(slave->bond, &binfo.master); in bond_netdev_notify_work()
1799 netdev_bonding_info_change(slave->dev, &binfo); in bond_netdev_notify_work()
1802 queue_delayed_work(slave->bond->wq, &slave->notify_work, 1); in bond_netdev_notify_work()
1808 queue_delayed_work(slave->bond->wq, &slave->notify_work, 0); in bond_queue_slave_event()
1815 info.link_up = slave->link == BOND_LINK_UP || in bond_lower_state_changed()
1816 slave->link == BOND_LINK_FAIL; in bond_lower_state_changed()
1818 netdev_lower_state_changed(slave->dev, &info); in bond_lower_state_changed()
1842 unsigned int flags = bond_dev->flags & (IFF_SLAVE | IFF_UP); in bond_ether_setup()
1845 bond_dev->flags |= IFF_MASTER | flags; in bond_ether_setup()
1846 bond_dev->priv_flags &= ~IFF_TX_SKB_SHARING; in bond_ether_setup()
1864 val &= slave->dev->xdp_features; in bond_xdp_set_features()
1876 const struct net_device_ops *slave_ops = slave_dev->netdev_ops; in bond_enslave()
1882 if (slave_dev->flags & IFF_MASTER && in bond_enslave()
1886 return -EPERM; in bond_enslave()
1889 if (!bond->params.use_carrier && in bond_enslave()
1890 slave_dev->ethtool_ops->get_link == NULL && in bond_enslave()
1891 slave_ops->ndo_eth_ioctl == NULL) { in bond_enslave()
1895 /* already in-use? */ in bond_enslave()
1899 return -EBUSY; in bond_enslave()
1904 return -EPERM; in bond_enslave()
1909 if (slave_dev->features & NETIF_F_VLAN_CHALLENGED) { in bond_enslave()
1914 return -EPERM; in bond_enslave()
1922 if (slave_dev->features & NETIF_F_HW_ESP) in bond_enslave()
1923 slave_dbg(bond_dev, slave_dev, "is esp-hw-offload capable\n"); in bond_enslave()
1930 if (slave_dev->flags & IFF_UP) { in bond_enslave()
1933 return -EPERM; in bond_enslave()
1936 /* set bonding device ether type by slave - bonding netdevices are in bond_enslave()
1940 * bond ether type mutual exclusion - don't allow slaves of dissimilar in bond_enslave()
1944 if (bond_dev->type != slave_dev->type) { in bond_enslave()
1946 bond_dev->type, slave_dev->type); in bond_enslave()
1953 return -EBUSY; in bond_enslave()
1960 if (slave_dev->type != ARPHRD_ETHER) in bond_enslave()
1968 } else if (bond_dev->type != slave_dev->type) { in bond_enslave()
1971 return -EINVAL; in bond_enslave()
1974 if (slave_dev->type == ARPHRD_INFINIBAND && in bond_enslave()
1977 "Only active-backup mode is supported for infiniband slaves"); in bond_enslave()
1978 res = -EOPNOTSUPP; in bond_enslave()
1982 if (!slave_ops->ndo_set_mac_address || in bond_enslave()
1983 slave_dev->type == ARPHRD_INFINIBAND) { in bond_enslave()
1986 bond->params.fail_over_mac != BOND_FOM_ACTIVE) { in bond_enslave()
1988 bond->params.fail_over_mac = BOND_FOM_ACTIVE; in bond_enslave()
1989 slave_warn(bond_dev, slave_dev, "Setting fail_over_mac to active for active-backup mode\n"); in bond_enslave()
1993 res = -EOPNOTSUPP; in bond_enslave()
2005 bond->dev->addr_assign_type == NET_ADDR_RANDOM) { in bond_enslave()
2006 res = bond_set_dev_addr(bond->dev, slave_dev); in bond_enslave()
2013 res = -ENOMEM; in bond_enslave()
2020 new_slave->queue_id = 0; in bond_enslave()
2023 new_slave->original_mtu = slave_dev->mtu; in bond_enslave()
2024 res = dev_set_mtu(slave_dev, bond->dev->mtu); in bond_enslave()
2034 bond_hw_addr_copy(new_slave->perm_hwaddr, slave_dev->dev_addr, in bond_enslave()
2035 slave_dev->addr_len); in bond_enslave()
2037 if (!bond->params.fail_over_mac || in bond_enslave()
2042 memcpy(ss.__data, bond_dev->dev_addr, bond_dev->addr_len); in bond_enslave()
2043 ss.ss_family = slave_dev->type; in bond_enslave()
2053 slave_dev->priv_flags |= IFF_NO_ADDRCONF; in bond_enslave()
2062 slave_dev->priv_flags |= IFF_BONDING; in bond_enslave()
2064 dev_get_stats(new_slave->dev, &new_slave->slave_stats); in bond_enslave()
2083 new_slave->delay = 0; in bond_enslave()
2084 new_slave->link_failure_count = 0; in bond_enslave()
2088 new_slave->link = BOND_LINK_DOWN; in bond_enslave()
2090 new_slave->last_rx = jiffies - in bond_enslave()
2091 (msecs_to_jiffies(bond->params.arp_interval) + 1); in bond_enslave()
2093 new_slave->target_last_arp_rx[i] = new_slave->last_rx; in bond_enslave()
2095 new_slave->last_tx = new_slave->last_rx; in bond_enslave()
2097 if (bond->params.miimon && !bond->params.use_carrier) { in bond_enslave()
2100 if ((link_reporting == -1) && !bond->params.arp_interval) { in bond_enslave()
2102 * does not support ETHTOOL/MII and in bond_enslave()
2109 …slave_warn(bond_dev, slave_dev, "MII and ETHTOOL support not available for slave, and arp_interval… in bond_enslave()
2110 } else if (link_reporting == -1) { in bond_enslave()
2111 /* unable get link status using mii/ethtool */ in bond_enslave()
2112 … slave; the network driver associated with this interface does not support MII or ETHTOOL link sta… in bond_enslave()
2117 new_slave->link = BOND_LINK_NOCHANGE; in bond_enslave()
2118 if (bond->params.miimon) { in bond_enslave()
2120 if (bond->params.updelay) { in bond_enslave()
2124 new_slave->delay = bond->params.updelay; in bond_enslave()
2134 } else if (bond->params.arp_interval) { in bond_enslave()
2144 if (new_slave->link != BOND_LINK_DOWN) in bond_enslave()
2145 new_slave->last_link_up = jiffies; in bond_enslave()
2147 new_slave->link == BOND_LINK_DOWN ? "DOWN" : in bond_enslave()
2148 (new_slave->link == BOND_LINK_UP ? "UP" : "BACK")); in bond_enslave()
2150 if (bond_uses_primary(bond) && bond->params.primary[0]) { in bond_enslave()
2152 if (strcmp(bond->params.primary, new_slave->dev->name) == 0) { in bond_enslave()
2153 rcu_assign_pointer(bond->primary_slave, new_slave); in bond_enslave()
2154 bond->force_primary = true; in bond_enslave()
2171 SLAVE_AD_INFO(new_slave)->id = 1; in bond_enslave()
2177 SLAVE_AD_INFO(new_slave)->id = in bond_enslave()
2178 SLAVE_AD_INFO(prev_slave)->id + 1; in bond_enslave()
2198 if (!rcu_access_pointer(bond->curr_active_slave) && in bond_enslave()
2199 new_slave->link == BOND_LINK_UP) in bond_enslave()
2200 rcu_assign_pointer(bond->curr_active_slave, new_slave); in bond_enslave()
2206 if (bond->dev->npinfo) { in bond_enslave()
2209 res = -EBUSY; in bond_enslave()
2215 if (!(bond_dev->features & NETIF_F_LRO)) in bond_enslave()
2244 if (bond_dev->flags & IFF_PROMISC) { in bond_enslave()
2251 if (bond_dev->flags & IFF_ALLMULTI) { in bond_enslave()
2254 if (bond_dev->flags & IFF_PROMISC) in bond_enslave()
2255 dev_set_promiscuity(slave_dev, -1); in bond_enslave()
2260 if (bond_dev->flags & IFF_UP) { in bond_enslave()
2271 bond->slave_cnt++; in bond_enslave()
2289 if (!slave_dev->netdev_ops->ndo_bpf || in bond_enslave()
2290 !slave_dev->netdev_ops->ndo_xdp_xmit) { in bond_enslave()
2291 if (bond->xdp_prog) { in bond_enslave()
2294 res = -EOPNOTSUPP; in bond_enslave()
2297 } else if (bond->xdp_prog) { in bond_enslave()
2301 .prog = bond->xdp_prog, in bond_enslave()
2308 res = -EOPNOTSUPP; in bond_enslave()
2312 res = slave_dev->netdev_ops->ndo_bpf(slave_dev, &xdp); in bond_enslave()
2318 if (bond->xdp_prog) in bond_enslave()
2319 bpf_prog_inc(bond->xdp_prog); in bond_enslave()
2326 new_slave->link != BOND_LINK_DOWN ? "an up" : "a down"); in bond_enslave()
2344 if (rcu_access_pointer(bond->primary_slave) == new_slave) in bond_enslave()
2345 RCU_INIT_POINTER(bond->primary_slave, NULL); in bond_enslave()
2346 if (rcu_access_pointer(bond->curr_active_slave) == new_slave) { in bond_enslave()
2358 slave_dev->priv_flags &= ~IFF_BONDING; in bond_enslave()
2362 slave_dev->priv_flags &= ~IFF_NO_ADDRCONF; in bond_enslave()
2363 if (!bond->params.fail_over_mac || in bond_enslave()
2365 /* XXX TODO - fom follow mode needs to change master's in bond_enslave()
2369 bond_hw_addr_copy(ss.__data, new_slave->perm_hwaddr, in bond_enslave()
2370 new_slave->dev->addr_len); in bond_enslave()
2371 ss.ss_family = slave_dev->type; in bond_enslave()
2376 dev_set_mtu(slave_dev, new_slave->original_mtu); in bond_enslave()
2379 kobject_put(&new_slave->kobj); in bond_enslave()
2384 if (ether_addr_equal_64bits(bond_dev->dev_addr, in bond_enslave()
2385 slave_dev->dev_addr)) in bond_enslave()
2387 if (bond_dev->type != ARPHRD_ETHER) { in bond_enslave()
2398 * is RTNL-locked. If "all" is true it means that the function is being called
2414 int old_flags = bond_dev->flags; in __bond_release_one()
2415 netdev_features_t old_features = bond_dev->features; in __bond_release_one()
2418 if (!(slave_dev->flags & IFF_SLAVE) || in __bond_release_one()
2421 return -EINVAL; in __bond_release_one()
2431 return -EINVAL; in __bond_release_one()
2439 bond_get_stats(bond->dev, &bond->bond_stats); in __bond_release_one()
2441 if (bond->xdp_prog) { in __bond_release_one()
2448 if (slave_dev->netdev_ops->ndo_bpf(slave_dev, &xdp)) in __bond_release_one()
2468 oldcurrent = rcu_access_pointer(bond->curr_active_slave); in __bond_release_one()
2470 RCU_INIT_POINTER(bond->current_arp_slave, NULL); in __bond_release_one()
2472 if (!all && (!bond->params.fail_over_mac || in __bond_release_one()
2474 if (ether_addr_equal_64bits(bond_dev->dev_addr, slave->perm_hwaddr) && in __bond_release_one()
2476 …slave_warn(bond_dev, slave_dev, "the permanent HWaddr of slave - %pM - is still in use by bond - s… in __bond_release_one()
2477 slave->perm_hwaddr); in __bond_release_one()
2480 if (rtnl_dereference(bond->primary_slave) == slave) in __bond_release_one()
2481 RCU_INIT_POINTER(bond->primary_slave, NULL); in __bond_release_one()
2502 RCU_INIT_POINTER(bond->curr_active_slave, NULL); in __bond_release_one()
2517 bond->slave_cnt--; in __bond_release_one()
2520 call_netdevice_notifiers(NETDEV_CHANGEADDR, bond->dev); in __bond_release_one()
2521 call_netdevice_notifiers(NETDEV_RELEASE, bond->dev); in __bond_release_one()
2525 if (!(bond_dev->features & NETIF_F_VLAN_CHALLENGED) && in __bond_release_one()
2527 …slave_info(bond_dev, slave_dev, "last VLAN challenged slave left bond - VLAN blocking is removed\n… in __bond_release_one()
2543 dev_set_promiscuity(slave_dev, -1); in __bond_release_one()
2547 dev_set_allmulti(slave_dev, -1); in __bond_release_one()
2558 slave_dev->priv_flags &= ~IFF_NO_ADDRCONF; in __bond_release_one()
2560 if (bond->params.fail_over_mac != BOND_FOM_ACTIVE || in __bond_release_one()
2563 bond_hw_addr_copy(ss.__data, slave->perm_hwaddr, in __bond_release_one()
2564 slave->dev->addr_len); in __bond_release_one()
2565 ss.ss_family = slave_dev->type; in __bond_release_one()
2570 __dev_set_mtu(slave_dev, slave->original_mtu); in __bond_release_one()
2572 dev_set_mtu(slave_dev, slave->original_mtu); in __bond_release_one()
2575 slave_dev->priv_flags &= ~IFF_BONDING; in __bond_release_one()
2578 kobject_put(&slave->kobj); in __bond_release_one()
2600 bond_dev->reg_state != NETREG_UNREGISTERING) { in bond_release_and_destroy()
2601 bond_dev->priv_flags |= IFF_DISABLE_NETPOLL; in bond_release_and_destroy()
2620 int i = 0, res = -ENODEV; in bond_slave_info_query()
2624 if (i++ == (int)info->slave_id) { in bond_slave_info_query()
2634 /*-------------------------------- Monitoring -------------------------------*/
2645 ignore_updelay = !rcu_dereference(bond->curr_active_slave); in bond_miimon_inspect()
2649 usable_slaves = rcu_dereference(bond->usable_slaves); in bond_miimon_inspect()
2651 if (usable_slaves && usable_slaves->count == 0) in bond_miimon_inspect()
2658 link_state = bond_check_dev_link(bond, slave->dev, 0); in bond_miimon_inspect()
2660 switch (slave->link) { in bond_miimon_inspect()
2667 slave->delay = bond->params.downdelay; in bond_miimon_inspect()
2668 if (slave->delay) { in bond_miimon_inspect()
2669 slave_info(bond->dev, slave->dev, "link status down for %sinterface, disabling it in %d ms\n", in bond_miimon_inspect()
2674 bond->params.downdelay * bond->params.miimon); in bond_miimon_inspect()
2681 slave->last_link_up = jiffies; in bond_miimon_inspect()
2682 slave_info(bond->dev, slave->dev, "link status up again after %d ms\n", in bond_miimon_inspect()
2683 (bond->params.downdelay - slave->delay) * in bond_miimon_inspect()
2684 bond->params.miimon); in bond_miimon_inspect()
2689 if (slave->delay <= 0) { in bond_miimon_inspect()
2695 slave->delay--; in bond_miimon_inspect()
2704 slave->delay = bond->params.updelay; in bond_miimon_inspect()
2706 if (slave->delay) { in bond_miimon_inspect()
2707 slave_info(bond->dev, slave->dev, "link status up, enabling it in %d ms\n", in bond_miimon_inspect()
2709 bond->params.updelay * in bond_miimon_inspect()
2710 bond->params.miimon); in bond_miimon_inspect()
2716 slave_info(bond->dev, slave->dev, "link status down again after %d ms\n", in bond_miimon_inspect()
2717 (bond->params.updelay - slave->delay) * in bond_miimon_inspect()
2718 bond->params.miimon); in bond_miimon_inspect()
2724 slave->delay = 0; in bond_miimon_inspect()
2726 if (slave->delay <= 0) { in bond_miimon_inspect()
2733 slave->delay--; in bond_miimon_inspect()
2768 switch (slave->link_new_state) { in bond_miimon_commit()
2777 slave->link == BOND_LINK_UP) in bond_miimon_commit()
2784 slave->link = BOND_LINK_DOWN; in bond_miimon_commit()
2786 slave_warn(bond->dev, slave->dev, in bond_miimon_commit()
2792 slave->last_link_up = jiffies; in bond_miimon_commit()
2794 primary = rtnl_dereference(bond->primary_slave); in bond_miimon_commit()
2803 slave_info(bond->dev, slave->dev, "link status definitely up, %u Mbps %s duplex\n", in bond_miimon_commit()
2804 slave->speed == SPEED_UNKNOWN ? 0 : slave->speed, in bond_miimon_commit()
2805 slave->duplex ? "full" : "half"); in bond_miimon_commit()
2809 active = rtnl_dereference(bond->curr_active_slave); in bond_miimon_commit()
2810 if (!active || slave == primary || slave->prio > active->prio) in bond_miimon_commit()
2816 if (slave->link_failure_count < UINT_MAX) in bond_miimon_commit()
2817 slave->link_failure_count++; in bond_miimon_commit()
2827 slave_info(bond->dev, slave->dev, "link status definitely down, disabling slave\n"); in bond_miimon_commit()
2831 if (slave == rcu_access_pointer(bond->curr_active_slave)) in bond_miimon_commit()
2837 slave_err(bond->dev, slave->dev, "invalid new link %d on slave\n", in bond_miimon_commit()
2838 slave->link_new_state); in bond_miimon_commit()
2856 * Really a wrapper that splits the mii monitor into two phases: an
2871 delay = msecs_to_jiffies(bond->params.miimon); in bond_mii_monitor()
2879 if (bond->send_peer_notif) { in bond_mii_monitor()
2882 bond->send_peer_notif--; in bond_mii_monitor()
2906 if (bond->params.miimon) in bond_mii_monitor()
2907 queue_delayed_work(bond->wq, &bond->mii_work, delay); in bond_mii_monitor()
2912 call_netdevice_notifiers(NETDEV_NOTIFY_PEERS, bond->dev); in bond_mii_monitor()
2920 __be32 ip = *(__be32 *)priv->data; in bond_upper_dev_walk()
2932 if (ip == bond_confirm_addr(bond->dev, 0, ip)) in bond_has_this_ip()
2936 if (netdev_walk_all_upper_dev_rcu(bond->dev, bond_upper_dev_walk, &priv)) in bond_has_this_ip()
2948 struct net_device *bond_dev = slave->bond->dev; in bond_handle_vlan()
2949 struct net_device *slave_dev = slave->dev; in bond_handle_vlan()
2952 if (!tags || tags->vlan_proto == BOND_VLAN_PROTO_NONE) in bond_handle_vlan()
2958 while (tags->vlan_proto != BOND_VLAN_PROTO_NONE) { in bond_handle_vlan()
2959 if (!tags->vlan_id) { in bond_handle_vlan()
2965 ntohs(outer_tag->vlan_proto), tags->vlan_id); in bond_handle_vlan()
2966 skb = vlan_insert_tag_set_proto(skb, tags->vlan_proto, in bond_handle_vlan()
2967 tags->vlan_id); in bond_handle_vlan()
2976 if (outer_tag->vlan_id) { in bond_handle_vlan()
2978 ntohs(outer_tag->vlan_proto), outer_tag->vlan_id); in bond_handle_vlan()
2979 __vlan_hwaccel_put_tag(skb, outer_tag->vlan_proto, in bond_handle_vlan()
2980 outer_tag->vlan_id); in bond_handle_vlan()
2988 * "native" to a VLAN) might not pass non-tagged frames.
2993 struct net_device *bond_dev = slave->bond->dev; in bond_arp_send()
2994 struct net_device *slave_dev = slave->dev; in bond_arp_send()
3001 NULL, slave_dev->dev_addr, NULL); in bond_arp_send()
3033 return ERR_PTR(-ENOMEM); in bond_verify_device_path()
3058 struct rtable *rt; in bond_arp_send_all() local
3060 __be32 *targets = bond->params.arp_targets, addr; in bond_arp_send_all()
3064 slave_dbg(bond->dev, slave->dev, "%s: target %pI4\n", in bond_arp_send_all()
3069 rt = ip_route_output(dev_net(bond->dev), targets[i], 0, in bond_arp_send_all()
3071 if (IS_ERR(rt)) { in bond_arp_send_all()
3072 /* there's no route to target - try to send arp in bond_arp_send_all()
3075 if (bond->params.arp_validate) in bond_arp_send_all()
3077 bond->dev->name, in bond_arp_send_all()
3085 if (rt->dst.dev == bond->dev) in bond_arp_send_all()
3089 tags = bond_verify_device_path(bond->dev, rt->dst.dev, 0); in bond_arp_send_all()
3095 /* Not our device - skip */ in bond_arp_send_all()
3096 slave_dbg(bond->dev, slave->dev, "no path to arp_ip_target %pI4 via rt.dev %s\n", in bond_arp_send_all()
3097 &targets[i], rt->dst.dev ? rt->dst.dev->name : "NULL"); in bond_arp_send_all()
3099 ip_rt_put(rt); in bond_arp_send_all()
3103 addr = bond_confirm_addr(rt->dst.dev, targets[i], 0); in bond_arp_send_all()
3104 ip_rt_put(rt); in bond_arp_send_all()
3115 slave_dbg(bond->dev, slave->dev, "%s: sip %pI4 tip %pI4 not found\n", in bond_validate_arp()
3120 i = bond_get_targets_ip(bond->params.arp_targets, sip); in bond_validate_arp()
3121 if (i == -1) { in bond_validate_arp()
3122 slave_dbg(bond->dev, slave->dev, "%s: sip %pI4 not found in targets\n", in bond_validate_arp()
3126 slave->last_rx = jiffies; in bond_validate_arp()
3127 slave->target_last_arp_rx[i] = jiffies; in bond_validate_arp()
3133 struct arphdr *arp = (struct arphdr *)skb->data; in bond_arp_rcv()
3139 alen = arp_hdr_len(bond->dev); in bond_arp_rcv()
3149 if (arp->ar_hln != bond->dev->addr_len || in bond_arp_rcv()
3150 skb->pkt_type == PACKET_OTHERHOST || in bond_arp_rcv()
3151 skb->pkt_type == PACKET_LOOPBACK || in bond_arp_rcv()
3152 arp->ar_hrd != htons(ARPHRD_ETHER) || in bond_arp_rcv()
3153 arp->ar_pro != htons(ETH_P_IP) || in bond_arp_rcv()
3154 arp->ar_pln != 4) in bond_arp_rcv()
3158 arp_ptr += bond->dev->addr_len; in bond_arp_rcv()
3160 arp_ptr += 4 + bond->dev->addr_len; in bond_arp_rcv()
3163 slave_dbg(bond->dev, slave->dev, "%s: %s/%d av %d sv %d sip %pI4 tip %pI4\n", in bond_arp_rcv()
3164 __func__, slave->dev->name, bond_slave_state(slave), in bond_arp_rcv()
3165 bond->params.arp_validate, slave_do_arp_validate(bond, slave), in bond_arp_rcv()
3168 curr_active_slave = rcu_dereference(bond->curr_active_slave); in bond_arp_rcv()
3169 curr_arp_slave = rcu_dereference(bond->current_arp_slave); in bond_arp_rcv()
3198 curr_active_slave->last_link_up)) in bond_arp_rcv()
3200 else if (curr_arp_slave && (arp->ar_op == htons(ARPOP_REPLY)) && in bond_arp_rcv()
3205 if (arp != (struct arphdr *)skb->data) in bond_arp_rcv()
3214 struct net_device *bond_dev = slave->bond->dev; in bond_ns_send()
3215 struct net_device *slave_dev = slave->dev; in bond_ns_send()
3237 struct in6_addr *targets = bond->params.ns_targets; in bond_ns_send_all()
3245 slave_dbg(bond->dev, slave->dev, "%s: target %pI6c\n", in bond_ns_send_all()
3252 fl6.flowi6_oif = bond->dev->ifindex; in bond_ns_send_all()
3254 dst = ip6_route_output(dev_net(bond->dev), NULL, &fl6); in bond_ns_send_all()
3255 if (dst->error) { in bond_ns_send_all()
3257 /* there's no route to target - try to send arp in bond_ns_send_all()
3260 if (bond->params.arp_validate) in bond_ns_send_all()
3262 bond->dev->name, in bond_ns_send_all()
3269 if (dst->dev == bond->dev) in bond_ns_send_all()
3273 tags = bond_verify_device_path(bond->dev, dst->dev, 0); in bond_ns_send_all()
3279 /* Not our device - skip */ in bond_ns_send_all()
3280 slave_dbg(bond->dev, slave->dev, "no path to ns_ip6_target %pI6c via dst->dev %s\n", in bond_ns_send_all()
3281 &targets[i], dst->dev ? dst->dev->name : "NULL"); in bond_ns_send_all()
3287 if (!ipv6_dev_get_saddr(dev_net(dst->dev), dst->dev, &targets[i], 0, &saddr)) in bond_ns_send_all()
3300 struct in6_addr *addr = (struct in6_addr *)priv->data; in bond_confirm_addr6()
3312 if (bond_confirm_addr6(bond->dev, &priv)) in bond_has_this_ip6()
3316 if (netdev_walk_all_upper_dev_rcu(bond->dev, bond_confirm_addr6, &priv)) in bond_has_this_ip6()
3330 * 2. Dest address is neither all-nodes multicast address nor in bond_validate_na()
3336 slave_dbg(bond->dev, slave->dev, "%s: sip %pI6c tip %pI6c not found\n", in bond_validate_na()
3341 i = bond_get_targets_ip6(bond->params.ns_targets, saddr); in bond_validate_na()
3342 if (i == -1) { in bond_validate_na()
3343 slave_dbg(bond->dev, slave->dev, "%s: sip %pI6c not found in targets\n", in bond_validate_na()
3347 slave->last_rx = jiffies; in bond_validate_na()
3348 slave->target_last_arp_rx[i] = jiffies; in bond_validate_na()
3361 if (skb->pkt_type == PACKET_OTHERHOST || in bond_na_rcv()
3362 skb->pkt_type == PACKET_LOOPBACK) in bond_na_rcv()
3366 if (!combined || combined->ip6.nexthdr != NEXTHDR_ICMP || in bond_na_rcv()
3367 (combined->icmp6.icmp6_type != NDISC_NEIGHBOUR_SOLICITATION && in bond_na_rcv()
3368 combined->icmp6.icmp6_type != NDISC_NEIGHBOUR_ADVERTISEMENT)) in bond_na_rcv()
3371 saddr = &combined->ip6.saddr; in bond_na_rcv()
3372 daddr = &combined->ip6.daddr; in bond_na_rcv()
3374 slave_dbg(bond->dev, slave->dev, "%s: %s/%d av %d sv %d sip %pI6c tip %pI6c\n", in bond_na_rcv()
3375 __func__, slave->dev->name, bond_slave_state(slave), in bond_na_rcv()
3376 bond->params.arp_validate, slave_do_arp_validate(bond, slave), in bond_na_rcv()
3379 curr_active_slave = rcu_dereference(bond->curr_active_slave); in bond_na_rcv()
3380 curr_arp_slave = rcu_dereference(bond->current_arp_slave); in bond_na_rcv()
3389 curr_active_slave->last_link_up)) in bond_na_rcv()
3404 bool is_ipv6 = skb->protocol == __cpu_to_be16(ETH_P_IPV6); in bond_rcv_validate()
3406 bool is_arp = skb->protocol == __cpu_to_be16(ETH_P_ARP); in bond_rcv_validate()
3408 slave_dbg(bond->dev, slave->dev, "%s: skb->dev %s\n", in bond_rcv_validate()
3409 __func__, skb->dev->name); in bond_rcv_validate()
3418 slave->last_rx = jiffies; in bond_rcv_validate()
3440 * (last_act - arp_interval) <= jiffies <= (last_act + mod * arp_interval +
3446 int delta_in_ticks = msecs_to_jiffies(bond->params.arp_interval); in bond_time_in_interval()
3449 last_act - delta_in_ticks, in bond_time_in_interval()
3455 * is used in load-balancing mode. if the adapter has been dormant, then an
3470 oldcurrent = rcu_dereference(bond->curr_active_slave); in bond_loadbalance_arp_mon()
3473 * the picture unless it is null. also, slave->last_link_up is not in bond_loadbalance_arp_mon()
3484 if (slave->link != BOND_LINK_UP) { in bond_loadbalance_arp_mon()
3486 bond_time_in_interval(bond, slave->last_rx, 1)) { in bond_loadbalance_arp_mon()
3491 /* primary_slave has no meaning in round-robin in bond_loadbalance_arp_mon()
3497 slave_info(bond->dev, slave->dev, "link status definitely up\n"); in bond_loadbalance_arp_mon()
3500 slave_info(bond->dev, slave->dev, "interface is now up\n"); in bond_loadbalance_arp_mon()
3504 /* slave->link == BOND_LINK_UP */ in bond_loadbalance_arp_mon()
3510 if (!bond_time_in_interval(bond, last_tx, bond->params.missed_max) || in bond_loadbalance_arp_mon()
3511 !bond_time_in_interval(bond, slave->last_rx, bond->params.missed_max)) { in bond_loadbalance_arp_mon()
3516 if (slave->link_failure_count < UINT_MAX) in bond_loadbalance_arp_mon()
3517 slave->link_failure_count++; in bond_loadbalance_arp_mon()
3519 slave_info(bond->dev, slave->dev, "interface is now down\n"); in bond_loadbalance_arp_mon()
3526 /* note: if switch is in round-robin mode, all links in bond_loadbalance_arp_mon()
3527 * must tx arp to ensure all links rx an arp - otherwise in bond_loadbalance_arp_mon()
3530 * do - all replies will be rx'ed on same link causing slaves in bond_loadbalance_arp_mon()
3544 if (slave->link_new_state != BOND_LINK_NOCHANGE) in bond_loadbalance_arp_mon()
3545 slave->link = slave->link_new_state; in bond_loadbalance_arp_mon()
3562 if (bond->params.arp_interval) in bond_loadbalance_arp_mon()
3563 queue_delayed_work(bond->wq, &bond->arp_work, in bond_loadbalance_arp_mon()
3564 msecs_to_jiffies(bond->params.arp_interval)); in bond_loadbalance_arp_mon()
3567 /* Called to inspect slaves for active-backup mode ARP monitor link state
3585 if (slave->link != BOND_LINK_UP) { in bond_ab_arp_inspect()
3589 } else if (slave->link == BOND_LINK_BACK) { in bond_ab_arp_inspect()
3600 if (bond_time_in_interval(bond, slave->last_link_up, 2)) in bond_ab_arp_inspect()
3604 * - No current_arp_slave AND in bond_ab_arp_inspect()
3605 * - more than (missed_max+1)*delta since last receive AND in bond_ab_arp_inspect()
3606 * - the bond has an IP address in bond_ab_arp_inspect()
3608 * Note: a non-null current_arp_slave indicates in bond_ab_arp_inspect()
3611 * we only take the curr_active_slave down - this in bond_ab_arp_inspect()
3616 !rcu_access_pointer(bond->current_arp_slave) && in bond_ab_arp_inspect()
3617 !bond_time_in_interval(bond, last_rx, bond->params.missed_max + 1)) { in bond_ab_arp_inspect()
3623 * - more than missed_max*delta since transmitting OR in bond_ab_arp_inspect()
3624 * - (more than missed_max*delta since receive AND in bond_ab_arp_inspect()
3629 (!bond_time_in_interval(bond, last_tx, bond->params.missed_max) || in bond_ab_arp_inspect()
3630 !bond_time_in_interval(bond, last_rx, bond->params.missed_max))) { in bond_ab_arp_inspect()
3640 * active-backup mode ARP monitor.
3652 switch (slave->link_new_state) { in bond_ab_arp_commit()
3658 if (rtnl_dereference(bond->curr_active_slave) != slave || in bond_ab_arp_commit()
3659 (!rtnl_dereference(bond->curr_active_slave) && in bond_ab_arp_commit()
3663 current_arp_slave = rtnl_dereference(bond->current_arp_slave); in bond_ab_arp_commit()
3670 RCU_INIT_POINTER(bond->current_arp_slave, NULL); in bond_ab_arp_commit()
3673 slave_info(bond->dev, slave->dev, "link status definitely up\n"); in bond_ab_arp_commit()
3675 if (!rtnl_dereference(bond->curr_active_slave) || in bond_ab_arp_commit()
3676 slave == rtnl_dereference(bond->primary_slave) || in bond_ab_arp_commit()
3677 slave->prio > rtnl_dereference(bond->curr_active_slave)->prio) in bond_ab_arp_commit()
3685 if (slave->link_failure_count < UINT_MAX) in bond_ab_arp_commit()
3686 slave->link_failure_count++; in bond_ab_arp_commit()
3693 slave_info(bond->dev, slave->dev, "link status definitely down, disabling slave\n"); in bond_ab_arp_commit()
3695 if (slave == rtnl_dereference(bond->curr_active_slave)) { in bond_ab_arp_commit()
3696 RCU_INIT_POINTER(bond->current_arp_slave, NULL); in bond_ab_arp_commit()
3711 if (rtnl_dereference(bond->curr_active_slave)) in bond_ab_arp_commit()
3712 RCU_INIT_POINTER(bond->current_arp_slave, NULL); in bond_ab_arp_commit()
3716 slave_err(bond->dev, slave->dev, in bond_ab_arp_commit()
3718 slave->link_new_state); in bond_ab_arp_commit()
3732 /* Send ARP probes for active-backup mode ARP monitor.
3739 *curr_arp_slave = rcu_dereference(bond->current_arp_slave), in bond_ab_arp_probe()
3740 *curr_active_slave = rcu_dereference(bond->curr_active_slave); in bond_ab_arp_probe()
3746 netdev_info(bond->dev, "PROBE: c_arp %s && cas %s BAD\n", in bond_ab_arp_probe()
3747 curr_arp_slave->dev->name, in bond_ab_arp_probe()
3748 curr_active_slave->dev->name); in bond_ab_arp_probe()
3773 * mark it down - this can happen if we have in bond_ab_arp_probe()
3779 if (!bond_slave_is_up(slave) && slave->link == BOND_LINK_UP) { in bond_ab_arp_probe()
3782 if (slave->link_failure_count < UINT_MAX) in bond_ab_arp_probe()
3783 slave->link_failure_count++; in bond_ab_arp_probe()
3788 slave_info(bond->dev, slave->dev, "backup interface is now down\n"); in bond_ab_arp_probe()
3804 new_slave->last_link_up = jiffies; in bond_ab_arp_probe()
3805 rcu_assign_pointer(bond->current_arp_slave, new_slave); in bond_ab_arp_probe()
3809 if (slave->should_notify || slave->should_notify_link) { in bond_ab_arp_probe()
3823 delta_in_ticks = msecs_to_jiffies(bond->params.arp_interval); in bond_activebackup_arp_mon()
3852 if (bond->params.arp_interval) in bond_activebackup_arp_mon()
3853 queue_delayed_work(bond->wq, &bond->arp_work, delta_in_ticks); in bond_activebackup_arp_mon()
3860 bond->send_peer_notif--; in bond_activebackup_arp_mon()
3862 bond->dev); in bond_activebackup_arp_mon()
3884 /*-------------------------- netdev event handling --------------------------*/
3939 bond_dev = slave->bond->dev; in bond_slave_netdev_event()
3940 bond = slave->bond; in bond_slave_netdev_event()
3941 primary = rtnl_dereference(bond->primary_slave); in bond_slave_netdev_event()
3947 if (bond_dev->type != ARPHRD_ETHER) in bond_slave_netdev_event()
3956 * in weird state. Mark it as link-fail if the link was in bond_slave_netdev_event()
3957 * previously up or link-down if it hasn't yet come up, and in bond_slave_netdev_event()
3958 * let link-monitoring (miimon) set it right when correct in bond_slave_netdev_event()
3963 if (slave->last_link_up) in bond_slave_netdev_event()
3964 slave->link = BOND_LINK_FAIL; in bond_slave_netdev_event()
3966 slave->link = BOND_LINK_DOWN; in bond_slave_netdev_event()
3973 /* Refresh slave-array if applicable! in bond_slave_netdev_event()
3974 * If the setup does not use miimon or arpmon (mode-specific!), in bond_slave_netdev_event()
3975 * then these events will not cause the slave-array to be in bond_slave_netdev_event()
3987 * an active-backup bond, slaves need in bond_slave_netdev_event()
4000 !bond->params.primary[0]) in bond_slave_netdev_event()
4004 /* slave's name changed - he's no longer primary */ in bond_slave_netdev_event()
4005 RCU_INIT_POINTER(bond->primary_slave, NULL); in bond_slave_netdev_event()
4006 } else if (!strcmp(slave_dev->name, bond->params.primary)) { in bond_slave_netdev_event()
4008 rcu_assign_pointer(bond->primary_slave, slave); in bond_slave_netdev_event()
4009 } else { /* we didn't change primary - exit */ in bond_slave_netdev_event()
4013 netdev_info(bond->dev, "Primary slave changed to %s, reselecting active slave\n", in bond_slave_netdev_event()
4014 primary ? slave_dev->name : "none"); in bond_slave_netdev_event()
4021 if (!bond->notifier_ctx) { in bond_slave_netdev_event()
4022 bond->notifier_ctx = true; in bond_slave_netdev_event()
4024 bond->notifier_ctx = false; in bond_slave_netdev_event()
4029 call_netdevice_notifiers(event, slave->bond->dev); in bond_slave_netdev_event()
4056 if (!(event_dev->priv_flags & IFF_BONDING)) in bond_netdev_event()
4059 if (event_dev->flags & IFF_MASTER) { in bond_netdev_event()
4067 if (event_dev->flags & IFF_SLAVE) in bond_netdev_event()
4077 /*---------------------------- Hashing Policies -----------------------------*/
4088 return skb->data; in bond_pull_data()
4103 return ep->h_dest[5] ^ ep->h_source[5] ^ be16_to_cpu(ep->h_proto); in bond_eth_hash()
4119 *nhoff += iph->ihl << 2; in bond_flow_ip()
4121 *ip_proto = iph->protocol; in bond_flow_ip()
4130 *ip_proto = iph6->nexthdr; in bond_flow_ip()
4136 fk->ports.ports = __skb_flow_get_ports(skb, *nhoff, *ip_proto, data, hlen); in bond_flow_ip()
4154 srcmac_vendor = (srcmac_vendor << 8) | mac_hdr->h_source[i]; in bond_vlan_srcmac_hash()
4157 srcmac_dev = (srcmac_dev << 8) | mac_hdr->h_source[i]; in bond_vlan_srcmac_hash()
4169 bool l34 = bond->params.xmit_policy == BOND_XMIT_POLICY_LAYER34; in bond_flow_dissect()
4170 int ip_proto = -1; in bond_flow_dissect()
4172 switch (bond->params.xmit_policy) { in bond_flow_dissect()
4182 fk->ports.ports = 0; in bond_flow_dissect()
4183 memset(&fk->icmp, 0, sizeof(fk->icmp)); in bond_flow_dissect()
4193 skb_flow_get_icmp_tci(skb, &fk->icmp, data, nhoff, hlen); in bond_flow_dissect()
4195 if (!icmp_is_err(fk->icmp.type)) in bond_flow_dissect()
4200 if (!icmpv6_is_err(fk->icmp.type)) in bond_flow_dissect()
4236 if (bond->params.xmit_policy == BOND_XMIT_POLICY_VLAN_SRCMAC) in __bond_xmit_hash()
4239 if (bond->params.xmit_policy == BOND_XMIT_POLICY_LAYER2 || in __bond_xmit_hash()
4243 if (bond->params.xmit_policy == BOND_XMIT_POLICY_LAYER23 || in __bond_xmit_hash()
4244 bond->params.xmit_policy == BOND_XMIT_POLICY_ENCAP23) { in __bond_xmit_hash()
4253 return bond_ip_hash(hash, &flow, bond->params.xmit_policy); in __bond_xmit_hash()
4257 * bond_xmit_hash - generate a hash value based on the xmit policy
4266 if (bond->params.xmit_policy == BOND_XMIT_POLICY_ENCAP34 && in bond_xmit_hash()
4267 skb->l4_hash) in bond_xmit_hash()
4268 return skb->hash; in bond_xmit_hash()
4270 return __bond_xmit_hash(bond, skb, skb->data, skb->protocol, in bond_xmit_hash()
4276 * bond_xmit_hash_xdp - generate a hash value based on the xmit policy
4286 if (xdp->data + sizeof(struct ethhdr) > xdp->data_end) in bond_xmit_hash_xdp()
4289 eth = (struct ethhdr *)xdp->data; in bond_xmit_hash_xdp()
4291 return __bond_xmit_hash(bond, NULL, xdp->data, eth->h_proto, 0, in bond_xmit_hash_xdp()
4292 sizeof(struct ethhdr), xdp->data_end - xdp->data); in bond_xmit_hash_xdp()
4295 /*-------------------------- Device entry points ----------------------------*/
4299 INIT_DELAYED_WORK(&bond->mcast_work, in bond_work_init_all()
4301 INIT_DELAYED_WORK(&bond->alb_work, bond_alb_monitor); in bond_work_init_all()
4302 INIT_DELAYED_WORK(&bond->mii_work, bond_mii_monitor); in bond_work_init_all()
4303 INIT_DELAYED_WORK(&bond->arp_work, bond_arp_monitor); in bond_work_init_all()
4304 INIT_DELAYED_WORK(&bond->ad_work, bond_3ad_state_machine_handler); in bond_work_init_all()
4305 INIT_DELAYED_WORK(&bond->slave_arr_work, bond_slave_arr_handler); in bond_work_init_all()
4310 cancel_delayed_work_sync(&bond->mii_work); in bond_work_cancel_all()
4311 cancel_delayed_work_sync(&bond->arp_work); in bond_work_cancel_all()
4312 cancel_delayed_work_sync(&bond->alb_work); in bond_work_cancel_all()
4313 cancel_delayed_work_sync(&bond->ad_work); in bond_work_cancel_all()
4314 cancel_delayed_work_sync(&bond->mcast_work); in bond_work_cancel_all()
4315 cancel_delayed_work_sync(&bond->slave_arr_work); in bond_work_cancel_all()
4324 if (BOND_MODE(bond) == BOND_MODE_ROUNDROBIN && !bond->rr_tx_counter) { in bond_open()
4325 bond->rr_tx_counter = alloc_percpu(u32); in bond_open()
4326 if (!bond->rr_tx_counter) in bond_open()
4327 return -ENOMEM; in bond_open()
4330 /* reset slave->backup and slave->inactive */ in bond_open()
4334 slave != rcu_access_pointer(bond->curr_active_slave)) { in bond_open()
4349 return -ENOMEM; in bond_open()
4350 if (bond->params.tlb_dynamic_lb || BOND_MODE(bond) == BOND_MODE_ALB) in bond_open()
4351 queue_delayed_work(bond->wq, &bond->alb_work, 0); in bond_open()
4354 if (bond->params.miimon) /* link check interval, in milliseconds. */ in bond_open()
4355 queue_delayed_work(bond->wq, &bond->mii_work, 0); in bond_open()
4357 if (bond->params.arp_interval) { /* arp interval, in milliseconds. */ in bond_open()
4358 queue_delayed_work(bond->wq, &bond->arp_work, 0); in bond_open()
4359 bond->recv_probe = bond_rcv_validate; in bond_open()
4363 queue_delayed_work(bond->wq, &bond->ad_work, 0); in bond_open()
4365 bond->recv_probe = bond_3ad_lacpdu_recv; in bond_open()
4369 dev_mc_add(slave->dev, lacpdu_mcast_addr); in bond_open()
4384 bond->send_peer_notif = 0; in bond_close()
4387 bond->recv_probe = NULL; in bond_close()
4391 slave = rcu_dereference(bond->curr_active_slave); in bond_close()
4393 bond_hw_addr_flush(bond_dev, slave->dev); in bond_close()
4399 bond_hw_addr_flush(bond_dev, slave->dev); in bond_close()
4420 s64 delta = nv - ov; in bond_fold_stats()
4424 delta = (s64)(s32)((u32)nv - (u32)ov); in bond_fold_stats()
4442 iter = &dev->adj_list.lower; in bond_get_lowest_level_rcu()
4452 niter = &ldev->adj_list.lower; in bond_get_lowest_level_rcu()
4463 next = dev_stack[--cur]; in bond_get_lowest_level_rcu()
4490 spin_lock_nested(&bond->stats_lock, nest_level); in bond_get_stats()
4491 memcpy(stats, &bond->bond_stats, sizeof(*stats)); in bond_get_stats()
4495 dev_get_stats(slave->dev, &temp); in bond_get_stats()
4497 bond_fold_stats(stats, new, &slave->slave_stats); in bond_get_stats()
4500 memcpy(&slave->slave_stats, new, sizeof(*new)); in bond_get_stats()
4503 memcpy(&bond->bond_stats, stats, sizeof(*stats)); in bond_get_stats()
4504 spin_unlock(&bond->stats_lock); in bond_get_stats()
4511 struct mii_ioctl_data *mii = NULL; in bond_eth_ioctl() local
4517 mii = if_mii(ifr); in bond_eth_ioctl()
4518 if (!mii) in bond_eth_ioctl()
4519 return -EINVAL; in bond_eth_ioctl()
4521 mii->phy_id = 0; in bond_eth_ioctl()
4527 mii = if_mii(ifr); in bond_eth_ioctl()
4528 if (!mii) in bond_eth_ioctl()
4529 return -EINVAL; in bond_eth_ioctl()
4531 if (mii->reg_num == 1) { in bond_eth_ioctl()
4532 mii->val_out = 0; in bond_eth_ioctl()
4533 if (netif_carrier_ok(bond->dev)) in bond_eth_ioctl()
4534 mii->val_out = BMSR_LSTATUS; in bond_eth_ioctl()
4539 return -EOPNOTSUPP; in bond_eth_ioctl()
4561 u_binfo = (struct ifbond __user *)ifr->ifr_data; in bond_do_ioctl()
4564 return -EFAULT; in bond_do_ioctl()
4568 return -EFAULT; in bond_do_ioctl()
4572 u_sinfo = (struct ifslave __user *)ifr->ifr_data; in bond_do_ioctl()
4575 return -EFAULT; in bond_do_ioctl()
4580 return -EFAULT; in bond_do_ioctl()
4589 if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) in bond_do_ioctl()
4590 return -EPERM; in bond_do_ioctl()
4592 slave_dev = __dev_get_by_name(net, ifr->ifr_slave); in bond_do_ioctl()
4597 return -ENODEV; in bond_do_ioctl()
4610 bond_opt_initstr(&newval, slave_dev->name); in bond_do_ioctl()
4615 res = -EOPNOTSUPP; in bond_do_ioctl()
4641 return -EOPNOTSUPP; in bond_siocdevprivate()
4650 bond_dev->flags & IFF_PROMISC ? 1 : -1); in bond_change_rx_flags()
4654 bond_dev->flags & IFF_ALLMULTI ? 1 : -1); in bond_change_rx_flags()
4665 slave = rcu_dereference(bond->curr_active_slave); in bond_set_rx_mode()
4667 dev_uc_sync(slave->dev, bond_dev); in bond_set_rx_mode()
4668 dev_mc_sync(slave->dev, bond_dev); in bond_set_rx_mode()
4672 dev_uc_sync_multiple(slave->dev, bond_dev); in bond_set_rx_mode()
4673 dev_mc_sync_multiple(slave->dev, bond_dev); in bond_set_rx_mode()
4681 struct bonding *bond = netdev_priv(n->dev); in bond_neigh_init()
4691 slave_ops = slave->dev->netdev_ops; in bond_neigh_init()
4692 if (!slave_ops->ndo_neigh_setup) in bond_neigh_init()
4704 ret = slave_ops->ndo_neigh_setup(slave->dev, &parms); in bond_neigh_init()
4721 * underlying devices. In that case - do nothing, we're already set up from
4728 if (parms->dev == dev) in bond_neigh_setup()
4729 parms->neigh_setup = bond_neigh_init; in bond_neigh_setup()
4745 slave_dbg(bond_dev, slave->dev, "s %p c_m %p\n", in bond_change_mtu()
4746 slave, slave->dev->netdev_ops->ndo_change_mtu); in bond_change_mtu()
4748 res = dev_set_mtu(slave->dev, new_mtu); in bond_change_mtu()
4759 slave_dbg(bond_dev, slave->dev, "err %d setting mtu to %d\n", in bond_change_mtu()
4765 bond_dev->mtu = new_mtu; in bond_change_mtu()
4777 tmp_res = dev_set_mtu(rollback_slave->dev, bond_dev->mtu); in bond_change_mtu()
4779 slave_dbg(bond_dev, rollback_slave->dev, "unwind err %d\n", in bond_change_mtu()
4809 if (bond->params.fail_over_mac && in bond_set_mac_address()
4813 if (!is_valid_ether_addr(ss->__data)) in bond_set_mac_address()
4814 return -EADDRNOTAVAIL; in bond_set_mac_address()
4817 slave_dbg(bond_dev, slave->dev, "%s: slave=%p\n", in bond_set_mac_address()
4819 res = dev_set_mac_address(slave->dev, addr, NULL); in bond_set_mac_address()
4827 slave_dbg(bond_dev, slave->dev, "%s: err %d\n", in bond_set_mac_address()
4834 dev_addr_set(bond_dev, ss->__data); in bond_set_mac_address()
4838 memcpy(tmp_ss.__data, bond_dev->dev_addr, bond_dev->addr_len); in bond_set_mac_address()
4839 tmp_ss.ss_family = bond_dev->type; in bond_set_mac_address()
4848 tmp_res = dev_set_mac_address(rollback_slave->dev, in bond_set_mac_address()
4851 slave_dbg(bond_dev, rollback_slave->dev, "%s: unwind err %d\n", in bond_set_mac_address()
4860 * bond_get_slave_by_id - get xmit slave with slave_id
4862 * @slave_id: slave id up to slave_cnt-1 through which to transmit
4876 if (--i < 0) { in bond_get_slave_by_id()
4885 if (--i < 0) in bond_get_slave_by_id()
4895 * bond_rr_gen_slave_id - generate slave id based on packets_per_slave
4906 int packets_per_slave = bond->params.packets_per_slave; in bond_rr_gen_slave_id()
4913 slave_id = this_cpu_inc_return(*bond->rr_tx_counter); in bond_rr_gen_slave_id()
4917 bond->params.reciprocal_packets_per_slave; in bond_rr_gen_slave_id()
4918 slave_id = this_cpu_inc_return(*bond->rr_tx_counter); in bond_rr_gen_slave_id()
4940 if (skb->protocol == htons(ETH_P_IP)) { in bond_xmit_roundrobin_slave_get()
4948 if (iph->protocol == IPPROTO_IGMP) { in bond_xmit_roundrobin_slave_get()
4949 slave = rcu_dereference(bond->curr_active_slave); in bond_xmit_roundrobin_slave_get()
4957 slave_cnt = READ_ONCE(bond->slave_cnt); in bond_xmit_roundrobin_slave_get()
4972 void *data = xdp->data; in bond_xdp_xmit_roundrobin_slave_get()
4974 if (data + sizeof(struct ethhdr) > xdp->data_end) in bond_xdp_xmit_roundrobin_slave_get()
4981 if (eth->h_proto == htons(ETH_P_IP)) { in bond_xdp_xmit_roundrobin_slave_get()
4984 if (data + sizeof(struct iphdr) > xdp->data_end) in bond_xdp_xmit_roundrobin_slave_get()
4989 if (iph->protocol == IPPROTO_IGMP) { in bond_xdp_xmit_roundrobin_slave_get()
4990 slave = rcu_dereference(bond->curr_active_slave); in bond_xdp_xmit_roundrobin_slave_get()
4998 slave_cnt = READ_ONCE(bond->slave_cnt); in bond_xdp_xmit_roundrobin_slave_get()
5014 return bond_dev_queue_xmit(bond, skb, slave->dev); in bond_xmit_roundrobin()
5021 return rcu_dereference(bond->curr_active_slave); in bond_xmit_activebackup_slave_get()
5024 /* In active-backup mode, we know that bond->curr_active_slave is always valid if
5035 return bond_dev_queue_xmit(bond, skb, slave->dev); in bond_xmit_activebackup()
5046 queue_delayed_work(bond->wq, &bond->slave_arr_work, delay); in bond_slave_arr_work_rearm()
5082 * this to-be-skipped slave to send a packet out. in bond_skip_slave()
5084 for (idx = 0; slaves && idx < slaves->count; idx++) { in bond_skip_slave()
5085 if (skipslave == slaves->arr[idx]) { in bond_skip_slave()
5086 slaves->arr[idx] = in bond_skip_slave()
5087 slaves->arr[slaves->count - 1]; in bond_skip_slave()
5088 slaves->count--; in bond_skip_slave()
5100 usable = rtnl_dereference(bond->usable_slaves); in bond_set_slave_arr()
5101 rcu_assign_pointer(bond->usable_slaves, usable_slaves); in bond_set_slave_arr()
5104 all = rtnl_dereference(bond->all_slaves); in bond_set_slave_arr()
5105 rcu_assign_pointer(bond->all_slaves, all_slaves); in bond_set_slave_arr()
5114 /* Build the usable slaves array in control path for modes that use xmit-hash
5115 * to determine the slave interface -
5133 bond->slave_cnt), GFP_KERNEL); in bond_update_slave_arr()
5135 bond->slave_cnt), GFP_KERNEL); in bond_update_slave_arr()
5137 ret = -ENOMEM; in bond_update_slave_arr()
5143 spin_lock_bh(&bond->mode_lock); in bond_update_slave_arr()
5145 spin_unlock_bh(&bond->mode_lock); in bond_update_slave_arr()
5153 spin_unlock_bh(&bond->mode_lock); in bond_update_slave_arr()
5160 all_slaves->arr[all_slaves->count++] = slave; in bond_update_slave_arr()
5164 agg = SLAVE_AD_INFO(slave)->port.aggregator; in bond_update_slave_arr()
5165 if (!agg || agg->aggregator_identifier != agg_id) in bond_update_slave_arr()
5171 slave_dbg(bond->dev, slave->dev, "Adding slave to tx hash array[%d]\n", in bond_update_slave_arr()
5172 usable_slaves->count); in bond_update_slave_arr()
5174 usable_slaves->arr[usable_slaves->count++] = slave; in bond_update_slave_arr()
5181 bond_skip_slave(rtnl_dereference(bond->all_slaves), in bond_update_slave_arr()
5183 bond_skip_slave(rtnl_dereference(bond->usable_slaves), in bond_update_slave_arr()
5201 count = slaves ? READ_ONCE(slaves->count) : 0; in bond_xmit_3ad_xor_slave_get()
5205 slave = slaves->arr[hash % count]; in bond_xmit_3ad_xor_slave_get()
5217 slaves = rcu_dereference(bond->usable_slaves); in bond_xdp_xmit_3ad_xor_slave_get()
5218 count = slaves ? READ_ONCE(slaves->count) : 0; in bond_xdp_xmit_3ad_xor_slave_get()
5222 return slaves->arr[hash % count]; in bond_xdp_xmit_3ad_xor_slave_get()
5236 slaves = rcu_dereference(bond->usable_slaves); in bond_3ad_xor_xmit()
5239 return bond_dev_queue_xmit(bond, skb, slave->dev); in bond_3ad_xor_xmit()
5257 if (!(bond_slave_is_up(slave) && slave->link == BOND_LINK_UP)) in bond_xmit_broadcast()
5267 bond_dev->name, __func__); in bond_xmit_broadcast()
5272 if (bond_dev_queue_xmit(bond, skb2, slave->dev) == NETDEV_TX_OK) in bond_xmit_broadcast()
5286 /*------------------------- Device initialization ---------------------------*/
5300 if (slave->queue_id == skb_get_queue_mapping(skb)) { in bond_slave_override()
5302 slave->link == BOND_LINK_UP) { in bond_slave_override()
5303 bond_dev_queue_xmit(bond, skb, slave->dev); in bond_slave_override()
5326 qdisc_skb_cb(skb)->slave_dev_queue_mapping = skb_get_queue_mapping(skb); in bond_select_queue()
5328 if (unlikely(txq >= dev->real_num_tx_queues)) { in bond_select_queue()
5330 txq -= dev->real_num_tx_queues; in bond_select_queue()
5331 } while (txq >= dev->real_num_tx_queues); in bond_select_queue()
5354 slaves = rcu_dereference(bond->all_slaves); in bond_xmit_get_slave()
5356 slaves = rcu_dereference(bond->usable_slaves); in bond_xmit_get_slave()
5374 return slave->dev; in bond_xmit_get_slave()
5380 switch (sk->sk_family) { in bond_sk_to_flow()
5384 ipv6_addr_type(&sk->sk_v6_daddr) != IPV6_ADDR_MAPPED) { in bond_sk_to_flow()
5385 flow->control.addr_type = FLOW_DISSECTOR_KEY_IPV6_ADDRS; in bond_sk_to_flow()
5386 flow->addrs.v6addrs.src = inet6_sk(sk)->saddr; in bond_sk_to_flow()
5387 flow->addrs.v6addrs.dst = sk->sk_v6_daddr; in bond_sk_to_flow()
5393 flow->control.addr_type = FLOW_DISSECTOR_KEY_IPV4_ADDRS; in bond_sk_to_flow()
5394 flow->addrs.v4addrs.src = inet_sk(sk)->inet_rcv_saddr; in bond_sk_to_flow()
5395 flow->addrs.v4addrs.dst = inet_sk(sk)->inet_daddr; in bond_sk_to_flow()
5399 flow->ports.src = inet_sk(sk)->inet_sport; in bond_sk_to_flow()
5400 flow->ports.dst = inet_sk(sk)->inet_dport; in bond_sk_to_flow()
5404 * bond_sk_hash_l34 - generate a hash value based on the socket's L3 and L4 fields
5432 slaves = rcu_dereference(bond->usable_slaves); in __bond_sk_get_lower_dev()
5433 count = slaves ? READ_ONCE(slaves->count) : 0; in __bond_sk_get_lower_dev()
5438 slave = slaves->arr[hash % count]; in __bond_sk_get_lower_dev()
5440 return slave->dev; in __bond_sk_get_lower_dev()
5461 struct net_device *tls_netdev = rcu_dereference(tls_get_ctx(skb->sk)->netdev); in bond_tls_device_xmit()
5559 return slave->dev; in bond_xdp_get_xmit_slave()
5567 int nxmit, err = -ENXIO; in bond_xdp_xmit()
5581 err = -ENXIO; in bond_xdp_xmit()
5585 err = slave_dev->netdev_ops->ndo_xdp_xmit(slave_dev, 1, frames1, flags); in bond_xdp_xmit()
5619 return -EOPNOTSUPP; in bond_xdp_set()
5621 old_prog = bond->xdp_prog; in bond_xdp_set()
5622 bond->xdp_prog = prog; in bond_xdp_set()
5625 struct net_device *slave_dev = slave->dev; in bond_xdp_set()
5627 if (!slave_dev->netdev_ops->ndo_bpf || in bond_xdp_set()
5628 !slave_dev->netdev_ops->ndo_xdp_xmit) { in bond_xdp_set()
5631 err = -EOPNOTSUPP; in bond_xdp_set()
5638 err = -EOPNOTSUPP; in bond_xdp_set()
5642 err = slave_dev->netdev_ops->ndo_bpf(slave_dev, &xdp); in bond_xdp_set()
5663 bond->xdp_prog = old_prog; in bond_xdp_set()
5668 struct net_device *slave_dev = rollback_slave->dev; in bond_xdp_set()
5674 err_unwind = slave_dev->netdev_ops->ndo_bpf(slave_dev, &xdp); in bond_xdp_set()
5686 switch (xdp->command) { in bond_xdp()
5688 return bond_xdp_set(dev, xdp->prog, xdp->extack); in bond_xdp()
5690 return -EINVAL; in bond_xdp()
5697 speed = slave->speed; in bond_mode_bcast_speed()
5699 speed = min(speed, slave->speed); in bond_mode_bcast_speed()
5707 struct ifreq *ifr = kernel_cfg->ifr; in bond_set_phc_index_flag()
5710 if (kernel_cfg->copied_to_user) { in bond_set_phc_index_flag()
5712 if (copy_from_user(&cfg, ifr->ifr_data, sizeof(cfg))) in bond_set_phc_index_flag()
5713 return -EFAULT; in bond_set_phc_index_flag()
5716 if (copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg))) in bond_set_phc_index_flag()
5717 return -EFAULT; in bond_set_phc_index_flag()
5719 kernel_cfg->flags |= HWTSTAMP_FLAG_BONDED_PHC_INDEX; in bond_set_phc_index_flag()
5734 return -EOPNOTSUPP; in bond_hwtstamp_get()
5751 if (!(cfg->flags & HWTSTAMP_FLAG_BONDED_PHC_INDEX)) in bond_hwtstamp_set()
5752 return -EOPNOTSUPP; in bond_hwtstamp_set()
5756 return -EOPNOTSUPP; in bond_hwtstamp_set()
5773 cmd->base.duplex = DUPLEX_UNKNOWN; in bond_ethtool_get_link_ksettings()
5774 cmd->base.port = PORT_OTHER; in bond_ethtool_get_link_ksettings()
5784 if (slave->speed != SPEED_UNKNOWN) { in bond_ethtool_get_link_ksettings()
5789 speed += slave->speed; in bond_ethtool_get_link_ksettings()
5791 if (cmd->base.duplex == DUPLEX_UNKNOWN && in bond_ethtool_get_link_ksettings()
5792 slave->duplex != DUPLEX_UNKNOWN) in bond_ethtool_get_link_ksettings()
5793 cmd->base.duplex = slave->duplex; in bond_ethtool_get_link_ksettings()
5796 cmd->base.speed = speed ? : SPEED_UNKNOWN; in bond_ethtool_get_link_ksettings()
5804 strscpy(drvinfo->driver, DRV_NAME, sizeof(drvinfo->driver)); in bond_ethtool_get_drvinfo()
5805 snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), "%d", in bond_ethtool_get_drvinfo()
5828 ops = real_dev->ethtool_ops; in bond_ethtool_get_ts_info()
5829 phydev = real_dev->phydev; in bond_ethtool_get_ts_info()
5834 } else if (ops->get_ts_info) { in bond_ethtool_get_ts_info()
5835 ret = ops->get_ts_info(real_dev, info); in bond_ethtool_get_ts_info()
5842 ret = -1; in bond_ethtool_get_ts_info()
5843 ops = slave->dev->ethtool_ops; in bond_ethtool_get_ts_info()
5844 phydev = slave->dev->phydev; in bond_ethtool_get_ts_info()
5848 else if (ops->get_ts_info) in bond_ethtool_get_ts_info()
5849 ret = ops->get_ts_info(slave->dev, &ts_info); in bond_ethtool_get_ts_info()
5863 info->so_timestamping = SOF_TIMESTAMPING_RX_SOFTWARE | in bond_ethtool_get_ts_info()
5866 info->so_timestamping |= SOF_TIMESTAMPING_TX_SOFTWARE; in bond_ethtool_get_ts_info()
5868 info->phc_index = -1; in bond_ethtool_get_ts_info()
5926 if (bond->wq) in bond_destructor()
5927 destroy_workqueue(bond->wq); in bond_destructor()
5929 free_percpu(bond->rr_tx_counter); in bond_destructor()
5936 spin_lock_init(&bond->mode_lock); in bond_setup()
5937 bond->params = bonding_defaults; in bond_setup()
5940 bond->dev = bond_dev; in bond_setup()
5944 bond_dev->max_mtu = ETH_MAX_MTU; in bond_setup()
5945 bond_dev->netdev_ops = &bond_netdev_ops; in bond_setup()
5946 bond_dev->ethtool_ops = &bond_ethtool_ops; in bond_setup()
5948 bond_dev->needs_free_netdev = true; in bond_setup()
5949 bond_dev->priv_destructor = bond_destructor; in bond_setup()
5954 bond_dev->flags |= IFF_MASTER; in bond_setup()
5955 bond_dev->priv_flags |= IFF_BONDING | IFF_UNICAST_FLT | IFF_NO_QUEUE; in bond_setup()
5956 bond_dev->priv_flags &= ~(IFF_XMIT_DST_RELEASE | IFF_TX_SKB_SHARING); in bond_setup()
5959 /* set up xfrm device ops (only supported in active-backup right now) */ in bond_setup()
5960 bond_dev->xfrmdev_ops = &bond_xfrmdev_ops; in bond_setup()
5961 INIT_LIST_HEAD(&bond->ipsec_list); in bond_setup()
5962 mutex_init(&bond->ipsec_lock); in bond_setup()
5966 bond_dev->features |= NETIF_F_LLTX; in bond_setup()
5976 bond_dev->features |= NETIF_F_NETNS_LOCAL; in bond_setup()
5978 bond_dev->hw_features = BOND_VLAN_FEATURES | in bond_setup()
5984 bond_dev->hw_features |= NETIF_F_GSO_ENCAP_ALL; in bond_setup()
5985 bond_dev->features |= bond_dev->hw_features; in bond_setup()
5986 bond_dev->features |= NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX; in bond_setup()
5988 bond_dev->hw_features |= BOND_XFRM_FEATURES; in bond_setup()
5989 /* Only enable XFRM features if this is an active-backup config */ in bond_setup()
5991 bond_dev->features |= BOND_XFRM_FEATURES; in bond_setup()
6008 __bond_release_one(bond_dev, slave->dev, true, true); in bond_uninit()
6012 mutex_destroy(&bond->ipsec_lock); in bond_uninit()
6017 list_del(&bond->bond_list); in bond_uninit()
6022 /*------------------------- Module initialization ---------------------------*/
6045 return -EINVAL; in bond_check_params()
6047 bond_mode = valptr->value; in bond_check_params()
6063 return -EINVAL; in bond_check_params()
6065 xmit_hashtype = valptr->value; in bond_check_params()
6080 return -EINVAL; in bond_check_params()
6082 lacp_fast = valptr->value; in bond_check_params()
6092 return -EINVAL; in bond_check_params()
6094 params->ad_select = valptr->value; in bond_check_params()
6098 params->ad_select = BOND_AD_STABLE; in bond_check_params()
6102 …pr_warn("Warning: max_bonds (%d) not in range %d-%d, so it was reset to BOND_DEFAULT_MAX_BONDS (%d… in bond_check_params()
6108 pr_warn("Warning: miimon module parameter (%d), not in range 0-%d, so it was reset to 0\n", in bond_check_params()
6114 pr_warn("Warning: updelay module parameter (%d), not in range 0-%d, so it was reset to 0\n", in bond_check_params()
6120 pr_warn("Warning: downdelay module parameter (%d), not in range 0-%d, so it was reset to 0\n", in bond_check_params()
6132 pr_warn("Warning: num_grat_arp/num_unsol_na (%d) not in range 0-255 so it was reset to 1\n", in bond_check_params()
6209 pr_warn("Warning: arp_interval module parameter (%d), not in range 0-%d, so it was reset to 0\n", in bond_check_params()
6219 if (!in4_pton(arp_ip_target[i], -1, (u8 *)&ip, -1, NULL) || in bond_check_params()
6225 if (bond_get_targets_ip(arp_target, ip) == -1) in bond_check_params()
6243 return -EINVAL; in bond_check_params()
6252 return -EINVAL; in bond_check_params()
6254 arp_validate_value = valptr->value; in bond_check_params()
6268 arp_all_targets_value = valptr->value; in bond_check_params()
6273 pr_info("MII link monitoring set to %d ms\n", miimon); in bond_check_params()
6278 arp_interval, valptr->string, arp_ip_count); in bond_check_params()
6308 return -EINVAL; in bond_check_params()
6310 primary_reselect_value = valptr->value; in bond_check_params()
6322 return -EINVAL; in bond_check_params()
6324 fail_over_mac_value = valptr->value; in bond_check_params()
6326 pr_warn("Warning: fail_over_mac only affects active-backup mode\n"); in bond_check_params()
6337 return -EINVAL; in bond_check_params()
6339 ad_actor_sys_prio = valptr->value; in bond_check_params()
6345 return -EINVAL; in bond_check_params()
6347 ad_user_port_key = valptr->value; in bond_check_params()
6353 return -EINVAL; in bond_check_params()
6355 tlb_dynamic_lb = valptr->value; in bond_check_params()
6364 params->mode = bond_mode; in bond_check_params()
6365 params->xmit_policy = xmit_hashtype; in bond_check_params()
6366 params->miimon = miimon; in bond_check_params()
6367 params->num_peer_notif = num_peer_notif; in bond_check_params()
6368 params->arp_interval = arp_interval; in bond_check_params()
6369 params->arp_validate = arp_validate_value; in bond_check_params()
6370 params->arp_all_targets = arp_all_targets_value; in bond_check_params()
6371 params->missed_max = 2; in bond_check_params()
6372 params->updelay = updelay; in bond_check_params()
6373 params->downdelay = downdelay; in bond_check_params()
6374 params->peer_notif_delay = 0; in bond_check_params()
6375 params->use_carrier = use_carrier; in bond_check_params()
6376 params->lacp_active = 1; in bond_check_params()
6377 params->lacp_fast = lacp_fast; in bond_check_params()
6378 params->primary[0] = 0; in bond_check_params()
6379 params->primary_reselect = primary_reselect_value; in bond_check_params()
6380 params->fail_over_mac = fail_over_mac_value; in bond_check_params()
6381 params->tx_queues = tx_queues; in bond_check_params()
6382 params->all_slaves_active = all_slaves_active; in bond_check_params()
6383 params->resend_igmp = resend_igmp; in bond_check_params()
6384 params->min_links = min_links; in bond_check_params()
6385 params->lp_interval = lp_interval; in bond_check_params()
6386 params->packets_per_slave = packets_per_slave; in bond_check_params()
6387 params->tlb_dynamic_lb = tlb_dynamic_lb; in bond_check_params()
6388 params->ad_actor_sys_prio = ad_actor_sys_prio; in bond_check_params()
6389 eth_zero_addr(params->ad_actor_system); in bond_check_params()
6390 params->ad_user_port_key = ad_user_port_key; in bond_check_params()
6392 params->reciprocal_packets_per_slave = in bond_check_params()
6398 params->reciprocal_packets_per_slave = in bond_check_params()
6403 strscpy_pad(params->primary, primary, sizeof(params->primary)); in bond_check_params()
6405 memcpy(params->arp_targets, arp_target, sizeof(arp_target)); in bond_check_params()
6407 memset(params->ns_targets, 0, sizeof(struct in6_addr) * BOND_MAX_NS_TARGETS); in bond_check_params()
6421 bond->wq = alloc_ordered_workqueue(bond_dev->name, WQ_MEM_RECLAIM); in bond_init()
6422 if (!bond->wq) in bond_init()
6423 return -ENOMEM; in bond_init()
6425 bond->notifier_ctx = false; in bond_init()
6427 spin_lock_init(&bond->stats_lock); in bond_init()
6430 list_add_tail(&bond->bond_list, &bn->dev_list); in bond_init()
6437 if (is_zero_ether_addr(bond_dev->dev_addr) && in bond_init()
6438 bond_dev->addr_assign_type == NET_ADDR_PERM) in bond_init()
6458 int res = -ENOMEM; in bond_create()
6470 bond_dev->rtnl_link_ops = &bond_link_ops; in bond_create()
6491 bn->net = net; in bond_net_init()
6492 INIT_LIST_HEAD(&bn->dev_list); in bond_net_init()
6517 list_for_each_entry_safe(bond, tmp_bond, &bn->dev_list, bond_list) in bond_net_exit_batch()
6518 unregister_netdevice_queue(bond->dev, &list); in bond_net_exit_batch()