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_dev - Get active device for IPsec offload
431 struct net_device *bond_dev = xs->xso.dev; in bond_ipsec_dev()
442 slave = rcu_dereference(bond->curr_active_slave); in bond_ipsec_dev()
446 if (!xs->xso.real_dev) 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()
457 * bond_ipsec_add_sa - program device with a security association
464 struct net_device *bond_dev = xs->xso.dev; in bond_ipsec_add_sa()
473 return -EINVAL; in bond_ipsec_add_sa()
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()
482 err = -ENODEV; in bond_ipsec_add_sa()
486 if (!real_dev->xfrmdev_ops || in bond_ipsec_add_sa()
487 !real_dev->xfrmdev_ops->xdo_dev_state_add || in bond_ipsec_add_sa()
490 err = -EINVAL; in bond_ipsec_add_sa()
496 err = -ENOMEM; in bond_ipsec_add_sa()
500 xs->xso.real_dev = real_dev; in bond_ipsec_add_sa()
501 err = real_dev->xfrmdev_ops->xdo_dev_state_add(xs, extack); in bond_ipsec_add_sa()
503 ipsec->xs = xs; in bond_ipsec_add_sa()
504 INIT_LIST_HEAD(&ipsec->list); in bond_ipsec_add_sa()
505 mutex_lock(&bond->ipsec_lock); in bond_ipsec_add_sa()
506 list_add(&ipsec->list, &bond->ipsec_list); in bond_ipsec_add_sa()
507 mutex_unlock(&bond->ipsec_lock); in bond_ipsec_add_sa()
518 struct net_device *bond_dev = bond->dev; in bond_ipsec_add_sa_all()
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()
528 mutex_lock(&bond->ipsec_lock); in bond_ipsec_add_sa_all()
529 if (!real_dev->xfrmdev_ops || in bond_ipsec_add_sa_all()
530 !real_dev->xfrmdev_ops->xdo_dev_state_add || in bond_ipsec_add_sa_all()
532 if (!list_empty(&bond->ipsec_list)) in bond_ipsec_add_sa_all()
539 list_for_each_entry(ipsec, &bond->ipsec_list, list) { in bond_ipsec_add_sa_all()
541 if (ipsec->xs->xso.real_dev == real_dev) in bond_ipsec_add_sa_all()
544 ipsec->xs->xso.real_dev = real_dev; in bond_ipsec_add_sa_all()
545 if (real_dev->xfrmdev_ops->xdo_dev_state_add(ipsec->xs, NULL)) { in bond_ipsec_add_sa_all()
547 ipsec->xs->xso.real_dev = NULL; in bond_ipsec_add_sa_all()
551 mutex_unlock(&bond->ipsec_lock); in bond_ipsec_add_sa_all()
555 * bond_ipsec_del_sa - clear out this specific SA
560 struct net_device *bond_dev = xs->xso.dev; in bond_ipsec_del_sa()
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()
580 if (!xs->xso.real_dev) in bond_ipsec_del_sa()
583 WARN_ON(xs->xso.real_dev != real_dev); in bond_ipsec_del_sa()
585 if (!real_dev->xfrmdev_ops || in bond_ipsec_del_sa()
586 !real_dev->xfrmdev_ops->xdo_dev_state_delete || in bond_ipsec_del_sa()
592 real_dev->xfrmdev_ops->xdo_dev_state_delete(xs); in bond_ipsec_del_sa()
595 mutex_lock(&bond->ipsec_lock); in bond_ipsec_del_sa()
596 list_for_each_entry(ipsec, &bond->ipsec_list, list) { in bond_ipsec_del_sa()
597 if (ipsec->xs == xs) { in bond_ipsec_del_sa()
598 list_del(&ipsec->list); in bond_ipsec_del_sa()
603 mutex_unlock(&bond->ipsec_lock); in bond_ipsec_del_sa()
608 struct net_device *bond_dev = bond->dev; in bond_ipsec_del_sa_all()
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()
618 mutex_lock(&bond->ipsec_lock); in bond_ipsec_del_sa_all()
619 list_for_each_entry(ipsec, &bond->ipsec_list, list) { in bond_ipsec_del_sa_all()
620 if (!ipsec->xs->xso.real_dev) in bond_ipsec_del_sa_all()
623 if (!real_dev->xfrmdev_ops || in bond_ipsec_del_sa_all()
624 !real_dev->xfrmdev_ops->xdo_dev_state_delete || in bond_ipsec_del_sa_all()
630 real_dev->xfrmdev_ops->xdo_dev_state_delete(ipsec->xs); in bond_ipsec_del_sa_all()
631 if (real_dev->xfrmdev_ops->xdo_dev_state_free) in bond_ipsec_del_sa_all()
632 real_dev->xfrmdev_ops->xdo_dev_state_free(ipsec->xs); in bond_ipsec_del_sa_all()
635 mutex_unlock(&bond->ipsec_lock); in bond_ipsec_del_sa_all()
640 struct net_device *bond_dev = xs->xso.dev; in bond_ipsec_free_sa()
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()
659 if (!xs->xso.real_dev) in bond_ipsec_free_sa()
662 WARN_ON(xs->xso.real_dev != real_dev); in bond_ipsec_free_sa()
664 if (real_dev && real_dev->xfrmdev_ops && in bond_ipsec_free_sa()
665 real_dev->xfrmdev_ops->xdo_dev_state_free) in bond_ipsec_free_sa()
666 real_dev->xfrmdev_ops->xdo_dev_state_free(xs); in bond_ipsec_free_sa()
672 * bond_ipsec_offload_ok - can this packet use the xfrm hw offload
686 if (!real_dev->xfrmdev_ops || in bond_ipsec_offload_ok()
687 !real_dev->xfrmdev_ops->xdo_dev_offload_ok || in bond_ipsec_offload_ok()
691 ok = real_dev->xfrmdev_ops->xdo_dev_offload_ok(skb, xs); in bond_ipsec_offload_ok()
698 * bond_advance_esn_state - ESN support for IPSec HW offload
710 if (!real_dev->xfrmdev_ops || in bond_advance_esn_state()
711 !real_dev->xfrmdev_ops->xdo_dev_state_advance_esn) { in bond_advance_esn_state()
712 …pr_warn_ratelimited("%s: %s doesn't support xdo_dev_state_advance_esn\n", __func__, real_dev->name… in bond_advance_esn_state()
716 real_dev->xfrmdev_ops->xdo_dev_state_advance_esn(xs); in bond_advance_esn_state()
722 * bond_xfrm_update_stats - Update xfrm state
734 if (!real_dev->xfrmdev_ops || in bond_xfrm_update_stats()
735 !real_dev->xfrmdev_ops->xdo_dev_state_update_stats) { in bond_xfrm_update_stats()
736 …pr_warn_ratelimited("%s: %s doesn't support xdo_dev_state_update_stats\n", __func__, real_dev->nam… in bond_xfrm_update_stats()
740 real_dev->xfrmdev_ops->xdo_dev_state_update_stats(xs); in bond_xfrm_update_stats()
755 /*------------------------------- Link status -------------------------------*/
775 if (slave->link == BOND_LINK_UP) { in bond_set_carrier()
776 if (!netif_carrier_ok(bond->dev)) { in bond_set_carrier()
777 netif_carrier_on(bond->dev); in bond_set_carrier()
785 if (netif_carrier_ok(bond->dev)) { in bond_set_carrier()
786 netif_carrier_off(bond->dev); in bond_set_carrier()
794 * values are invalid, set speed and duplex to -1,
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()
810 if (ecmd.base.speed == 0 || ecmd.base.speed == ((__u32)-1)) 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()
842 /* if <dev> supports MII link status reporting, check its link status.
844 * We either do MII/ETHTOOL ioctls, or check netif_carrier_ok(),
851 * If reporting is non-zero, instead of faking link up, return -1 if
852 * both ETHTOOL and MII ioctls fail (meaning the device does not
860 const struct net_device_ops *slave_ops = slave_dev->netdev_ops; in bond_check_dev_link()
863 struct mii_ioctl_data *mii; in bond_check_dev_link() local
868 if (bond->params.use_carrier) in bond_check_dev_link()
872 if (slave_dev->ethtool_ops->get_link) in bond_check_dev_link()
873 return slave_dev->ethtool_ops->get_link(slave_dev) ? in bond_check_dev_link()
876 /* Ethtool can't be used, fallback to MII ioctls. */ in bond_check_dev_link()
877 ioctl = slave_ops->ndo_eth_ioctl; in bond_check_dev_link()
891 /* Yes, the mii is overlaid on the ifreq.ifr_ifru */ in bond_check_dev_link()
892 strscpy_pad(ifr.ifr_name, slave_dev->name, IFNAMSIZ); in bond_check_dev_link()
893 mii = if_mii(&ifr); in bond_check_dev_link()
895 mii->reg_num = MII_BMSR; in bond_check_dev_link()
897 return mii->val_out & BMSR_LSTATUS; in bond_check_dev_link()
906 return reporting ? -1 : BMSR_LSTATUS; in bond_check_dev_link()
909 /*----------------------------- Multicast list ------------------------------*/
918 struct slave *curr_active = rtnl_dereference(bond->curr_active_slave); in bond_set_promiscuity()
921 err = dev_set_promiscuity(curr_active->dev, inc); 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()
944 err = dev_set_allmulti(curr_active->dev, inc); in bond_set_allmulti()
949 err = dev_set_allmulti(slave->dev, inc); in bond_set_allmulti()
967 queue_delayed_work(bond->wq, &bond->mcast_work, 1); in bond_resend_igmp_join_requests_delayed()
970 call_netdevice_notifiers(NETDEV_RESEND_IGMP, bond->dev); in bond_resend_igmp_join_requests_delayed()
972 if (bond->igmp_retrans > 1) { in bond_resend_igmp_join_requests_delayed()
973 bond->igmp_retrans--; in bond_resend_igmp_join_requests_delayed()
974 queue_delayed_work(bond->wq, &bond->mcast_work, HZ/5); in bond_resend_igmp_join_requests_delayed()
992 /*--------------------------- Active slave change ---------------------------*/
1003 if (bond->dev->flags & IFF_PROMISC) in bond_hw_addr_swap()
1004 dev_set_promiscuity(old_active->dev, -1); in bond_hw_addr_swap()
1006 if (bond->dev->flags & IFF_ALLMULTI) in bond_hw_addr_swap()
1007 dev_set_allmulti(old_active->dev, -1); in bond_hw_addr_swap()
1009 if (bond->dev->flags & IFF_UP) in bond_hw_addr_swap()
1010 bond_hw_addr_flush(bond->dev, old_active->dev); in bond_hw_addr_swap()
1017 if (bond->dev->flags & IFF_PROMISC) in bond_hw_addr_swap()
1018 dev_set_promiscuity(new_active->dev, 1); in bond_hw_addr_swap()
1020 if (bond->dev->flags & IFF_ALLMULTI) in bond_hw_addr_swap()
1021 dev_set_allmulti(new_active->dev, 1); in bond_hw_addr_swap()
1023 if (bond->dev->flags & IFF_UP) { in bond_hw_addr_swap()
1024 netif_addr_lock_bh(bond->dev); in bond_hw_addr_swap()
1025 dev_uc_sync(new_active->dev, bond->dev); in bond_hw_addr_swap()
1026 dev_mc_sync(new_active->dev, bond->dev); in bond_hw_addr_swap()
1027 netif_addr_unlock_bh(bond->dev); in bond_hw_addr_swap()
1035 * bond_set_dev_addr - clone slave's address to bond
1046 slave_dbg(bond_dev, slave_dev, "bond_dev=%p slave_dev=%p slave_dev->addr_len=%d\n", in bond_set_dev_addr()
1047 bond_dev, slave_dev, slave_dev->addr_len); in bond_set_dev_addr()
1048 err = dev_pre_changeaddr_notify(bond_dev, slave_dev->dev_addr, NULL); in bond_set_dev_addr()
1052 __dev_addr_set(bond_dev, slave_dev->dev_addr, slave_dev->addr_len); in bond_set_dev_addr()
1053 bond_dev->addr_assign_type = NET_ADDR_STOLEN; in bond_set_dev_addr()
1068 if (ether_addr_equal(bond->dev->dev_addr, slave->dev->dev_addr)) in bond_get_old_active()
1089 switch (bond->params.fail_over_mac) { in bond_do_fail_over_mac()
1092 rv = bond_set_dev_addr(bond->dev, new_active->dev); in bond_do_fail_over_mac()
1094 slave_err(bond->dev, new_active->dev, "Error %d setting bond MAC from slave\n", in bond_do_fail_over_mac()
1095 -rv); in bond_do_fail_over_mac()
1110 bond_hw_addr_copy(tmp_mac, new_active->dev->dev_addr, in bond_do_fail_over_mac()
1111 new_active->dev->addr_len); in bond_do_fail_over_mac()
1113 old_active->dev->dev_addr, in bond_do_fail_over_mac()
1114 old_active->dev->addr_len); in bond_do_fail_over_mac()
1115 ss.ss_family = new_active->dev->type; in bond_do_fail_over_mac()
1117 bond_hw_addr_copy(ss.__data, bond->dev->dev_addr, in bond_do_fail_over_mac()
1118 bond->dev->addr_len); in bond_do_fail_over_mac()
1119 ss.ss_family = bond->dev->type; in bond_do_fail_over_mac()
1122 rv = dev_set_mac_address(new_active->dev, in bond_do_fail_over_mac()
1125 slave_err(bond->dev, new_active->dev, "Error %d setting MAC of new active slave\n", in bond_do_fail_over_mac()
1126 -rv); in bond_do_fail_over_mac()
1134 new_active->dev->addr_len); in bond_do_fail_over_mac()
1135 ss.ss_family = old_active->dev->type; in bond_do_fail_over_mac()
1137 rv = dev_set_mac_address(old_active->dev, in bond_do_fail_over_mac()
1140 slave_err(bond->dev, old_active->dev, "Error %d setting MAC of old active slave\n", in bond_do_fail_over_mac()
1141 -rv); in bond_do_fail_over_mac()
1145 netdev_err(bond->dev, "bond_do_fail_over_mac impossible: bad policy %d\n", in bond_do_fail_over_mac()
1146 bond->params.fail_over_mac); in bond_do_fail_over_mac()
1153 * bond_choose_primary_or_current - select the primary or high priority slave
1156 * - Check if there is a primary link. If the primary link was set and is up,
1159 * - If primary link is not set or down, find the highest priority link.
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()
1170 if (!prim || prim->link != BOND_LINK_UP) { in bond_choose_primary_or_current()
1172 if (slave->link == BOND_LINK_UP) { in bond_choose_primary_or_current()
1174 if (slave->prio > hprio->prio) in bond_choose_primary_or_current()
1184 if (!curr || curr->link != BOND_LINK_UP) in bond_choose_primary_or_current()
1189 if (bond->force_primary) { in bond_choose_primary_or_current()
1190 bond->force_primary = false; in bond_choose_primary_or_current()
1195 if (!curr || curr->link != BOND_LINK_UP) in bond_choose_primary_or_current()
1199 switch (bond->params.primary_reselect) { in bond_choose_primary_or_current()
1203 if (prim->speed < curr->speed) in bond_choose_primary_or_current()
1205 if (prim->speed == curr->speed && prim->duplex <= curr->duplex) in bond_choose_primary_or_current()
1211 netdev_err(bond->dev, "impossible primary_reselect %d\n", in bond_choose_primary_or_current()
1212 bond->params.primary_reselect); in bond_choose_primary_or_current()
1218 * bond_find_best_slave - select the best available slave to be the active one
1225 int mintime = bond->params.updelay; in bond_find_best_slave()
1232 if (slave->link == BOND_LINK_UP) 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()
1247 struct slave *slave = rcu_dereference_rtnl(bond->curr_active_slave); in bond_should_notify_peers()
1249 if (!slave || !bond->send_peer_notif || in bond_should_notify_peers()
1250 bond->send_peer_notif % in bond_should_notify_peers()
1251 max(1, bond->params.peer_notif_delay) != 0 || in bond_should_notify_peers()
1252 !netif_carrier_ok(bond->dev) || in bond_should_notify_peers()
1253 test_bit(__LINK_STATE_LINKWATCH_PENDING, &slave->dev->state)) in bond_should_notify_peers()
1256 netdev_dbg(bond->dev, "bond_should_notify_peers: slave %s\n", in bond_should_notify_peers()
1257 slave ? slave->dev->name : "NULL"); in bond_should_notify_peers()
1263 * bond_change_active_slave - change the active slave into the specified one
1269 * Setting include flags, mc-list, promiscuity, allmulti, etc.
1283 old_active = rtnl_dereference(bond->curr_active_slave); in bond_change_active_slave()
1293 new_active->last_link_up = jiffies; in bond_change_active_slave()
1295 if (new_active->link == BOND_LINK_BACK) { in bond_change_active_slave()
1297 slave_info(bond->dev, new_active->dev, "making interface the new active one %d ms earlier\n", in bond_change_active_slave()
1298 (bond->params.updelay - new_active->delay) * bond->params.miimon); in bond_change_active_slave()
1301 new_active->delay = 0; in bond_change_active_slave()
1312 slave_info(bond->dev, new_active->dev, "making interface the new active one\n"); in bond_change_active_slave()
1328 rcu_assign_pointer(bond->curr_active_slave, new_active); in bond_change_active_slave()
1342 if (bond->params.fail_over_mac) in bond_change_active_slave()
1346 if (netif_running(bond->dev)) { in bond_change_active_slave()
1347 bond->send_peer_notif = in bond_change_active_slave()
1348 bond->params.num_peer_notif * in bond_change_active_slave()
1349 max(1, bond->params.peer_notif_delay); in bond_change_active_slave()
1354 call_netdevice_notifiers(NETDEV_BONDING_FAILOVER, bond->dev); in bond_change_active_slave()
1356 bond->send_peer_notif--; in bond_change_active_slave()
1358 bond->dev); in bond_change_active_slave()
1372 if (netif_running(bond->dev) && (bond->params.resend_igmp > 0) && in bond_change_active_slave()
1375 bond->igmp_retrans = bond->params.resend_igmp; in bond_change_active_slave()
1376 queue_delayed_work(bond->wq, &bond->mcast_work, 1); in bond_change_active_slave()
1381 * bond_select_active_slave - select a new active slave, if needed
1385 * - The old curr_active_slave has been released or lost its link.
1386 * - The primary_slave has got its link back.
1387 * - A slave has got its link back and there's no old curr_active_slave.
1399 if (best_slave != rtnl_dereference(bond->curr_active_slave)) { in bond_select_active_slave()
1405 if (netif_carrier_ok(bond->dev)) in bond_select_active_slave()
1406 netdev_info(bond->dev, "active interface up!\n"); in bond_select_active_slave()
1408 netdev_info(bond->dev, "now running without any active interface!\n"); in bond_select_active_slave()
1419 err = -ENOMEM; in slave_enable_netpoll()
1423 err = __netpoll_setup(np, slave->dev); in slave_enable_netpoll()
1428 slave->np = np; in slave_enable_netpoll()
1434 struct netpoll *np = slave->np; in slave_disable_netpoll()
1439 slave->np = NULL; in slave_disable_netpoll()
1461 SLAVE_AD_INFO(slave)->port.aggregator; in bond_poll_controller()
1464 agg->aggregator_identifier != ad_info.aggregator_id) in bond_poll_controller()
1468 netpoll_poll_dev(slave->dev); in bond_poll_controller()
1512 /*---------------------------------- IOCTL ----------------------------------*/
1529 slave->dev->features, in bond_fix_features()
1558 struct net_device *bond_dev = bond->dev; in bond_compute_features()
1572 slave->dev->vlan_features, BOND_VLAN_FEATURES); in bond_compute_features()
1575 slave->dev->hw_enc_features, in bond_compute_features()
1580 slave->dev->hw_enc_features, in bond_compute_features()
1585 slave->dev->mpls_features, in bond_compute_features()
1588 dst_release_flag &= slave->dev->priv_flags; in bond_compute_features()
1589 if (slave->dev->hard_header_len > max_hard_header_len) in bond_compute_features()
1590 max_hard_header_len = slave->dev->hard_header_len; in bond_compute_features()
1592 tso_max_size = min(tso_max_size, slave->dev->tso_max_size); in bond_compute_features()
1593 tso_max_segs = min(tso_max_segs, slave->dev->tso_max_segs); in bond_compute_features()
1595 bond_dev->hard_header_len = max_hard_header_len; in bond_compute_features()
1598 bond_dev->vlan_features = vlan_features; in bond_compute_features()
1599 bond_dev->hw_enc_features = enc_features | NETIF_F_GSO_ENCAP_ALL | in bond_compute_features()
1603 bond_dev->hw_enc_features |= xfrm_features; in bond_compute_features()
1605 bond_dev->mpls_features = mpls_features; in bond_compute_features()
1609 bond_dev->priv_flags &= ~IFF_XMIT_DST_RELEASE; in bond_compute_features()
1610 if ((bond_dev->priv_flags & IFF_XMIT_DST_RELEASE_PERM) && in bond_compute_features()
1612 bond_dev->priv_flags |= IFF_XMIT_DST_RELEASE; in bond_compute_features()
1620 bool was_up = !!(bond_dev->flags & IFF_UP); in bond_setup_by_slave()
1624 bond_dev->header_ops = slave_dev->header_ops; in bond_setup_by_slave()
1626 bond_dev->type = slave_dev->type; in bond_setup_by_slave()
1627 bond_dev->hard_header_len = slave_dev->hard_header_len; in bond_setup_by_slave()
1628 bond_dev->needed_headroom = slave_dev->needed_headroom; in bond_setup_by_slave()
1629 bond_dev->addr_len = slave_dev->addr_len; in bond_setup_by_slave()
1631 memcpy(bond_dev->broadcast, slave_dev->broadcast, in bond_setup_by_slave()
1632 slave_dev->addr_len); in bond_setup_by_slave()
1634 if (slave_dev->flags & IFF_POINTOPOINT) { in bond_setup_by_slave()
1635 bond_dev->flags &= ~(IFF_BROADCAST | IFF_MULTICAST); in bond_setup_by_slave()
1636 bond_dev->flags |= (IFF_POINTOPOINT | IFF_NOARP); in bond_setup_by_slave()
1643 * duplicates except for alb non-mcast/bcast.
1651 skb->pkt_type != PACKET_BROADCAST && in bond_should_deliver_exact_match()
1652 skb->pkt_type != PACKET_MULTICAST) in bond_should_deliver_exact_match()
1674 slave = bond_slave_get_rcu(skb->dev); in bond_handle_frame()
1675 bond = slave->bond; in bond_handle_frame()
1677 recv_probe = READ_ONCE(bond->recv_probe); in bond_handle_frame()
1688 * be suppressed we want to make an exception for link-local packets. in bond_handle_frame()
1694 * (including link-local ones) can have their originating interface in bond_handle_frame()
1698 if (is_link_local_ether_addr(eth_hdr(skb)->h_dest)) in bond_handle_frame()
1703 skb->dev = bond->dev; in bond_handle_frame()
1706 netif_is_bridge_port(bond->dev) && in bond_handle_frame()
1707 skb->pkt_type == PACKET_HOST) { in bond_handle_frame()
1710 skb->data - skb_mac_header(skb)))) { in bond_handle_frame()
1714 bond_hw_addr_copy(eth_hdr(skb)->h_dest, bond->dev->dev_addr, in bond_handle_frame()
1715 bond->dev->addr_len); in bond_handle_frame()
1744 switch (bond->params.xmit_policy) { in bond_lag_hash_type()
1773 err = netdev_master_upper_dev_link(slave->dev, bond->dev, slave, in bond_master_upper_dev_link()
1778 slave->dev->flags |= IFF_SLAVE; in bond_master_upper_dev_link()
1784 netdev_upper_dev_unlink(slave->dev, bond->dev); in bond_upper_dev_unlink()
1785 slave->dev->flags &= ~IFF_SLAVE; in bond_upper_dev_unlink()
1793 cancel_delayed_work_sync(&slave->notify_work); in slave_kobj_release()
1811 err = kobject_init_and_add(&slave->kobj, &slave_ktype, in bond_kobj_init()
1812 &(slave->dev->dev.kobj), "bonding_slave"); in bond_kobj_init()
1814 kobject_put(&slave->kobj); in bond_kobj_init()
1828 slave->bond = bond; in bond_alloc_slave()
1829 slave->dev = slave_dev; in bond_alloc_slave()
1830 INIT_DELAYED_WORK(&slave->notify_work, bond_netdev_notify_work); in bond_alloc_slave()
1839 kobject_put(&slave->kobj); in bond_alloc_slave()
1849 info->bond_mode = BOND_MODE(bond); in bond_fill_ifbond()
1850 info->miimon = bond->params.miimon; in bond_fill_ifbond()
1851 info->num_slaves = bond->slave_cnt; in bond_fill_ifbond()
1856 strcpy(info->slave_name, slave->dev->name); in bond_fill_ifslave()
1857 info->link = slave->link; in bond_fill_ifslave()
1858 info->state = bond_slave_state(slave); in bond_fill_ifslave()
1859 info->link_failure_count = slave->link_failure_count; in bond_fill_ifslave()
1871 bond_fill_ifbond(slave->bond, &binfo.master); in bond_netdev_notify_work()
1872 netdev_bonding_info_change(slave->dev, &binfo); in bond_netdev_notify_work()
1875 queue_delayed_work(slave->bond->wq, &slave->notify_work, 1); in bond_netdev_notify_work()
1881 queue_delayed_work(slave->bond->wq, &slave->notify_work, 0); in bond_queue_slave_event()
1888 info.link_up = slave->link == BOND_LINK_UP || in bond_lower_state_changed()
1889 slave->link == BOND_LINK_FAIL; in bond_lower_state_changed()
1891 netdev_lower_state_changed(slave->dev, &info); in bond_lower_state_changed()
1915 unsigned int flags = bond_dev->flags & (IFF_SLAVE | IFF_UP); in bond_ether_setup()
1918 bond_dev->flags |= IFF_MASTER | flags; in bond_ether_setup()
1919 bond_dev->priv_flags &= ~IFF_TX_SKB_SHARING; in bond_ether_setup()
1937 val &= slave->dev->xdp_features; in bond_xdp_set_features()
1949 const struct net_device_ops *slave_ops = slave_dev->netdev_ops; in bond_enslave()
1955 if (slave_dev->flags & IFF_MASTER && in bond_enslave()
1959 return -EPERM; in bond_enslave()
1962 if (!bond->params.use_carrier && in bond_enslave()
1963 slave_dev->ethtool_ops->get_link == NULL && in bond_enslave()
1964 slave_ops->ndo_eth_ioctl == NULL) { in bond_enslave()
1968 /* already in-use? */ in bond_enslave()
1972 return -EBUSY; in bond_enslave()
1977 return -EPERM; in bond_enslave()
1982 if (slave_dev->features & NETIF_F_VLAN_CHALLENGED) { in bond_enslave()
1987 return -EPERM; in bond_enslave()
1995 if (slave_dev->features & NETIF_F_HW_ESP) in bond_enslave()
1996 slave_dbg(bond_dev, slave_dev, "is esp-hw-offload capable\n"); in bond_enslave()
2003 if (slave_dev->flags & IFF_UP) { in bond_enslave()
2006 return -EPERM; in bond_enslave()
2009 /* set bonding device ether type by slave - bonding netdevices are in bond_enslave()
2013 * bond ether type mutual exclusion - don't allow slaves of dissimilar in bond_enslave()
2017 if (bond_dev->type != slave_dev->type) { in bond_enslave()
2019 bond_dev->type, slave_dev->type); in bond_enslave()
2026 return -EBUSY; in bond_enslave()
2033 if (slave_dev->type != ARPHRD_ETHER) in bond_enslave()
2041 } else if (bond_dev->type != slave_dev->type) { in bond_enslave()
2044 return -EINVAL; in bond_enslave()
2047 if (slave_dev->type == ARPHRD_INFINIBAND && in bond_enslave()
2050 "Only active-backup mode is supported for infiniband slaves"); in bond_enslave()
2051 res = -EOPNOTSUPP; in bond_enslave()
2055 if (!slave_ops->ndo_set_mac_address || in bond_enslave()
2056 slave_dev->type == ARPHRD_INFINIBAND) { in bond_enslave()
2059 bond->params.fail_over_mac != BOND_FOM_ACTIVE) { in bond_enslave()
2061 bond->params.fail_over_mac = BOND_FOM_ACTIVE; in bond_enslave()
2062 slave_warn(bond_dev, slave_dev, "Setting fail_over_mac to active for active-backup mode\n"); in bond_enslave()
2066 res = -EOPNOTSUPP; in bond_enslave()
2078 bond->dev->addr_assign_type == NET_ADDR_RANDOM) { in bond_enslave()
2079 res = bond_set_dev_addr(bond->dev, slave_dev); in bond_enslave()
2086 res = -ENOMEM; in bond_enslave()
2093 new_slave->queue_id = 0; in bond_enslave()
2096 new_slave->original_mtu = slave_dev->mtu; in bond_enslave()
2097 res = dev_set_mtu(slave_dev, bond->dev->mtu); in bond_enslave()
2107 bond_hw_addr_copy(new_slave->perm_hwaddr, slave_dev->dev_addr, in bond_enslave()
2108 slave_dev->addr_len); in bond_enslave()
2110 if (!bond->params.fail_over_mac || in bond_enslave()
2115 memcpy(ss.__data, bond_dev->dev_addr, bond_dev->addr_len); in bond_enslave()
2116 ss.ss_family = slave_dev->type; in bond_enslave()
2126 slave_dev->priv_flags |= IFF_NO_ADDRCONF; in bond_enslave()
2135 slave_dev->priv_flags |= IFF_BONDING; in bond_enslave()
2137 dev_get_stats(new_slave->dev, &new_slave->slave_stats); in bond_enslave()
2156 new_slave->delay = 0; in bond_enslave()
2157 new_slave->link_failure_count = 0; in bond_enslave()
2161 new_slave->link = BOND_LINK_DOWN; in bond_enslave()
2163 new_slave->last_rx = jiffies - in bond_enslave()
2164 (msecs_to_jiffies(bond->params.arp_interval) + 1); in bond_enslave()
2166 new_slave->target_last_arp_rx[i] = new_slave->last_rx; in bond_enslave()
2168 new_slave->last_tx = new_slave->last_rx; in bond_enslave()
2170 if (bond->params.miimon && !bond->params.use_carrier) { in bond_enslave()
2173 if ((link_reporting == -1) && !bond->params.arp_interval) { in bond_enslave()
2175 * does not support ETHTOOL/MII and in bond_enslave()
2182 …slave_warn(bond_dev, slave_dev, "MII and ETHTOOL support not available for slave, and arp_interval… in bond_enslave()
2183 } else if (link_reporting == -1) { in bond_enslave()
2184 /* unable get link status using mii/ethtool */ in bond_enslave()
2185 … slave; the network driver associated with this interface does not support MII or ETHTOOL link sta… in bond_enslave()
2190 new_slave->link = BOND_LINK_NOCHANGE; in bond_enslave()
2191 if (bond->params.miimon) { in bond_enslave()
2193 if (bond->params.updelay) { in bond_enslave()
2197 new_slave->delay = bond->params.updelay; in bond_enslave()
2207 } else if (bond->params.arp_interval) { in bond_enslave()
2217 if (new_slave->link != BOND_LINK_DOWN) in bond_enslave()
2218 new_slave->last_link_up = jiffies; in bond_enslave()
2220 new_slave->link == BOND_LINK_DOWN ? "DOWN" : in bond_enslave()
2221 (new_slave->link == BOND_LINK_UP ? "UP" : "BACK")); in bond_enslave()
2223 if (bond_uses_primary(bond) && bond->params.primary[0]) { in bond_enslave()
2225 if (strcmp(bond->params.primary, new_slave->dev->name) == 0) { in bond_enslave()
2226 rcu_assign_pointer(bond->primary_slave, new_slave); in bond_enslave()
2227 bond->force_primary = true; in bond_enslave()
2244 SLAVE_AD_INFO(new_slave)->id = 1; in bond_enslave()
2250 SLAVE_AD_INFO(new_slave)->id = in bond_enslave()
2251 SLAVE_AD_INFO(prev_slave)->id + 1; in bond_enslave()
2271 if (!rcu_access_pointer(bond->curr_active_slave) && in bond_enslave()
2272 new_slave->link == BOND_LINK_UP) in bond_enslave()
2273 rcu_assign_pointer(bond->curr_active_slave, new_slave); in bond_enslave()
2279 if (bond->dev->npinfo) { in bond_enslave()
2282 res = -EBUSY; in bond_enslave()
2288 if (!(bond_dev->features & NETIF_F_LRO)) in bond_enslave()
2317 if (bond_dev->flags & IFF_PROMISC) { in bond_enslave()
2324 if (bond_dev->flags & IFF_ALLMULTI) { in bond_enslave()
2327 if (bond_dev->flags & IFF_PROMISC) in bond_enslave()
2328 dev_set_promiscuity(slave_dev, -1); in bond_enslave()
2333 if (bond_dev->flags & IFF_UP) { in bond_enslave()
2344 bond->slave_cnt++; in bond_enslave()
2362 if (!slave_dev->netdev_ops->ndo_bpf || in bond_enslave()
2363 !slave_dev->netdev_ops->ndo_xdp_xmit) { in bond_enslave()
2364 if (bond->xdp_prog) { in bond_enslave()
2367 res = -EOPNOTSUPP; in bond_enslave()
2370 } else if (bond->xdp_prog) { in bond_enslave()
2374 .prog = bond->xdp_prog, in bond_enslave()
2381 res = -EOPNOTSUPP; in bond_enslave()
2391 if (bond->xdp_prog) in bond_enslave()
2392 bpf_prog_inc(bond->xdp_prog); in bond_enslave()
2399 new_slave->link != BOND_LINK_DOWN ? "an up" : "a down"); in bond_enslave()
2417 if (rcu_access_pointer(bond->primary_slave) == new_slave) in bond_enslave()
2418 RCU_INIT_POINTER(bond->primary_slave, NULL); in bond_enslave()
2419 if (rcu_access_pointer(bond->curr_active_slave) == new_slave) { in bond_enslave()
2431 slave_dev->priv_flags &= ~IFF_BONDING; in bond_enslave()
2435 slave_dev->priv_flags &= ~IFF_NO_ADDRCONF; in bond_enslave()
2436 if (!bond->params.fail_over_mac || in bond_enslave()
2438 /* XXX TODO - fom follow mode needs to change master's in bond_enslave()
2442 bond_hw_addr_copy(ss.__data, new_slave->perm_hwaddr, in bond_enslave()
2443 new_slave->dev->addr_len); in bond_enslave()
2444 ss.ss_family = slave_dev->type; in bond_enslave()
2449 dev_set_mtu(slave_dev, new_slave->original_mtu); in bond_enslave()
2452 kobject_put(&new_slave->kobj); in bond_enslave()
2457 if (ether_addr_equal_64bits(bond_dev->dev_addr, in bond_enslave()
2458 slave_dev->dev_addr)) in bond_enslave()
2460 if (bond_dev->type != ARPHRD_ETHER) { in bond_enslave()
2471 * is RTNL-locked. If "all" is true it means that the function is being called
2487 int old_flags = bond_dev->flags; in __bond_release_one()
2488 netdev_features_t old_features = bond_dev->features; in __bond_release_one()
2491 if (!(slave_dev->flags & IFF_SLAVE) || in __bond_release_one()
2494 return -EINVAL; in __bond_release_one()
2504 return -EINVAL; in __bond_release_one()
2512 bond_get_stats(bond->dev, &bond->bond_stats); in __bond_release_one()
2514 if (bond->xdp_prog) { in __bond_release_one()
2541 oldcurrent = rcu_access_pointer(bond->curr_active_slave); in __bond_release_one()
2543 RCU_INIT_POINTER(bond->current_arp_slave, NULL); in __bond_release_one()
2545 if (!all && (!bond->params.fail_over_mac || in __bond_release_one()
2547 if (ether_addr_equal_64bits(bond_dev->dev_addr, slave->perm_hwaddr) && in __bond_release_one()
2549 …slave_warn(bond_dev, slave_dev, "the permanent HWaddr of slave - %pM - is still in use by bond - s… in __bond_release_one()
2550 slave->perm_hwaddr); in __bond_release_one()
2553 if (rtnl_dereference(bond->primary_slave) == slave) in __bond_release_one()
2554 RCU_INIT_POINTER(bond->primary_slave, NULL); in __bond_release_one()
2575 RCU_INIT_POINTER(bond->curr_active_slave, NULL); in __bond_release_one()
2590 bond->slave_cnt--; in __bond_release_one()
2593 call_netdevice_notifiers(NETDEV_CHANGEADDR, bond->dev); in __bond_release_one()
2594 call_netdevice_notifiers(NETDEV_RELEASE, bond->dev); in __bond_release_one()
2598 if (!(bond_dev->features & NETIF_F_VLAN_CHALLENGED) && in __bond_release_one()
2600 …slave_info(bond_dev, slave_dev, "last VLAN challenged slave left bond - VLAN blocking is removed\n… in __bond_release_one()
2616 dev_set_promiscuity(slave_dev, -1); in __bond_release_one()
2620 dev_set_allmulti(slave_dev, -1); in __bond_release_one()
2631 slave_dev->priv_flags &= ~IFF_NO_ADDRCONF; in __bond_release_one()
2633 if (bond->params.fail_over_mac != BOND_FOM_ACTIVE || in __bond_release_one()
2636 bond_hw_addr_copy(ss.__data, slave->perm_hwaddr, in __bond_release_one()
2637 slave->dev->addr_len); in __bond_release_one()
2638 ss.ss_family = slave_dev->type; in __bond_release_one()
2643 __dev_set_mtu(slave_dev, slave->original_mtu); in __bond_release_one()
2645 dev_set_mtu(slave_dev, slave->original_mtu); in __bond_release_one()
2648 slave_dev->priv_flags &= ~IFF_BONDING; in __bond_release_one()
2651 kobject_put(&slave->kobj); in __bond_release_one()
2673 bond_dev->reg_state != NETREG_UNREGISTERING) { in bond_release_and_destroy()
2674 bond_dev->priv_flags |= IFF_DISABLE_NETPOLL; in bond_release_and_destroy()
2693 int i = 0, res = -ENODEV; in bond_slave_info_query()
2697 if (i++ == (int)info->slave_id) { in bond_slave_info_query()
2707 /*-------------------------------- Monitoring -------------------------------*/
2718 ignore_updelay = !rcu_dereference(bond->curr_active_slave); in bond_miimon_inspect()
2722 usable_slaves = rcu_dereference(bond->usable_slaves); in bond_miimon_inspect()
2724 if (usable_slaves && usable_slaves->count == 0) in bond_miimon_inspect()
2731 link_state = bond_check_dev_link(bond, slave->dev, 0); in bond_miimon_inspect()
2733 switch (slave->link) { in bond_miimon_inspect()
2740 slave->delay = bond->params.downdelay; in bond_miimon_inspect()
2741 if (slave->delay && net_ratelimit()) { in bond_miimon_inspect()
2742 slave_info(bond->dev, slave->dev, "link status down for %sinterface, disabling it in %d ms\n", in bond_miimon_inspect()
2747 bond->params.downdelay * bond->params.miimon); in bond_miimon_inspect()
2754 slave->last_link_up = jiffies; in bond_miimon_inspect()
2756 slave_info(bond->dev, slave->dev, "link status up again after %d ms\n", in bond_miimon_inspect()
2757 (bond->params.downdelay - slave->delay) * in bond_miimon_inspect()
2758 bond->params.miimon); in bond_miimon_inspect()
2763 if (slave->delay <= 0) { in bond_miimon_inspect()
2769 slave->delay--; in bond_miimon_inspect()
2778 slave->delay = bond->params.updelay; in bond_miimon_inspect()
2780 if (slave->delay && net_ratelimit()) { in bond_miimon_inspect()
2781 slave_info(bond->dev, slave->dev, "link status up, enabling it in %d ms\n", in bond_miimon_inspect()
2783 bond->params.updelay * in bond_miimon_inspect()
2784 bond->params.miimon); in bond_miimon_inspect()
2791 slave_info(bond->dev, slave->dev, "link status down again after %d ms\n", in bond_miimon_inspect()
2792 (bond->params.updelay - slave->delay) * in bond_miimon_inspect()
2793 bond->params.miimon); in bond_miimon_inspect()
2799 slave->delay = 0; in bond_miimon_inspect()
2801 if (slave->delay <= 0) { in bond_miimon_inspect()
2808 slave->delay--; in bond_miimon_inspect()
2843 switch (slave->link_new_state) { in bond_miimon_commit()
2852 slave->link == BOND_LINK_UP) in bond_miimon_commit()
2859 slave->link = BOND_LINK_DOWN; in bond_miimon_commit()
2861 slave_warn(bond->dev, slave->dev, in bond_miimon_commit()
2867 slave->last_link_up = jiffies; in bond_miimon_commit()
2869 primary = rtnl_dereference(bond->primary_slave); in bond_miimon_commit()
2878 slave_info(bond->dev, slave->dev, "link status definitely up, %u Mbps %s duplex\n", in bond_miimon_commit()
2879 slave->speed == SPEED_UNKNOWN ? 0 : slave->speed, in bond_miimon_commit()
2880 slave->duplex ? "full" : "half"); in bond_miimon_commit()
2884 active = rtnl_dereference(bond->curr_active_slave); in bond_miimon_commit()
2885 if (!active || slave == primary || slave->prio > active->prio) in bond_miimon_commit()
2891 if (slave->link_failure_count < UINT_MAX) in bond_miimon_commit()
2892 slave->link_failure_count++; in bond_miimon_commit()
2902 slave_info(bond->dev, slave->dev, "link status definitely down, disabling slave\n"); in bond_miimon_commit()
2906 if (slave == rcu_access_pointer(bond->curr_active_slave)) in bond_miimon_commit()
2912 slave_err(bond->dev, slave->dev, "invalid new link %d on slave\n", in bond_miimon_commit()
2913 slave->link_new_state); in bond_miimon_commit()
2931 * Really a wrapper that splits the mii monitor into two phases: an
2946 delay = msecs_to_jiffies(bond->params.miimon); in bond_mii_monitor()
2954 if (bond->send_peer_notif) { in bond_mii_monitor()
2957 bond->send_peer_notif--; in bond_mii_monitor()
2981 if (bond->params.miimon) in bond_mii_monitor()
2982 queue_delayed_work(bond->wq, &bond->mii_work, delay); in bond_mii_monitor()
2987 call_netdevice_notifiers(NETDEV_NOTIFY_PEERS, bond->dev); in bond_mii_monitor()
2995 __be32 ip = *(__be32 *)priv->data; in bond_upper_dev_walk()
3007 if (ip == bond_confirm_addr(bond->dev, 0, ip)) in bond_has_this_ip()
3011 if (netdev_walk_all_upper_dev_rcu(bond->dev, bond_upper_dev_walk, &priv)) in bond_has_this_ip()
3023 struct net_device *bond_dev = slave->bond->dev; in bond_handle_vlan()
3024 struct net_device *slave_dev = slave->dev; in bond_handle_vlan()
3027 if (!tags || tags->vlan_proto == BOND_VLAN_PROTO_NONE) in bond_handle_vlan()
3033 while (tags->vlan_proto != BOND_VLAN_PROTO_NONE) { in bond_handle_vlan()
3034 if (!tags->vlan_id) { in bond_handle_vlan()
3040 ntohs(outer_tag->vlan_proto), tags->vlan_id); in bond_handle_vlan()
3041 skb = vlan_insert_tag_set_proto(skb, tags->vlan_proto, in bond_handle_vlan()
3042 tags->vlan_id); in bond_handle_vlan()
3051 if (outer_tag->vlan_id) { in bond_handle_vlan()
3053 ntohs(outer_tag->vlan_proto), outer_tag->vlan_id); in bond_handle_vlan()
3054 __vlan_hwaccel_put_tag(skb, outer_tag->vlan_proto, in bond_handle_vlan()
3055 outer_tag->vlan_id); in bond_handle_vlan()
3063 * "native" to a VLAN) might not pass non-tagged frames.
3068 struct net_device *bond_dev = slave->bond->dev; in bond_arp_send()
3069 struct net_device *slave_dev = slave->dev; in bond_arp_send()
3076 NULL, slave_dev->dev_addr, NULL); in bond_arp_send()
3108 return ERR_PTR(-ENOMEM); in bond_verify_device_path()
3133 struct rtable *rt; in bond_arp_send_all() local
3135 __be32 *targets = bond->params.arp_targets, addr; in bond_arp_send_all()
3139 slave_dbg(bond->dev, slave->dev, "%s: target %pI4\n", in bond_arp_send_all()
3144 rt = ip_route_output(dev_net(bond->dev), targets[i], 0, 0, 0, in bond_arp_send_all()
3146 if (IS_ERR(rt)) { in bond_arp_send_all()
3147 /* there's no route to target - try to send arp in bond_arp_send_all()
3150 if (bond->params.arp_validate) in bond_arp_send_all()
3152 bond->dev->name, in bond_arp_send_all()
3160 if (rt->dst.dev == bond->dev) in bond_arp_send_all()
3164 tags = bond_verify_device_path(bond->dev, rt->dst.dev, 0); in bond_arp_send_all()
3170 /* Not our device - skip */ in bond_arp_send_all()
3171 slave_dbg(bond->dev, slave->dev, "no path to arp_ip_target %pI4 via rt.dev %s\n", in bond_arp_send_all()
3172 &targets[i], rt->dst.dev ? rt->dst.dev->name : "NULL"); in bond_arp_send_all()
3174 ip_rt_put(rt); in bond_arp_send_all()
3178 addr = bond_confirm_addr(rt->dst.dev, targets[i], 0); in bond_arp_send_all()
3179 ip_rt_put(rt); in bond_arp_send_all()
3190 slave_dbg(bond->dev, slave->dev, "%s: sip %pI4 tip %pI4 not found\n", in bond_validate_arp()
3195 i = bond_get_targets_ip(bond->params.arp_targets, sip); in bond_validate_arp()
3196 if (i == -1) { in bond_validate_arp()
3197 slave_dbg(bond->dev, slave->dev, "%s: sip %pI4 not found in targets\n", in bond_validate_arp()
3201 slave->last_rx = jiffies; in bond_validate_arp()
3202 slave->target_last_arp_rx[i] = jiffies; in bond_validate_arp()
3208 struct arphdr *arp = (struct arphdr *)skb->data; in bond_arp_rcv()
3214 alen = arp_hdr_len(bond->dev); in bond_arp_rcv()
3224 if (arp->ar_hln != bond->dev->addr_len || in bond_arp_rcv()
3225 skb->pkt_type == PACKET_OTHERHOST || in bond_arp_rcv()
3226 skb->pkt_type == PACKET_LOOPBACK || in bond_arp_rcv()
3227 arp->ar_hrd != htons(ARPHRD_ETHER) || in bond_arp_rcv()
3228 arp->ar_pro != htons(ETH_P_IP) || in bond_arp_rcv()
3229 arp->ar_pln != 4) in bond_arp_rcv()
3233 arp_ptr += bond->dev->addr_len; in bond_arp_rcv()
3235 arp_ptr += 4 + bond->dev->addr_len; in bond_arp_rcv()
3238 slave_dbg(bond->dev, slave->dev, "%s: %s/%d av %d sv %d sip %pI4 tip %pI4\n", in bond_arp_rcv()
3239 __func__, slave->dev->name, bond_slave_state(slave), in bond_arp_rcv()
3240 bond->params.arp_validate, slave_do_arp_validate(bond, slave), in bond_arp_rcv()
3243 curr_active_slave = rcu_dereference(bond->curr_active_slave); in bond_arp_rcv()
3244 curr_arp_slave = rcu_dereference(bond->current_arp_slave); in bond_arp_rcv()
3273 curr_active_slave->last_link_up)) in bond_arp_rcv()
3275 else if (curr_arp_slave && (arp->ar_op == htons(ARPOP_REPLY)) && in bond_arp_rcv()
3280 if (arp != (struct arphdr *)skb->data) in bond_arp_rcv()
3289 struct net_device *bond_dev = slave->bond->dev; in bond_ns_send()
3290 struct net_device *slave_dev = slave->dev; in bond_ns_send()
3312 struct in6_addr *targets = bond->params.ns_targets; in bond_ns_send_all()
3320 slave_dbg(bond->dev, slave->dev, "%s: target %pI6c\n", in bond_ns_send_all()
3327 fl6.flowi6_oif = bond->dev->ifindex; in bond_ns_send_all()
3329 dst = ip6_route_output(dev_net(bond->dev), NULL, &fl6); in bond_ns_send_all()
3330 if (dst->error) { in bond_ns_send_all()
3332 /* there's no route to target - try to send arp in bond_ns_send_all()
3335 if (bond->params.arp_validate) in bond_ns_send_all()
3337 bond->dev->name, in bond_ns_send_all()
3344 if (dst->dev == bond->dev) in bond_ns_send_all()
3348 tags = bond_verify_device_path(bond->dev, dst->dev, 0); in bond_ns_send_all()
3354 /* Not our device - skip */ in bond_ns_send_all()
3355 slave_dbg(bond->dev, slave->dev, "no path to ns_ip6_target %pI6c via dst->dev %s\n", in bond_ns_send_all()
3356 &targets[i], dst->dev ? dst->dev->name : "NULL"); in bond_ns_send_all()
3362 if (!ipv6_dev_get_saddr(dev_net(dst->dev), dst->dev, &targets[i], 0, &saddr)) in bond_ns_send_all()
3375 struct in6_addr *addr = (struct in6_addr *)priv->data; in bond_confirm_addr6()
3387 if (bond_confirm_addr6(bond->dev, &priv)) in bond_has_this_ip6()
3391 if (netdev_walk_all_upper_dev_rcu(bond->dev, bond_confirm_addr6, &priv)) in bond_has_this_ip6()
3405 * 2. Dest address is neither all-nodes multicast address nor in bond_validate_na()
3411 slave_dbg(bond->dev, slave->dev, "%s: sip %pI6c tip %pI6c not found\n", in bond_validate_na()
3416 i = bond_get_targets_ip6(bond->params.ns_targets, saddr); in bond_validate_na()
3417 if (i == -1) { in bond_validate_na()
3418 slave_dbg(bond->dev, slave->dev, "%s: sip %pI6c not found in targets\n", in bond_validate_na()
3422 slave->last_rx = jiffies; in bond_validate_na()
3423 slave->target_last_arp_rx[i] = jiffies; in bond_validate_na()
3436 if (skb->pkt_type == PACKET_OTHERHOST || in bond_na_rcv()
3437 skb->pkt_type == PACKET_LOOPBACK) in bond_na_rcv()
3441 if (!combined || combined->ip6.nexthdr != NEXTHDR_ICMP || in bond_na_rcv()
3442 (combined->icmp6.icmp6_type != NDISC_NEIGHBOUR_SOLICITATION && in bond_na_rcv()
3443 combined->icmp6.icmp6_type != NDISC_NEIGHBOUR_ADVERTISEMENT)) in bond_na_rcv()
3446 saddr = &combined->ip6.saddr; in bond_na_rcv()
3447 daddr = &combined->ip6.daddr; in bond_na_rcv()
3449 slave_dbg(bond->dev, slave->dev, "%s: %s/%d av %d sv %d sip %pI6c tip %pI6c\n", in bond_na_rcv()
3450 __func__, slave->dev->name, bond_slave_state(slave), in bond_na_rcv()
3451 bond->params.arp_validate, slave_do_arp_validate(bond, slave), in bond_na_rcv()
3454 curr_active_slave = rcu_dereference(bond->curr_active_slave); in bond_na_rcv()
3455 curr_arp_slave = rcu_dereference(bond->current_arp_slave); in bond_na_rcv()
3464 curr_active_slave->last_link_up)) in bond_na_rcv()
3479 bool is_ipv6 = skb->protocol == __cpu_to_be16(ETH_P_IPV6); in bond_rcv_validate()
3481 bool is_arp = skb->protocol == __cpu_to_be16(ETH_P_ARP); in bond_rcv_validate()
3483 slave_dbg(bond->dev, slave->dev, "%s: skb->dev %s\n", in bond_rcv_validate()
3484 __func__, skb->dev->name); in bond_rcv_validate()
3493 slave->last_rx = jiffies; in bond_rcv_validate()
3515 * (last_act - arp_interval) <= jiffies <= (last_act + mod * arp_interval +
3521 int delta_in_ticks = msecs_to_jiffies(bond->params.arp_interval); in bond_time_in_interval()
3524 last_act - delta_in_ticks, in bond_time_in_interval()
3530 * is used in load-balancing mode. if the adapter has been dormant, then an
3545 oldcurrent = rcu_dereference(bond->curr_active_slave); in bond_loadbalance_arp_mon()
3548 * the picture unless it is null. also, slave->last_link_up is not in bond_loadbalance_arp_mon()
3559 if (slave->link != BOND_LINK_UP) { in bond_loadbalance_arp_mon()
3561 bond_time_in_interval(bond, slave->last_rx, 1)) { in bond_loadbalance_arp_mon()
3566 /* primary_slave has no meaning in round-robin in bond_loadbalance_arp_mon()
3572 slave_info(bond->dev, slave->dev, "link status definitely up\n"); in bond_loadbalance_arp_mon()
3575 slave_info(bond->dev, slave->dev, "interface is now up\n"); in bond_loadbalance_arp_mon()
3579 /* slave->link == BOND_LINK_UP */ in bond_loadbalance_arp_mon()
3585 if (!bond_time_in_interval(bond, last_tx, bond->params.missed_max) || in bond_loadbalance_arp_mon()
3586 !bond_time_in_interval(bond, slave->last_rx, bond->params.missed_max)) { in bond_loadbalance_arp_mon()
3591 if (slave->link_failure_count < UINT_MAX) in bond_loadbalance_arp_mon()
3592 slave->link_failure_count++; in bond_loadbalance_arp_mon()
3594 slave_info(bond->dev, slave->dev, "interface is now down\n"); in bond_loadbalance_arp_mon()
3601 /* note: if switch is in round-robin mode, all links in bond_loadbalance_arp_mon()
3602 * must tx arp to ensure all links rx an arp - otherwise in bond_loadbalance_arp_mon()
3605 * do - all replies will be rx'ed on same link causing slaves in bond_loadbalance_arp_mon()
3619 if (slave->link_new_state != BOND_LINK_NOCHANGE) in bond_loadbalance_arp_mon()
3620 slave->link = slave->link_new_state; in bond_loadbalance_arp_mon()
3637 if (bond->params.arp_interval) in bond_loadbalance_arp_mon()
3638 queue_delayed_work(bond->wq, &bond->arp_work, in bond_loadbalance_arp_mon()
3639 msecs_to_jiffies(bond->params.arp_interval)); in bond_loadbalance_arp_mon()
3642 /* Called to inspect slaves for active-backup mode ARP monitor link state
3660 if (slave->link != BOND_LINK_UP) { in bond_ab_arp_inspect()
3664 } else if (slave->link == BOND_LINK_BACK) { in bond_ab_arp_inspect()
3675 if (bond_time_in_interval(bond, slave->last_link_up, 2)) in bond_ab_arp_inspect()
3679 * - No current_arp_slave AND in bond_ab_arp_inspect()
3680 * - more than (missed_max+1)*delta since last receive AND in bond_ab_arp_inspect()
3681 * - the bond has an IP address in bond_ab_arp_inspect()
3683 * Note: a non-null current_arp_slave indicates in bond_ab_arp_inspect()
3686 * we only take the curr_active_slave down - this in bond_ab_arp_inspect()
3691 !rcu_access_pointer(bond->current_arp_slave) && in bond_ab_arp_inspect()
3692 !bond_time_in_interval(bond, last_rx, bond->params.missed_max + 1)) { in bond_ab_arp_inspect()
3698 * - more than missed_max*delta since transmitting OR in bond_ab_arp_inspect()
3699 * - (more than missed_max*delta since receive AND in bond_ab_arp_inspect()
3704 (!bond_time_in_interval(bond, last_tx, bond->params.missed_max) || in bond_ab_arp_inspect()
3705 !bond_time_in_interval(bond, last_rx, bond->params.missed_max))) { in bond_ab_arp_inspect()
3715 * active-backup mode ARP monitor.
3727 switch (slave->link_new_state) { in bond_ab_arp_commit()
3733 if (rtnl_dereference(bond->curr_active_slave) != slave || in bond_ab_arp_commit()
3734 (!rtnl_dereference(bond->curr_active_slave) && in bond_ab_arp_commit()
3738 current_arp_slave = rtnl_dereference(bond->current_arp_slave); in bond_ab_arp_commit()
3745 RCU_INIT_POINTER(bond->current_arp_slave, NULL); in bond_ab_arp_commit()
3748 slave_info(bond->dev, slave->dev, "link status definitely up\n"); in bond_ab_arp_commit()
3750 if (!rtnl_dereference(bond->curr_active_slave) || in bond_ab_arp_commit()
3751 slave == rtnl_dereference(bond->primary_slave) || in bond_ab_arp_commit()
3752 slave->prio > rtnl_dereference(bond->curr_active_slave)->prio) in bond_ab_arp_commit()
3760 if (slave->link_failure_count < UINT_MAX) in bond_ab_arp_commit()
3761 slave->link_failure_count++; in bond_ab_arp_commit()
3768 slave_info(bond->dev, slave->dev, "link status definitely down, disabling slave\n"); in bond_ab_arp_commit()
3770 if (slave == rtnl_dereference(bond->curr_active_slave)) { in bond_ab_arp_commit()
3771 RCU_INIT_POINTER(bond->current_arp_slave, NULL); in bond_ab_arp_commit()
3786 if (rtnl_dereference(bond->curr_active_slave)) in bond_ab_arp_commit()
3787 RCU_INIT_POINTER(bond->current_arp_slave, NULL); in bond_ab_arp_commit()
3791 slave_err(bond->dev, slave->dev, in bond_ab_arp_commit()
3793 slave->link_new_state); in bond_ab_arp_commit()
3807 /* Send ARP probes for active-backup mode ARP monitor.
3814 *curr_arp_slave = rcu_dereference(bond->current_arp_slave), in bond_ab_arp_probe()
3815 *curr_active_slave = rcu_dereference(bond->curr_active_slave); in bond_ab_arp_probe()
3821 netdev_info(bond->dev, "PROBE: c_arp %s && cas %s BAD\n", in bond_ab_arp_probe()
3822 curr_arp_slave->dev->name, in bond_ab_arp_probe()
3823 curr_active_slave->dev->name); in bond_ab_arp_probe()
3848 * mark it down - this can happen if we have in bond_ab_arp_probe()
3854 if (!bond_slave_is_up(slave) && slave->link == BOND_LINK_UP) { in bond_ab_arp_probe()
3857 if (slave->link_failure_count < UINT_MAX) in bond_ab_arp_probe()
3858 slave->link_failure_count++; in bond_ab_arp_probe()
3863 slave_info(bond->dev, slave->dev, "backup interface is now down\n"); in bond_ab_arp_probe()
3879 new_slave->last_link_up = jiffies; in bond_ab_arp_probe()
3880 rcu_assign_pointer(bond->current_arp_slave, new_slave); in bond_ab_arp_probe()
3884 if (slave->should_notify || slave->should_notify_link) { in bond_ab_arp_probe()
3898 delta_in_ticks = msecs_to_jiffies(bond->params.arp_interval); in bond_activebackup_arp_mon()
3927 if (bond->params.arp_interval) in bond_activebackup_arp_mon()
3928 queue_delayed_work(bond->wq, &bond->arp_work, delta_in_ticks); in bond_activebackup_arp_mon()
3935 bond->send_peer_notif--; in bond_activebackup_arp_mon()
3937 bond->dev); in bond_activebackup_arp_mon()
3959 /*-------------------------- netdev event handling --------------------------*/
4014 bond_dev = slave->bond->dev; in bond_slave_netdev_event()
4015 bond = slave->bond; in bond_slave_netdev_event()
4016 primary = rtnl_dereference(bond->primary_slave); in bond_slave_netdev_event()
4022 if (bond_dev->type != ARPHRD_ETHER) in bond_slave_netdev_event()
4031 * in weird state. Mark it as link-fail if the link was in bond_slave_netdev_event()
4032 * previously up or link-down if it hasn't yet come up, and in bond_slave_netdev_event()
4033 * let link-monitoring (miimon) set it right when correct in bond_slave_netdev_event()
4038 if (slave->last_link_up) in bond_slave_netdev_event()
4039 slave->link = BOND_LINK_FAIL; in bond_slave_netdev_event()
4041 slave->link = BOND_LINK_DOWN; in bond_slave_netdev_event()
4048 /* Refresh slave-array if applicable! in bond_slave_netdev_event()
4049 * If the setup does not use miimon or arpmon (mode-specific!), in bond_slave_netdev_event()
4050 * then these events will not cause the slave-array to be in bond_slave_netdev_event()
4062 * an active-backup bond, slaves need in bond_slave_netdev_event()
4075 !bond->params.primary[0]) in bond_slave_netdev_event()
4079 /* slave's name changed - he's no longer primary */ in bond_slave_netdev_event()
4080 RCU_INIT_POINTER(bond->primary_slave, NULL); in bond_slave_netdev_event()
4081 } else if (!strcmp(slave_dev->name, bond->params.primary)) { in bond_slave_netdev_event()
4083 rcu_assign_pointer(bond->primary_slave, slave); in bond_slave_netdev_event()
4084 } else { /* we didn't change primary - exit */ in bond_slave_netdev_event()
4088 netdev_info(bond->dev, "Primary slave changed to %s, reselecting active slave\n", in bond_slave_netdev_event()
4089 primary ? slave_dev->name : "none"); in bond_slave_netdev_event()
4096 if (!bond->notifier_ctx) { in bond_slave_netdev_event()
4097 bond->notifier_ctx = true; in bond_slave_netdev_event()
4099 bond->notifier_ctx = false; in bond_slave_netdev_event()
4104 call_netdevice_notifiers(event, slave->bond->dev); in bond_slave_netdev_event()
4131 if (!(event_dev->priv_flags & IFF_BONDING)) in bond_netdev_event()
4134 if (event_dev->flags & IFF_MASTER) { in bond_netdev_event()
4142 if (event_dev->flags & IFF_SLAVE) in bond_netdev_event()
4152 /*---------------------------- Hashing Policies -----------------------------*/
4163 return skb->data; in bond_pull_data()
4178 return ep->h_dest[5] ^ ep->h_source[5] ^ be16_to_cpu(ep->h_proto); in bond_eth_hash()
4194 *nhoff += iph->ihl << 2; in bond_flow_ip()
4196 *ip_proto = iph->protocol; in bond_flow_ip()
4205 *ip_proto = iph6->nexthdr; in bond_flow_ip()
4211 fk->ports.ports = __skb_flow_get_ports(skb, *nhoff, *ip_proto, data, hlen); in bond_flow_ip()
4229 srcmac_vendor = (srcmac_vendor << 8) | mac_hdr->h_source[i]; in bond_vlan_srcmac_hash()
4232 srcmac_dev = (srcmac_dev << 8) | mac_hdr->h_source[i]; in bond_vlan_srcmac_hash()
4244 bool l34 = bond->params.xmit_policy == BOND_XMIT_POLICY_LAYER34; in bond_flow_dissect()
4245 int ip_proto = -1; in bond_flow_dissect()
4247 switch (bond->params.xmit_policy) { in bond_flow_dissect()
4257 fk->ports.ports = 0; in bond_flow_dissect()
4258 memset(&fk->icmp, 0, sizeof(fk->icmp)); in bond_flow_dissect()
4268 skb_flow_get_icmp_tci(skb, &fk->icmp, data, nhoff, hlen); in bond_flow_dissect()
4270 if (!icmp_is_err(fk->icmp.type)) in bond_flow_dissect()
4275 if (!icmpv6_is_err(fk->icmp.type)) in bond_flow_dissect()
4311 if (bond->params.xmit_policy == BOND_XMIT_POLICY_VLAN_SRCMAC) in __bond_xmit_hash()
4314 if (bond->params.xmit_policy == BOND_XMIT_POLICY_LAYER2 || in __bond_xmit_hash()
4318 if (bond->params.xmit_policy == BOND_XMIT_POLICY_LAYER23 || in __bond_xmit_hash()
4319 bond->params.xmit_policy == BOND_XMIT_POLICY_ENCAP23) { in __bond_xmit_hash()
4328 return bond_ip_hash(hash, &flow, bond->params.xmit_policy); in __bond_xmit_hash()
4332 * bond_xmit_hash - generate a hash value based on the xmit policy
4341 if (bond->params.xmit_policy == BOND_XMIT_POLICY_ENCAP34 && in bond_xmit_hash()
4342 skb->l4_hash) in bond_xmit_hash()
4343 return skb->hash; in bond_xmit_hash()
4345 return __bond_xmit_hash(bond, skb, skb->data, skb->protocol, in bond_xmit_hash()
4351 * bond_xmit_hash_xdp - generate a hash value based on the xmit policy
4361 if (xdp->data + sizeof(struct ethhdr) > xdp->data_end) in bond_xmit_hash_xdp()
4364 eth = (struct ethhdr *)xdp->data; in bond_xmit_hash_xdp()
4366 return __bond_xmit_hash(bond, NULL, xdp->data, eth->h_proto, 0, in bond_xmit_hash_xdp()
4367 sizeof(struct ethhdr), xdp->data_end - xdp->data); in bond_xmit_hash_xdp()
4370 /*-------------------------- Device entry points ----------------------------*/
4374 INIT_DELAYED_WORK(&bond->mcast_work, in bond_work_init_all()
4376 INIT_DELAYED_WORK(&bond->alb_work, bond_alb_monitor); in bond_work_init_all()
4377 INIT_DELAYED_WORK(&bond->mii_work, bond_mii_monitor); in bond_work_init_all()
4378 INIT_DELAYED_WORK(&bond->arp_work, bond_arp_monitor); in bond_work_init_all()
4379 INIT_DELAYED_WORK(&bond->ad_work, bond_3ad_state_machine_handler); in bond_work_init_all()
4380 INIT_DELAYED_WORK(&bond->slave_arr_work, bond_slave_arr_handler); in bond_work_init_all()
4385 cancel_delayed_work_sync(&bond->mii_work); in bond_work_cancel_all()
4386 cancel_delayed_work_sync(&bond->arp_work); in bond_work_cancel_all()
4387 cancel_delayed_work_sync(&bond->alb_work); in bond_work_cancel_all()
4388 cancel_delayed_work_sync(&bond->ad_work); in bond_work_cancel_all()
4389 cancel_delayed_work_sync(&bond->mcast_work); in bond_work_cancel_all()
4390 cancel_delayed_work_sync(&bond->slave_arr_work); in bond_work_cancel_all()
4399 if (BOND_MODE(bond) == BOND_MODE_ROUNDROBIN && !bond->rr_tx_counter) { in bond_open()
4400 bond->rr_tx_counter = alloc_percpu(u32); in bond_open()
4401 if (!bond->rr_tx_counter) in bond_open()
4402 return -ENOMEM; in bond_open()
4405 /* reset slave->backup and slave->inactive */ in bond_open()
4409 slave != rcu_access_pointer(bond->curr_active_slave)) { in bond_open()
4424 return -ENOMEM; in bond_open()
4425 if (bond->params.tlb_dynamic_lb || BOND_MODE(bond) == BOND_MODE_ALB) in bond_open()
4426 queue_delayed_work(bond->wq, &bond->alb_work, 0); in bond_open()
4429 if (bond->params.miimon) /* link check interval, in milliseconds. */ in bond_open()
4430 queue_delayed_work(bond->wq, &bond->mii_work, 0); in bond_open()
4432 if (bond->params.arp_interval) { /* arp interval, in milliseconds. */ in bond_open()
4433 queue_delayed_work(bond->wq, &bond->arp_work, 0); in bond_open()
4434 bond->recv_probe = bond_rcv_validate; in bond_open()
4438 queue_delayed_work(bond->wq, &bond->ad_work, 0); in bond_open()
4440 bond->recv_probe = bond_3ad_lacpdu_recv; in bond_open()
4444 dev_mc_add(slave->dev, lacpdu_mcast_addr); in bond_open()
4459 bond->send_peer_notif = 0; in bond_close()
4462 bond->recv_probe = NULL; in bond_close()
4466 slave = rcu_dereference(bond->curr_active_slave); in bond_close()
4468 bond_hw_addr_flush(bond_dev, slave->dev); in bond_close()
4474 bond_hw_addr_flush(bond_dev, slave->dev); in bond_close()
4495 s64 delta = nv - ov; in bond_fold_stats()
4499 delta = (s64)(s32)((u32)nv - (u32)ov); in bond_fold_stats()
4517 iter = &dev->adj_list.lower; in bond_get_lowest_level_rcu()
4527 niter = &ldev->adj_list.lower; in bond_get_lowest_level_rcu()
4538 next = dev_stack[--cur]; in bond_get_lowest_level_rcu()
4565 spin_lock_nested(&bond->stats_lock, nest_level); in bond_get_stats()
4566 memcpy(stats, &bond->bond_stats, sizeof(*stats)); in bond_get_stats()
4570 dev_get_stats(slave->dev, &temp); in bond_get_stats()
4572 bond_fold_stats(stats, new, &slave->slave_stats); in bond_get_stats()
4575 memcpy(&slave->slave_stats, new, sizeof(*new)); in bond_get_stats()
4578 memcpy(&bond->bond_stats, stats, sizeof(*stats)); in bond_get_stats()
4579 spin_unlock(&bond->stats_lock); in bond_get_stats()
4586 struct mii_ioctl_data *mii = NULL; in bond_eth_ioctl() local
4592 mii = if_mii(ifr); in bond_eth_ioctl()
4593 if (!mii) in bond_eth_ioctl()
4594 return -EINVAL; in bond_eth_ioctl()
4596 mii->phy_id = 0; in bond_eth_ioctl()
4602 mii = if_mii(ifr); in bond_eth_ioctl()
4603 if (!mii) in bond_eth_ioctl()
4604 return -EINVAL; in bond_eth_ioctl()
4606 if (mii->reg_num == 1) { in bond_eth_ioctl()
4607 mii->val_out = 0; in bond_eth_ioctl()
4608 if (netif_carrier_ok(bond->dev)) in bond_eth_ioctl()
4609 mii->val_out = BMSR_LSTATUS; in bond_eth_ioctl()
4614 return -EOPNOTSUPP; in bond_eth_ioctl()
4636 u_binfo = (struct ifbond __user *)ifr->ifr_data; in bond_do_ioctl()
4639 return -EFAULT; in bond_do_ioctl()
4643 return -EFAULT; in bond_do_ioctl()
4647 u_sinfo = (struct ifslave __user *)ifr->ifr_data; in bond_do_ioctl()
4650 return -EFAULT; in bond_do_ioctl()
4655 return -EFAULT; in bond_do_ioctl()
4664 if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) in bond_do_ioctl()
4665 return -EPERM; in bond_do_ioctl()
4667 slave_dev = __dev_get_by_name(net, ifr->ifr_slave); in bond_do_ioctl()
4672 return -ENODEV; in bond_do_ioctl()
4685 bond_opt_initstr(&newval, slave_dev->name); in bond_do_ioctl()
4690 res = -EOPNOTSUPP; in bond_do_ioctl()
4716 return -EOPNOTSUPP; in bond_siocdevprivate()
4725 bond_dev->flags & IFF_PROMISC ? 1 : -1); in bond_change_rx_flags()
4729 bond_dev->flags & IFF_ALLMULTI ? 1 : -1); in bond_change_rx_flags()
4740 slave = rcu_dereference(bond->curr_active_slave); in bond_set_rx_mode()
4742 dev_uc_sync(slave->dev, bond_dev); in bond_set_rx_mode()
4743 dev_mc_sync(slave->dev, bond_dev); in bond_set_rx_mode()
4747 dev_uc_sync_multiple(slave->dev, bond_dev); in bond_set_rx_mode()
4748 dev_mc_sync_multiple(slave->dev, bond_dev); in bond_set_rx_mode()
4756 struct bonding *bond = netdev_priv(n->dev); in bond_neigh_init()
4766 slave_ops = slave->dev->netdev_ops; in bond_neigh_init()
4767 if (!slave_ops->ndo_neigh_setup) in bond_neigh_init()
4779 ret = slave_ops->ndo_neigh_setup(slave->dev, &parms); in bond_neigh_init()
4796 * underlying devices. In that case - do nothing, we're already set up from
4803 if (parms->dev == dev) in bond_neigh_setup()
4804 parms->neigh_setup = bond_neigh_init; in bond_neigh_setup()
4820 slave_dbg(bond_dev, slave->dev, "s %p c_m %p\n", in bond_change_mtu()
4821 slave, slave->dev->netdev_ops->ndo_change_mtu); in bond_change_mtu()
4823 res = dev_set_mtu(slave->dev, new_mtu); in bond_change_mtu()
4834 slave_dbg(bond_dev, slave->dev, "err %d setting mtu to %d\n", in bond_change_mtu()
4840 WRITE_ONCE(bond_dev->mtu, new_mtu); in bond_change_mtu()
4852 tmp_res = dev_set_mtu(rollback_slave->dev, bond_dev->mtu); in bond_change_mtu()
4854 slave_dbg(bond_dev, rollback_slave->dev, "unwind err %d\n", in bond_change_mtu()
4884 if (bond->params.fail_over_mac && in bond_set_mac_address()
4888 if (!is_valid_ether_addr(ss->__data)) in bond_set_mac_address()
4889 return -EADDRNOTAVAIL; in bond_set_mac_address()
4892 slave_dbg(bond_dev, slave->dev, "%s: slave=%p\n", in bond_set_mac_address()
4894 res = dev_set_mac_address(slave->dev, addr, NULL); in bond_set_mac_address()
4902 slave_dbg(bond_dev, slave->dev, "%s: err %d\n", in bond_set_mac_address()
4909 dev_addr_set(bond_dev, ss->__data); in bond_set_mac_address()
4913 memcpy(tmp_ss.__data, bond_dev->dev_addr, bond_dev->addr_len); in bond_set_mac_address()
4914 tmp_ss.ss_family = bond_dev->type; in bond_set_mac_address()
4923 tmp_res = dev_set_mac_address(rollback_slave->dev, in bond_set_mac_address()
4926 slave_dbg(bond_dev, rollback_slave->dev, "%s: unwind err %d\n", in bond_set_mac_address()
4935 * bond_get_slave_by_id - get xmit slave with slave_id
4937 * @slave_id: slave id up to slave_cnt-1 through which to transmit
4951 if (--i < 0) { in bond_get_slave_by_id()
4960 if (--i < 0) in bond_get_slave_by_id()
4970 * bond_rr_gen_slave_id - generate slave id based on packets_per_slave
4981 int packets_per_slave = bond->params.packets_per_slave; in bond_rr_gen_slave_id()
4988 slave_id = this_cpu_inc_return(*bond->rr_tx_counter); in bond_rr_gen_slave_id()
4992 bond->params.reciprocal_packets_per_slave; in bond_rr_gen_slave_id()
4993 slave_id = this_cpu_inc_return(*bond->rr_tx_counter); in bond_rr_gen_slave_id()
5015 if (skb->protocol == htons(ETH_P_IP)) { in bond_xmit_roundrobin_slave_get()
5023 if (iph->protocol == IPPROTO_IGMP) { in bond_xmit_roundrobin_slave_get()
5024 slave = rcu_dereference(bond->curr_active_slave); in bond_xmit_roundrobin_slave_get()
5032 slave_cnt = READ_ONCE(bond->slave_cnt); in bond_xmit_roundrobin_slave_get()
5047 void *data = xdp->data; in bond_xdp_xmit_roundrobin_slave_get()
5049 if (data + sizeof(struct ethhdr) > xdp->data_end) in bond_xdp_xmit_roundrobin_slave_get()
5056 if (eth->h_proto == htons(ETH_P_IP)) { in bond_xdp_xmit_roundrobin_slave_get()
5059 if (data + sizeof(struct iphdr) > xdp->data_end) in bond_xdp_xmit_roundrobin_slave_get()
5064 if (iph->protocol == IPPROTO_IGMP) { in bond_xdp_xmit_roundrobin_slave_get()
5065 slave = rcu_dereference(bond->curr_active_slave); in bond_xdp_xmit_roundrobin_slave_get()
5073 slave_cnt = READ_ONCE(bond->slave_cnt); in bond_xdp_xmit_roundrobin_slave_get()
5089 return bond_dev_queue_xmit(bond, skb, slave->dev); in bond_xmit_roundrobin()
5096 return rcu_dereference(bond->curr_active_slave); in bond_xmit_activebackup_slave_get()
5099 /* In active-backup mode, we know that bond->curr_active_slave is always valid if
5110 return bond_dev_queue_xmit(bond, skb, slave->dev); in bond_xmit_activebackup()
5121 queue_delayed_work(bond->wq, &bond->slave_arr_work, delay); in bond_slave_arr_work_rearm()
5157 * this to-be-skipped slave to send a packet out. in bond_skip_slave()
5159 for (idx = 0; slaves && idx < slaves->count; idx++) { in bond_skip_slave()
5160 if (skipslave == slaves->arr[idx]) { in bond_skip_slave()
5161 slaves->arr[idx] = in bond_skip_slave()
5162 slaves->arr[slaves->count - 1]; in bond_skip_slave()
5163 slaves->count--; in bond_skip_slave()
5175 usable = rtnl_dereference(bond->usable_slaves); in bond_set_slave_arr()
5176 rcu_assign_pointer(bond->usable_slaves, usable_slaves); in bond_set_slave_arr()
5179 all = rtnl_dereference(bond->all_slaves); in bond_set_slave_arr()
5180 rcu_assign_pointer(bond->all_slaves, all_slaves); in bond_set_slave_arr()
5189 /* Build the usable slaves array in control path for modes that use xmit-hash
5190 * to determine the slave interface -
5208 bond->slave_cnt), GFP_KERNEL); in bond_update_slave_arr()
5210 bond->slave_cnt), GFP_KERNEL); in bond_update_slave_arr()
5212 ret = -ENOMEM; in bond_update_slave_arr()
5218 spin_lock_bh(&bond->mode_lock); in bond_update_slave_arr()
5220 spin_unlock_bh(&bond->mode_lock); in bond_update_slave_arr()
5228 spin_unlock_bh(&bond->mode_lock); in bond_update_slave_arr()
5235 all_slaves->arr[all_slaves->count++] = slave; in bond_update_slave_arr()
5239 agg = SLAVE_AD_INFO(slave)->port.aggregator; in bond_update_slave_arr()
5240 if (!agg || agg->aggregator_identifier != agg_id) in bond_update_slave_arr()
5246 slave_dbg(bond->dev, slave->dev, "Adding slave to tx hash array[%d]\n", in bond_update_slave_arr()
5247 usable_slaves->count); in bond_update_slave_arr()
5249 usable_slaves->arr[usable_slaves->count++] = slave; in bond_update_slave_arr()
5256 bond_skip_slave(rtnl_dereference(bond->all_slaves), in bond_update_slave_arr()
5258 bond_skip_slave(rtnl_dereference(bond->usable_slaves), in bond_update_slave_arr()
5276 count = slaves ? READ_ONCE(slaves->count) : 0; in bond_xmit_3ad_xor_slave_get()
5280 slave = slaves->arr[hash % count]; in bond_xmit_3ad_xor_slave_get()
5292 slaves = rcu_dereference(bond->usable_slaves); in bond_xdp_xmit_3ad_xor_slave_get()
5293 count = slaves ? READ_ONCE(slaves->count) : 0; in bond_xdp_xmit_3ad_xor_slave_get()
5297 return slaves->arr[hash % count]; in bond_xdp_xmit_3ad_xor_slave_get()
5311 slaves = rcu_dereference(bond->usable_slaves); in bond_3ad_xor_xmit()
5314 return bond_dev_queue_xmit(bond, skb, slave->dev); in bond_3ad_xor_xmit()
5332 if (!(bond_slave_is_up(slave) && slave->link == BOND_LINK_UP)) in bond_xmit_broadcast()
5342 bond_dev->name, __func__); in bond_xmit_broadcast()
5347 if (bond_dev_queue_xmit(bond, skb2, slave->dev) == NETDEV_TX_OK) in bond_xmit_broadcast()
5361 /*------------------------- Device initialization ---------------------------*/
5375 if (READ_ONCE(slave->queue_id) == skb_get_queue_mapping(skb)) { in bond_slave_override()
5377 slave->link == BOND_LINK_UP) { in bond_slave_override()
5378 bond_dev_queue_xmit(bond, skb, slave->dev); in bond_slave_override()
5401 qdisc_skb_cb(skb)->slave_dev_queue_mapping = skb_get_queue_mapping(skb); in bond_select_queue()
5403 if (unlikely(txq >= dev->real_num_tx_queues)) { in bond_select_queue()
5405 txq -= dev->real_num_tx_queues; in bond_select_queue()
5406 } while (txq >= dev->real_num_tx_queues); in bond_select_queue()
5429 slaves = rcu_dereference(bond->all_slaves); in bond_xmit_get_slave()
5431 slaves = rcu_dereference(bond->usable_slaves); in bond_xmit_get_slave()
5449 return slave->dev; in bond_xmit_get_slave()
5455 switch (sk->sk_family) { in bond_sk_to_flow()
5459 ipv6_addr_type(&sk->sk_v6_daddr) != IPV6_ADDR_MAPPED) { in bond_sk_to_flow()
5460 flow->control.addr_type = FLOW_DISSECTOR_KEY_IPV6_ADDRS; in bond_sk_to_flow()
5461 flow->addrs.v6addrs.src = inet6_sk(sk)->saddr; in bond_sk_to_flow()
5462 flow->addrs.v6addrs.dst = sk->sk_v6_daddr; in bond_sk_to_flow()
5468 flow->control.addr_type = FLOW_DISSECTOR_KEY_IPV4_ADDRS; in bond_sk_to_flow()
5469 flow->addrs.v4addrs.src = inet_sk(sk)->inet_rcv_saddr; in bond_sk_to_flow()
5470 flow->addrs.v4addrs.dst = inet_sk(sk)->inet_daddr; in bond_sk_to_flow()
5474 flow->ports.src = inet_sk(sk)->inet_sport; in bond_sk_to_flow()
5475 flow->ports.dst = inet_sk(sk)->inet_dport; in bond_sk_to_flow()
5479 * bond_sk_hash_l34 - generate a hash value based on the socket's L3 and L4 fields
5507 slaves = rcu_dereference(bond->usable_slaves); in __bond_sk_get_lower_dev()
5508 count = slaves ? READ_ONCE(slaves->count) : 0; in __bond_sk_get_lower_dev()
5513 slave = slaves->arr[hash % count]; in __bond_sk_get_lower_dev()
5515 return slave->dev; in __bond_sk_get_lower_dev()
5536 struct net_device *tls_netdev = rcu_dereference(tls_get_ctx(skb->sk)->netdev); in bond_tls_device_xmit()
5634 return slave->dev; in bond_xdp_get_xmit_slave()
5642 int nxmit, err = -ENXIO; in bond_xdp_xmit()
5656 err = -ENXIO; in bond_xdp_xmit()
5660 err = slave_dev->netdev_ops->ndo_xdp_xmit(slave_dev, 1, frames1, flags); in bond_xdp_xmit()
5694 return -EOPNOTSUPP; in bond_xdp_set()
5696 old_prog = bond->xdp_prog; in bond_xdp_set()
5697 bond->xdp_prog = prog; in bond_xdp_set()
5700 struct net_device *slave_dev = slave->dev; in bond_xdp_set()
5702 if (!slave_dev->netdev_ops->ndo_bpf || in bond_xdp_set()
5703 !slave_dev->netdev_ops->ndo_xdp_xmit) { in bond_xdp_set()
5706 err = -EOPNOTSUPP; in bond_xdp_set()
5713 err = -EOPNOTSUPP; in bond_xdp_set()
5738 bond->xdp_prog = old_prog; in bond_xdp_set()
5743 struct net_device *slave_dev = rollback_slave->dev; in bond_xdp_set()
5761 switch (xdp->command) { in bond_xdp()
5763 return bond_xdp_set(dev, xdp->prog, xdp->extack); in bond_xdp()
5765 return -EINVAL; in bond_xdp()
5772 speed = slave->speed; in bond_mode_bcast_speed()
5774 speed = min(speed, slave->speed); in bond_mode_bcast_speed()
5782 struct ifreq *ifr = kernel_cfg->ifr; in bond_set_phc_index_flag()
5785 if (kernel_cfg->copied_to_user) { in bond_set_phc_index_flag()
5787 if (copy_from_user(&cfg, ifr->ifr_data, sizeof(cfg))) in bond_set_phc_index_flag()
5788 return -EFAULT; in bond_set_phc_index_flag()
5791 if (copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg))) in bond_set_phc_index_flag()
5792 return -EFAULT; in bond_set_phc_index_flag()
5794 kernel_cfg->flags |= HWTSTAMP_FLAG_BONDED_PHC_INDEX; in bond_set_phc_index_flag()
5809 return -EOPNOTSUPP; in bond_hwtstamp_get()
5826 if (!(cfg->flags & HWTSTAMP_FLAG_BONDED_PHC_INDEX)) in bond_hwtstamp_set()
5827 return -EOPNOTSUPP; in bond_hwtstamp_set()
5831 return -EOPNOTSUPP; in bond_hwtstamp_set()
5848 cmd->base.duplex = DUPLEX_UNKNOWN; in bond_ethtool_get_link_ksettings()
5849 cmd->base.port = PORT_OTHER; in bond_ethtool_get_link_ksettings()
5859 if (slave->speed != SPEED_UNKNOWN) { in bond_ethtool_get_link_ksettings()
5864 speed += slave->speed; in bond_ethtool_get_link_ksettings()
5866 if (cmd->base.duplex == DUPLEX_UNKNOWN && in bond_ethtool_get_link_ksettings()
5867 slave->duplex != DUPLEX_UNKNOWN) in bond_ethtool_get_link_ksettings()
5868 cmd->base.duplex = slave->duplex; in bond_ethtool_get_link_ksettings()
5871 cmd->base.speed = speed ? : SPEED_UNKNOWN; in bond_ethtool_get_link_ksettings()
5879 strscpy(drvinfo->driver, DRV_NAME, sizeof(drvinfo->driver)); in bond_ethtool_get_drvinfo()
5880 snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), "%d", in bond_ethtool_get_drvinfo()
5906 ret = ethtool_get_ts_info_by_layer(slave->dev, &ts_info); in bond_ethtool_get_ts_info()
5919 info->so_timestamping |= SOF_TIMESTAMPING_TX_SOFTWARE; in bond_ethtool_get_ts_info()
5976 if (bond->wq) in bond_destructor()
5977 destroy_workqueue(bond->wq); in bond_destructor()
5979 free_percpu(bond->rr_tx_counter); in bond_destructor()
5986 spin_lock_init(&bond->mode_lock); in bond_setup()
5987 bond->params = bonding_defaults; in bond_setup()
5990 bond->dev = bond_dev; in bond_setup()
5994 bond_dev->max_mtu = ETH_MAX_MTU; in bond_setup()
5995 bond_dev->netdev_ops = &bond_netdev_ops; in bond_setup()
5996 bond_dev->ethtool_ops = &bond_ethtool_ops; in bond_setup()
5998 bond_dev->needs_free_netdev = true; in bond_setup()
5999 bond_dev->priv_destructor = bond_destructor; in bond_setup()
6004 bond_dev->flags |= IFF_MASTER; in bond_setup()
6005 bond_dev->priv_flags |= IFF_BONDING | IFF_UNICAST_FLT | IFF_NO_QUEUE; in bond_setup()
6006 bond_dev->priv_flags &= ~(IFF_XMIT_DST_RELEASE | IFF_TX_SKB_SHARING); in bond_setup()
6009 /* set up xfrm device ops (only supported in active-backup right now) */ in bond_setup()
6010 bond_dev->xfrmdev_ops = &bond_xfrmdev_ops; in bond_setup()
6011 INIT_LIST_HEAD(&bond->ipsec_list); in bond_setup()
6012 mutex_init(&bond->ipsec_lock); in bond_setup()
6016 bond_dev->lltx = true; in bond_setup()
6019 bond_dev->netns_local = true; in bond_setup()
6028 bond_dev->hw_features = BOND_VLAN_FEATURES | in bond_setup()
6034 bond_dev->hw_features |= NETIF_F_GSO_ENCAP_ALL; in bond_setup()
6035 bond_dev->features |= bond_dev->hw_features; in bond_setup()
6036 bond_dev->features |= NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX; in bond_setup()
6038 bond_dev->hw_features |= BOND_XFRM_FEATURES; in bond_setup()
6039 /* Only enable XFRM features if this is an active-backup config */ in bond_setup()
6041 bond_dev->features |= BOND_XFRM_FEATURES; in bond_setup()
6058 __bond_release_one(bond_dev, slave->dev, true, true); in bond_uninit()
6062 mutex_destroy(&bond->ipsec_lock); in bond_uninit()
6067 list_del_rcu(&bond->bond_list); in bond_uninit()
6072 /*------------------------- Module initialization ---------------------------*/
6095 return -EINVAL; in bond_check_params()
6097 bond_mode = valptr->value; in bond_check_params()
6113 return -EINVAL; in bond_check_params()
6115 xmit_hashtype = valptr->value; in bond_check_params()
6130 return -EINVAL; in bond_check_params()
6132 lacp_fast = valptr->value; in bond_check_params()
6142 return -EINVAL; in bond_check_params()
6144 params->ad_select = valptr->value; in bond_check_params()
6148 params->ad_select = BOND_AD_STABLE; in bond_check_params()
6152 …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()
6158 pr_warn("Warning: miimon module parameter (%d), not in range 0-%d, so it was reset to 0\n", in bond_check_params()
6164 pr_warn("Warning: updelay module parameter (%d), not in range 0-%d, so it was reset to 0\n", in bond_check_params()
6170 pr_warn("Warning: downdelay module parameter (%d), not in range 0-%d, so it was reset to 0\n", in bond_check_params()
6182 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()
6259 pr_warn("Warning: arp_interval module parameter (%d), not in range 0-%d, so it was reset to 0\n", in bond_check_params()
6269 if (!in4_pton(arp_ip_target[i], -1, (u8 *)&ip, -1, NULL) || in bond_check_params()
6275 if (bond_get_targets_ip(arp_target, ip) == -1) in bond_check_params()
6293 return -EINVAL; in bond_check_params()
6302 return -EINVAL; in bond_check_params()
6304 arp_validate_value = valptr->value; in bond_check_params()
6318 arp_all_targets_value = valptr->value; in bond_check_params()
6323 pr_info("MII link monitoring set to %d ms\n", miimon); in bond_check_params()
6328 arp_interval, valptr->string, arp_ip_count); in bond_check_params()
6358 return -EINVAL; in bond_check_params()
6360 primary_reselect_value = valptr->value; in bond_check_params()
6372 return -EINVAL; in bond_check_params()
6374 fail_over_mac_value = valptr->value; in bond_check_params()
6376 pr_warn("Warning: fail_over_mac only affects active-backup mode\n"); in bond_check_params()
6387 return -EINVAL; in bond_check_params()
6389 ad_actor_sys_prio = valptr->value; in bond_check_params()
6395 return -EINVAL; in bond_check_params()
6397 ad_user_port_key = valptr->value; in bond_check_params()
6403 return -EINVAL; in bond_check_params()
6405 tlb_dynamic_lb = valptr->value; in bond_check_params()
6414 params->mode = bond_mode; in bond_check_params()
6415 params->xmit_policy = xmit_hashtype; in bond_check_params()
6416 params->miimon = miimon; in bond_check_params()
6417 params->num_peer_notif = num_peer_notif; in bond_check_params()
6418 params->arp_interval = arp_interval; in bond_check_params()
6419 params->arp_validate = arp_validate_value; in bond_check_params()
6420 params->arp_all_targets = arp_all_targets_value; in bond_check_params()
6421 params->missed_max = 2; in bond_check_params()
6422 params->updelay = updelay; in bond_check_params()
6423 params->downdelay = downdelay; in bond_check_params()
6424 params->peer_notif_delay = 0; in bond_check_params()
6425 params->use_carrier = use_carrier; in bond_check_params()
6426 params->lacp_active = 1; in bond_check_params()
6427 params->lacp_fast = lacp_fast; in bond_check_params()
6428 params->primary[0] = 0; in bond_check_params()
6429 params->primary_reselect = primary_reselect_value; in bond_check_params()
6430 params->fail_over_mac = fail_over_mac_value; in bond_check_params()
6431 params->tx_queues = tx_queues; in bond_check_params()
6432 params->all_slaves_active = all_slaves_active; in bond_check_params()
6433 params->resend_igmp = resend_igmp; in bond_check_params()
6434 params->min_links = min_links; in bond_check_params()
6435 params->lp_interval = lp_interval; in bond_check_params()
6436 params->packets_per_slave = packets_per_slave; in bond_check_params()
6437 params->tlb_dynamic_lb = tlb_dynamic_lb; in bond_check_params()
6438 params->ad_actor_sys_prio = ad_actor_sys_prio; in bond_check_params()
6439 eth_zero_addr(params->ad_actor_system); in bond_check_params()
6440 params->ad_user_port_key = ad_user_port_key; in bond_check_params()
6441 params->coupled_control = 1; in bond_check_params()
6443 params->reciprocal_packets_per_slave = in bond_check_params()
6449 params->reciprocal_packets_per_slave = in bond_check_params()
6454 strscpy_pad(params->primary, primary, sizeof(params->primary)); in bond_check_params()
6456 memcpy(params->arp_targets, arp_target, sizeof(arp_target)); in bond_check_params()
6458 memset(params->ns_targets, 0, sizeof(struct in6_addr) * BOND_MAX_NS_TARGETS); in bond_check_params()
6472 bond->wq = alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, in bond_init()
6473 bond_dev->name); in bond_init()
6474 if (!bond->wq) in bond_init()
6475 return -ENOMEM; in bond_init()
6477 bond->notifier_ctx = false; in bond_init()
6479 spin_lock_init(&bond->stats_lock); in bond_init()
6482 list_add_tail_rcu(&bond->bond_list, &bn->dev_list); in bond_init()
6489 if (is_zero_ether_addr(bond_dev->dev_addr) && in bond_init()
6490 bond_dev->addr_assign_type == NET_ADDR_PERM) in bond_init()
6510 int res = -ENOMEM; in bond_create()
6522 bond_dev->rtnl_link_ops = &bond_link_ops; in bond_create()
6543 bn->net = net; in bond_net_init()
6544 INIT_LIST_HEAD(&bn->dev_list); in bond_net_init()
6574 list_for_each_entry_safe(bond, tmp_bond, &bn->dev_list, bond_list) in bond_net_exit_batch_rtnl()
6575 unregister_netdevice_queue(bond->dev, dev_kill_list); in bond_net_exit_batch_rtnl()