Lines Matching +full:ether +full:- +full:link +full:- +full:active +full:- +full:low
1 // SPDX-License-Identifier: GPL-1.0+
97 /*---------------------------- Module parameters ----------------------------*/
137 MODULE_PARM_DESC(miimon, "Link check interval in milliseconds");
139 MODULE_PARM_DESC(updelay, "Delay before considering link up, in milliseconds");
141 MODULE_PARM_DESC(downdelay, "Delay before considering link down, "
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");
159 "2 for only on active slave "
172 MODULE_PARM_DESC(xmit_hash_policy, "balance-alb, balance-tlb, balance-xor, 802.3ad hashing method; "
182 "0 for none (default), 1 for active, "
187 MODULE_PARM_DESC(fail_over_mac, "For active-backup, do not set all slaves to "
189 "1 for active, 2 for follow");
192 "by setting active flag for all slaves; "
196 "link failure");
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()
279 [BOND_MODE_8023AD] = "IEEE 802.3ad Dynamic link aggregation", 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()
792 /* Get link speed and duplex from the slave's base driver
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()
826 const char *bond_slave_link_status(s8 link) in bond_slave_link_status() argument
828 switch (link) { in bond_slave_link_status()
842 /* if <dev> supports MII link status reporting, check its link status.
847 * Return either BMSR_LSTATUS, meaning that the link is up (or we
848 * can't tell and just pretend it is), or 0, meaning that the link is
851 * If reporting is non-zero, instead of faking link up, return -1 if
860 const struct net_device_ops *slave_ops = slave_dev->netdev_ops; in bond_check_dev_link()
868 if (bond->params.use_carrier) in bond_check_dev_link()
871 /* Try to get link status using Ethtool first. */ 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()
877 ioctl = slave_ops->ndo_eth_ioctl; in bond_check_dev_link()
892 strscpy_pad(ifr.ifr_name, slave_dev->name, IFNAMSIZ); 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()
903 * cannot report link status). If not reporting, pretend 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()
958 * device and retransmit an IGMP JOIN request to the current active
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 ---------------------------*/
995 * old active slaves (if any). Modes that are not using primary keep all
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()
1100 * if just old_active, do nothing (going to no active slave) 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,
1157 * go on and do link reselection.
1159 * - If primary link is not set or down, find the highest priority link.
1160 * If the highest priority link is not current slave, set it as primary
1161 * link and do link reselection.
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
1265 * @new_active: the new slave to make the active one
1269 * Setting include flags, mc-list, promiscuity, allmulti, etc.
1271 * If @new's link state is %BOND_LINK_BACK we'll set it to %BOND_LINK_UP,
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()
1367 /* resend IGMP joins since active slave has changed or 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 ----------------------------------*/
1527 slave->dev->features, in bond_fix_features()
1558 struct net_device *bond_dev = bond->dev; in bond_compute_features()
1573 slave->dev->vlan_features, BOND_VLAN_FEATURES); in bond_compute_features()
1576 slave->dev->hw_enc_features, in bond_compute_features()
1581 slave->dev->hw_enc_features, in bond_compute_features()
1585 if (slave->dev->hw_enc_features & NETIF_F_GSO_PARTIAL) in bond_compute_features()
1586 gso_partial_features &= slave->dev->gso_partial_features; in bond_compute_features()
1589 slave->dev->mpls_features, in bond_compute_features()
1592 dst_release_flag &= slave->dev->priv_flags; in bond_compute_features()
1593 if (slave->dev->hard_header_len > max_hard_header_len) in bond_compute_features()
1594 max_hard_header_len = slave->dev->hard_header_len; in bond_compute_features()
1596 tso_max_size = min(tso_max_size, slave->dev->tso_max_size); in bond_compute_features()
1597 tso_max_segs = min(tso_max_segs, slave->dev->tso_max_segs); in bond_compute_features()
1599 bond_dev->hard_header_len = max_hard_header_len; in bond_compute_features()
1602 bond_dev->gso_partial_features |= NETIF_F_GSO_ESP; in bond_compute_features()
1604 bond_dev->gso_partial_features &= ~NETIF_F_GSO_ESP; in bond_compute_features()
1607 bond_dev->vlan_features = vlan_features; in bond_compute_features()
1608 bond_dev->hw_enc_features = enc_features | NETIF_F_GSO_ENCAP_ALL | in bond_compute_features()
1612 bond_dev->hw_enc_features |= xfrm_features; in bond_compute_features()
1614 bond_dev->mpls_features = mpls_features; in bond_compute_features()
1618 bond_dev->priv_flags &= ~IFF_XMIT_DST_RELEASE; in bond_compute_features()
1619 if ((bond_dev->priv_flags & IFF_XMIT_DST_RELEASE_PERM) && in bond_compute_features()
1621 bond_dev->priv_flags |= IFF_XMIT_DST_RELEASE; in bond_compute_features()
1629 bool was_up = !!(bond_dev->flags & IFF_UP); in bond_setup_by_slave()
1633 bond_dev->header_ops = slave_dev->header_ops; in bond_setup_by_slave()
1635 bond_dev->type = slave_dev->type; in bond_setup_by_slave()
1636 bond_dev->hard_header_len = slave_dev->hard_header_len; in bond_setup_by_slave()
1637 bond_dev->needed_headroom = slave_dev->needed_headroom; in bond_setup_by_slave()
1638 bond_dev->addr_len = slave_dev->addr_len; in bond_setup_by_slave()
1640 memcpy(bond_dev->broadcast, slave_dev->broadcast, in bond_setup_by_slave()
1641 slave_dev->addr_len); in bond_setup_by_slave()
1643 if (slave_dev->flags & IFF_POINTOPOINT) { in bond_setup_by_slave()
1644 bond_dev->flags &= ~(IFF_BROADCAST | IFF_MULTICAST); in bond_setup_by_slave()
1645 bond_dev->flags |= (IFF_POINTOPOINT | IFF_NOARP); in bond_setup_by_slave()
1651 /* On bonding slaves other than the currently active slave, suppress
1652 * duplicates except for alb non-mcast/bcast.
1660 skb->pkt_type != PACKET_BROADCAST && in bond_should_deliver_exact_match()
1661 skb->pkt_type != PACKET_MULTICAST) in bond_should_deliver_exact_match()
1683 slave = bond_slave_get_rcu(skb->dev); in bond_handle_frame()
1684 bond = slave->bond; in bond_handle_frame()
1686 recv_probe = READ_ONCE(bond->recv_probe); in bond_handle_frame()
1697 * be suppressed we want to make an exception for link-local packets. in bond_handle_frame()
1703 * (including link-local ones) can have their originating interface in bond_handle_frame()
1707 if (is_link_local_ether_addr(eth_hdr(skb)->h_dest)) in bond_handle_frame()
1712 skb->dev = bond->dev; in bond_handle_frame()
1715 netif_is_bridge_port(bond->dev) && in bond_handle_frame()
1716 skb->pkt_type == PACKET_HOST) { in bond_handle_frame()
1719 skb->data - skb_mac_header(skb)))) { in bond_handle_frame()
1723 bond_hw_addr_copy(eth_hdr(skb)->h_dest, bond->dev->dev_addr, in bond_handle_frame()
1724 bond->dev->addr_len); in bond_handle_frame()
1753 switch (bond->params.xmit_policy) { in bond_lag_hash_type()
1782 err = netdev_master_upper_dev_link(slave->dev, bond->dev, slave, in bond_master_upper_dev_link()
1787 slave->dev->flags |= IFF_SLAVE; in bond_master_upper_dev_link()
1793 netdev_upper_dev_unlink(slave->dev, bond->dev); in bond_upper_dev_unlink()
1794 slave->dev->flags &= ~IFF_SLAVE; in bond_upper_dev_unlink()
1802 cancel_delayed_work_sync(&slave->notify_work); in slave_kobj_release()
1820 err = kobject_init_and_add(&slave->kobj, &slave_ktype, in bond_kobj_init()
1821 &(slave->dev->dev.kobj), "bonding_slave"); in bond_kobj_init()
1823 kobject_put(&slave->kobj); in bond_kobj_init()
1837 slave->bond = bond; in bond_alloc_slave()
1838 slave->dev = slave_dev; in bond_alloc_slave()
1839 INIT_DELAYED_WORK(&slave->notify_work, bond_netdev_notify_work); in bond_alloc_slave()
1848 kobject_put(&slave->kobj); in bond_alloc_slave()
1858 info->bond_mode = BOND_MODE(bond); in bond_fill_ifbond()
1859 info->miimon = bond->params.miimon; in bond_fill_ifbond()
1860 info->num_slaves = bond->slave_cnt; in bond_fill_ifbond()
1865 strcpy(info->slave_name, slave->dev->name); in bond_fill_ifslave()
1866 info->link = slave->link; in bond_fill_ifslave()
1867 info->state = bond_slave_state(slave); in bond_fill_ifslave()
1868 info->link_failure_count = slave->link_failure_count; in bond_fill_ifslave()
1880 bond_fill_ifbond(slave->bond, &binfo.master); in bond_netdev_notify_work()
1881 netdev_bonding_info_change(slave->dev, &binfo); in bond_netdev_notify_work()
1884 queue_delayed_work(slave->bond->wq, &slave->notify_work, 1); in bond_netdev_notify_work()
1890 queue_delayed_work(slave->bond->wq, &slave->notify_work, 0); in bond_queue_slave_event()
1897 info.link_up = slave->link == BOND_LINK_UP || in bond_lower_state_changed()
1898 slave->link == BOND_LINK_FAIL; in bond_lower_state_changed()
1900 netdev_lower_state_changed(slave->dev, &info); in bond_lower_state_changed()
1924 unsigned int flags = bond_dev->flags & (IFF_SLAVE | IFF_UP); in bond_ether_setup()
1927 bond_dev->flags |= IFF_MASTER | flags; in bond_ether_setup()
1928 bond_dev->priv_flags &= ~IFF_TX_SKB_SHARING; in bond_ether_setup()
1946 val &= slave->dev->xdp_features; in bond_xdp_set_features()
1958 const struct net_device_ops *slave_ops = slave_dev->netdev_ops; in bond_enslave()
1964 if (slave_dev->flags & IFF_MASTER && in bond_enslave()
1968 return -EPERM; in bond_enslave()
1971 if (!bond->params.use_carrier && in bond_enslave()
1972 slave_dev->ethtool_ops->get_link == NULL && in bond_enslave()
1973 slave_ops->ndo_eth_ioctl == NULL) { in bond_enslave()
1974 slave_warn(bond_dev, slave_dev, "no link monitoring support\n"); in bond_enslave()
1977 /* already in-use? */ in bond_enslave()
1981 return -EBUSY; in bond_enslave()
1986 return -EPERM; in bond_enslave()
1991 if (slave_dev->features & NETIF_F_VLAN_CHALLENGED) { in bond_enslave()
1996 return -EPERM; in bond_enslave()
2004 if (slave_dev->features & NETIF_F_HW_ESP) in bond_enslave()
2005 slave_dbg(bond_dev, slave_dev, "is esp-hw-offload capable\n"); in bond_enslave()
2012 if (slave_dev->flags & IFF_UP) { in bond_enslave()
2015 return -EPERM; in bond_enslave()
2018 /* set bonding device ether type by slave - bonding netdevices are in bond_enslave()
2022 * bond ether type mutual exclusion - don't allow slaves of dissimilar in bond_enslave()
2023 * ether type (eg ARPHRD_ETHER and ARPHRD_INFINIBAND) share the same bond in bond_enslave()
2026 if (bond_dev->type != slave_dev->type) { in bond_enslave()
2028 bond_dev->type, slave_dev->type); in bond_enslave()
2035 return -EBUSY; in bond_enslave()
2042 if (slave_dev->type != ARPHRD_ETHER) in bond_enslave()
2050 } else if (bond_dev->type != slave_dev->type) { in bond_enslave()
2053 return -EINVAL; in bond_enslave()
2056 if (slave_dev->type == ARPHRD_INFINIBAND && in bond_enslave()
2059 "Only active-backup mode is supported for infiniband slaves"); in bond_enslave()
2060 res = -EOPNOTSUPP; in bond_enslave()
2064 if (!slave_ops->ndo_set_mac_address || in bond_enslave()
2065 slave_dev->type == ARPHRD_INFINIBAND) { in bond_enslave()
2068 bond->params.fail_over_mac != BOND_FOM_ACTIVE) { in bond_enslave()
2070 bond->params.fail_over_mac = BOND_FOM_ACTIVE; in bond_enslave()
2071 slave_warn(bond_dev, slave_dev, "Setting fail_over_mac to active for active-backup mode\n"); in bond_enslave()
2074 … "Slave device does not support setting the MAC address, but fail_over_mac is not set to active"); in bond_enslave()
2075 res = -EOPNOTSUPP; in bond_enslave()
2087 bond->dev->addr_assign_type == NET_ADDR_RANDOM) { in bond_enslave()
2088 res = bond_set_dev_addr(bond->dev, slave_dev); in bond_enslave()
2095 res = -ENOMEM; in bond_enslave()
2102 new_slave->queue_id = 0; in bond_enslave()
2105 new_slave->original_mtu = slave_dev->mtu; in bond_enslave()
2106 res = dev_set_mtu(slave_dev, bond->dev->mtu); in bond_enslave()
2116 bond_hw_addr_copy(new_slave->perm_hwaddr, slave_dev->dev_addr, in bond_enslave()
2117 slave_dev->addr_len); in bond_enslave()
2119 if (!bond->params.fail_over_mac || in bond_enslave()
2124 memcpy(ss.__data, bond_dev->dev_addr, bond_dev->addr_len); in bond_enslave()
2125 ss.ss_family = slave_dev->type; in bond_enslave()
2135 slave_dev->priv_flags |= IFF_NO_ADDRCONF; in bond_enslave()
2144 slave_dev->priv_flags |= IFF_BONDING; in bond_enslave()
2146 dev_get_stats(new_slave->dev, &new_slave->slave_stats); in bond_enslave()
2165 new_slave->delay = 0; in bond_enslave()
2166 new_slave->link_failure_count = 0; in bond_enslave()
2170 new_slave->link = BOND_LINK_DOWN; in bond_enslave()
2172 new_slave->last_rx = jiffies - in bond_enslave()
2173 (msecs_to_jiffies(bond->params.arp_interval) + 1); in bond_enslave()
2175 new_slave->target_last_arp_rx[i] = new_slave->last_rx; in bond_enslave()
2177 new_slave->last_tx = new_slave->last_rx; in bond_enslave()
2179 if (bond->params.miimon && !bond->params.use_carrier) { in bond_enslave()
2182 if ((link_reporting == -1) && !bond->params.arp_interval) { in bond_enslave()
2191 …p_ip_target module parameters not specified, thus bonding will not detect link failures! see bondi… in bond_enslave()
2192 } else if (link_reporting == -1) { in bond_enslave()
2193 /* unable get link status using mii/ethtool */ in bond_enslave()
2194 …lave_dev, "can't get link status from slave; the network driver associated with this interface doe… in bond_enslave()
2199 new_slave->link = BOND_LINK_NOCHANGE; in bond_enslave()
2200 if (bond->params.miimon) { in bond_enslave()
2202 if (bond->params.updelay) { in bond_enslave()
2206 new_slave->delay = bond->params.updelay; in bond_enslave()
2216 } else if (bond->params.arp_interval) { in bond_enslave()
2226 if (new_slave->link != BOND_LINK_DOWN) in bond_enslave()
2227 new_slave->last_link_up = jiffies; in bond_enslave()
2229 new_slave->link == BOND_LINK_DOWN ? "DOWN" : in bond_enslave()
2230 (new_slave->link == BOND_LINK_UP ? "UP" : "BACK")); in bond_enslave()
2232 if (bond_uses_primary(bond) && bond->params.primary[0]) { in bond_enslave()
2234 if (strcmp(bond->params.primary, new_slave->dev->name) == 0) { in bond_enslave()
2235 rcu_assign_pointer(bond->primary_slave, new_slave); in bond_enslave()
2236 bond->force_primary = true; in bond_enslave()
2253 SLAVE_AD_INFO(new_slave)->id = 1; in bond_enslave()
2259 SLAVE_AD_INFO(new_slave)->id = in bond_enslave()
2260 SLAVE_AD_INFO(prev_slave)->id + 1; in bond_enslave()
2271 slave_dbg(bond_dev, slave_dev, "This slave is always active in trunk mode\n"); in bond_enslave()
2273 /* always active in trunk mode */ in bond_enslave()
2280 if (!rcu_access_pointer(bond->curr_active_slave) && in bond_enslave()
2281 new_slave->link == BOND_LINK_UP) in bond_enslave()
2282 rcu_assign_pointer(bond->curr_active_slave, new_slave); in bond_enslave()
2288 if (bond->dev->npinfo) { in bond_enslave()
2291 res = -EBUSY; in bond_enslave()
2297 if (!(bond_dev->features & NETIF_F_LRO)) in bond_enslave()
2326 if (bond_dev->flags & IFF_PROMISC) { in bond_enslave()
2333 if (bond_dev->flags & IFF_ALLMULTI) { in bond_enslave()
2336 if (bond_dev->flags & IFF_PROMISC) in bond_enslave()
2337 dev_set_promiscuity(slave_dev, -1); in bond_enslave()
2342 if (bond_dev->flags & IFF_UP) { in bond_enslave()
2353 bond->slave_cnt++; in bond_enslave()
2358 * remove the maddrs if the slave is selected as active slave. in bond_enslave()
2371 if (!slave_dev->netdev_ops->ndo_bpf || in bond_enslave()
2372 !slave_dev->netdev_ops->ndo_xdp_xmit) { in bond_enslave()
2373 if (bond->xdp_prog) { in bond_enslave()
2376 res = -EOPNOTSUPP; in bond_enslave()
2379 } else if (bond->xdp_prog) { in bond_enslave()
2383 .prog = bond->xdp_prog, in bond_enslave()
2390 res = -EOPNOTSUPP; in bond_enslave()
2400 if (bond->xdp_prog) in bond_enslave()
2401 bpf_prog_inc(bond->xdp_prog); in bond_enslave()
2406 slave_info(bond_dev, slave_dev, "Enslaving as %s interface with %s link\n", in bond_enslave()
2407 bond_is_active_slave(new_slave) ? "an active" : "a backup", in bond_enslave()
2408 new_slave->link != BOND_LINK_DOWN ? "an up" : "a down"); in bond_enslave()
2426 if (rcu_access_pointer(bond->primary_slave) == new_slave) in bond_enslave()
2427 RCU_INIT_POINTER(bond->primary_slave, NULL); in bond_enslave()
2428 if (rcu_access_pointer(bond->curr_active_slave) == new_slave) { in bond_enslave()
2440 slave_dev->priv_flags &= ~IFF_BONDING; in bond_enslave()
2444 slave_dev->priv_flags &= ~IFF_NO_ADDRCONF; in bond_enslave()
2445 if (!bond->params.fail_over_mac || in bond_enslave()
2447 /* XXX TODO - fom follow mode needs to change master's in bond_enslave()
2451 bond_hw_addr_copy(ss.__data, new_slave->perm_hwaddr, in bond_enslave()
2452 new_slave->dev->addr_len); in bond_enslave()
2453 ss.ss_family = slave_dev->type; in bond_enslave()
2458 dev_set_mtu(slave_dev, new_slave->original_mtu); in bond_enslave()
2461 kobject_put(&new_slave->kobj); in bond_enslave()
2466 if (ether_addr_equal_64bits(bond_dev->dev_addr, in bond_enslave()
2467 slave_dev->dev_addr)) in bond_enslave()
2469 if (bond_dev->type != ARPHRD_ETHER) { in bond_enslave()
2480 * is RTNL-locked. If "all" is true it means that the function is being called
2484 * for Active/Backup:
2485 * Active stays on all backups go down
2496 int old_flags = bond_dev->flags; in __bond_release_one()
2497 netdev_features_t old_features = bond_dev->features; in __bond_release_one()
2500 if (!(slave_dev->flags & IFF_SLAVE) || in __bond_release_one()
2503 return -EINVAL; in __bond_release_one()
2513 return -EINVAL; in __bond_release_one()
2521 bond_get_stats(bond->dev, &bond->bond_stats); in __bond_release_one()
2523 if (bond->xdp_prog) { in __bond_release_one()
2548 bond_is_active_slave(slave) ? "active" : "backup"); in __bond_release_one()
2550 oldcurrent = rcu_access_pointer(bond->curr_active_slave); in __bond_release_one()
2552 RCU_INIT_POINTER(bond->current_arp_slave, NULL); in __bond_release_one()
2554 if (!all && (!bond->params.fail_over_mac || in __bond_release_one()
2556 if (ether_addr_equal_64bits(bond_dev->dev_addr, slave->perm_hwaddr) && in __bond_release_one()
2558 …slave_warn(bond_dev, slave_dev, "the permanent HWaddr of slave - %pM - is still in use by bond - s… in __bond_release_one()
2559 slave->perm_hwaddr); in __bond_release_one()
2562 if (rtnl_dereference(bond->primary_slave) == slave) in __bond_release_one()
2563 RCU_INIT_POINTER(bond->primary_slave, NULL); in __bond_release_one()
2569 * might change from an active slave to a backup slave. Then it is in __bond_release_one()
2578 * but before a new active slave is selected. in __bond_release_one()
2584 RCU_INIT_POINTER(bond->curr_active_slave, NULL); in __bond_release_one()
2599 bond->slave_cnt--; in __bond_release_one()
2602 call_netdevice_notifiers(NETDEV_CHANGEADDR, bond->dev); in __bond_release_one()
2603 call_netdevice_notifiers(NETDEV_RELEASE, bond->dev); in __bond_release_one()
2607 if (!(bond_dev->features & NETIF_F_VLAN_CHALLENGED) && in __bond_release_one()
2609 …slave_info(bond_dev, slave_dev, "last VLAN challenged slave left bond - VLAN blocking is removed\n… in __bond_release_one()
2625 dev_set_promiscuity(slave_dev, -1); in __bond_release_one()
2629 dev_set_allmulti(slave_dev, -1); in __bond_release_one()
2640 slave_dev->priv_flags &= ~IFF_NO_ADDRCONF; in __bond_release_one()
2642 if (bond->params.fail_over_mac != BOND_FOM_ACTIVE || in __bond_release_one()
2645 bond_hw_addr_copy(ss.__data, slave->perm_hwaddr, in __bond_release_one()
2646 slave->dev->addr_len); in __bond_release_one()
2647 ss.ss_family = slave_dev->type; in __bond_release_one()
2652 __dev_set_mtu(slave_dev, slave->original_mtu); in __bond_release_one()
2654 dev_set_mtu(slave_dev, slave->original_mtu); in __bond_release_one()
2657 slave_dev->priv_flags &= ~IFF_BONDING; in __bond_release_one()
2660 kobject_put(&slave->kobj); in __bond_release_one()
2682 bond_dev->reg_state != NETREG_UNREGISTERING) { in bond_release_and_destroy()
2683 bond_dev->priv_flags |= IFF_DISABLE_NETPOLL; in bond_release_and_destroy()
2702 int i = 0, res = -ENODEV; in bond_slave_info_query()
2706 if (i++ == (int)info->slave_id) { in bond_slave_info_query()
2716 /*-------------------------------- Monitoring -------------------------------*/
2727 ignore_updelay = !rcu_dereference(bond->curr_active_slave); in bond_miimon_inspect()
2731 usable_slaves = rcu_dereference(bond->usable_slaves); in bond_miimon_inspect()
2733 if (usable_slaves && usable_slaves->count == 0) in bond_miimon_inspect()
2740 link_state = bond_check_dev_link(bond, slave->dev, 0); in bond_miimon_inspect()
2742 switch (slave->link) { in bond_miimon_inspect()
2749 slave->delay = bond->params.downdelay; in bond_miimon_inspect()
2750 if (slave->delay && net_ratelimit()) { in bond_miimon_inspect()
2751 slave_info(bond->dev, slave->dev, "link status down for %sinterface, disabling it in %d ms\n", in bond_miimon_inspect()
2755 "active " : "backup ") : "", in bond_miimon_inspect()
2756 bond->params.downdelay * bond->params.miimon); in bond_miimon_inspect()
2763 slave->last_link_up = jiffies; in bond_miimon_inspect()
2765 slave_info(bond->dev, slave->dev, "link status up again after %d ms\n", in bond_miimon_inspect()
2766 (bond->params.downdelay - slave->delay) * in bond_miimon_inspect()
2767 bond->params.miimon); in bond_miimon_inspect()
2772 if (slave->delay <= 0) { in bond_miimon_inspect()
2778 slave->delay--; in bond_miimon_inspect()
2787 slave->delay = bond->params.updelay; in bond_miimon_inspect()
2789 if (slave->delay && net_ratelimit()) { in bond_miimon_inspect()
2790 slave_info(bond->dev, slave->dev, "link status up, enabling it in %d ms\n", in bond_miimon_inspect()
2792 bond->params.updelay * in bond_miimon_inspect()
2793 bond->params.miimon); in bond_miimon_inspect()
2800 slave_info(bond->dev, slave->dev, "link status down again after %d ms\n", in bond_miimon_inspect()
2801 (bond->params.updelay - slave->delay) * in bond_miimon_inspect()
2802 bond->params.miimon); in bond_miimon_inspect()
2808 slave->delay = 0; in bond_miimon_inspect()
2810 if (slave->delay <= 0) { in bond_miimon_inspect()
2817 slave->delay--; in bond_miimon_inspect()
2827 char link) in bond_miimon_link_change() argument
2831 bond_3ad_handle_link_change(slave, link); in bond_miimon_link_change()
2835 bond_alb_handle_link_change(bond, slave, link); in bond_miimon_link_change()
2845 struct slave *slave, *primary, *active; in bond_miimon_commit() local
2852 switch (slave->link_new_state) { in bond_miimon_commit()
2857 * link monitoring could make a decision on the actual in bond_miimon_commit()
2858 * link status in bond_miimon_commit()
2861 slave->link == BOND_LINK_UP) in bond_miimon_commit()
2868 slave->link = BOND_LINK_DOWN; in bond_miimon_commit()
2870 slave_warn(bond->dev, slave->dev, in bond_miimon_commit()
2871 "failed to get link speed/duplex\n"); in bond_miimon_commit()
2876 slave->last_link_up = jiffies; in bond_miimon_commit()
2878 primary = rtnl_dereference(bond->primary_slave); in bond_miimon_commit()
2880 /* prevent it from being the active one */ in bond_miimon_commit()
2883 /* make it immediately active */ in bond_miimon_commit()
2887 slave_info(bond->dev, slave->dev, "link status definitely up, %u Mbps %s duplex\n", in bond_miimon_commit()
2888 slave->speed == SPEED_UNKNOWN ? 0 : slave->speed, in bond_miimon_commit()
2889 slave->duplex ? "full" : "half"); in bond_miimon_commit()
2893 active = rtnl_dereference(bond->curr_active_slave); in bond_miimon_commit()
2894 if (!active || slave == primary || slave->prio > active->prio) in bond_miimon_commit()
2900 if (slave->link_failure_count < UINT_MAX) in bond_miimon_commit()
2901 slave->link_failure_count++; in bond_miimon_commit()
2911 slave_info(bond->dev, slave->dev, "link status definitely down, disabling slave\n"); in bond_miimon_commit()
2915 if (slave == rcu_access_pointer(bond->curr_active_slave)) in bond_miimon_commit()
2921 slave_err(bond->dev, slave->dev, "invalid new link %d on slave\n", in bond_miimon_commit()
2922 slave->link_new_state); in bond_miimon_commit()
2943 * implement whatever link state changes are indicated.
2955 delay = msecs_to_jiffies(bond->params.miimon); in bond_mii_monitor()
2963 if (bond->send_peer_notif) { in bond_mii_monitor()
2966 bond->send_peer_notif--; in bond_mii_monitor()
2990 if (bond->params.miimon) in bond_mii_monitor()
2991 queue_delayed_work(bond->wq, &bond->mii_work, delay); in bond_mii_monitor()
2996 call_netdevice_notifiers(NETDEV_NOTIFY_PEERS, bond->dev); in bond_mii_monitor()
3004 __be32 ip = *(__be32 *)priv->data; in bond_upper_dev_walk()
3016 if (ip == bond_confirm_addr(bond->dev, 0, ip)) in bond_has_this_ip()
3020 if (netdev_walk_all_upper_dev_rcu(bond->dev, bond_upper_dev_walk, &priv)) in bond_has_this_ip()
3032 struct net_device *bond_dev = slave->bond->dev; in bond_handle_vlan()
3033 struct net_device *slave_dev = slave->dev; in bond_handle_vlan()
3036 if (!tags || tags->vlan_proto == BOND_VLAN_PROTO_NONE) in bond_handle_vlan()
3042 while (tags->vlan_proto != BOND_VLAN_PROTO_NONE) { in bond_handle_vlan()
3043 if (!tags->vlan_id) { in bond_handle_vlan()
3049 ntohs(outer_tag->vlan_proto), tags->vlan_id); in bond_handle_vlan()
3050 skb = vlan_insert_tag_set_proto(skb, tags->vlan_proto, in bond_handle_vlan()
3051 tags->vlan_id); in bond_handle_vlan()
3060 if (outer_tag->vlan_id) { in bond_handle_vlan()
3062 ntohs(outer_tag->vlan_proto), outer_tag->vlan_id); in bond_handle_vlan()
3063 __vlan_hwaccel_put_tag(skb, outer_tag->vlan_proto, in bond_handle_vlan()
3064 outer_tag->vlan_id); in bond_handle_vlan()
3072 * "native" to a VLAN) might not pass non-tagged frames.
3077 struct net_device *bond_dev = slave->bond->dev; in bond_arp_send()
3078 struct net_device *slave_dev = slave->dev; in bond_arp_send()
3085 NULL, slave_dev->dev_addr, NULL); in bond_arp_send()
3117 return ERR_PTR(-ENOMEM); in bond_verify_device_path()
3144 __be32 *targets = bond->params.arp_targets, addr; in bond_arp_send_all()
3148 slave_dbg(bond->dev, slave->dev, "%s: target %pI4\n", in bond_arp_send_all()
3153 rt = ip_route_output(dev_net(bond->dev), targets[i], 0, 0, 0, in bond_arp_send_all()
3156 /* there's no route to target - try to send arp in bond_arp_send_all()
3159 if (bond->params.arp_validate) in bond_arp_send_all()
3161 bond->dev->name, in bond_arp_send_all()
3169 if (rt->dst.dev == bond->dev) in bond_arp_send_all()
3173 tags = bond_verify_device_path(bond->dev, rt->dst.dev, 0); in bond_arp_send_all()
3179 /* Not our device - skip */ in bond_arp_send_all()
3180 slave_dbg(bond->dev, slave->dev, "no path to arp_ip_target %pI4 via rt.dev %s\n", in bond_arp_send_all()
3181 &targets[i], rt->dst.dev ? rt->dst.dev->name : "NULL"); in bond_arp_send_all()
3187 addr = bond_confirm_addr(rt->dst.dev, targets[i], 0); in bond_arp_send_all()
3199 slave_dbg(bond->dev, slave->dev, "%s: sip %pI4 tip %pI4 not found\n", in bond_validate_arp()
3204 i = bond_get_targets_ip(bond->params.arp_targets, sip); in bond_validate_arp()
3205 if (i == -1) { in bond_validate_arp()
3206 slave_dbg(bond->dev, slave->dev, "%s: sip %pI4 not found in targets\n", in bond_validate_arp()
3210 slave->last_rx = jiffies; in bond_validate_arp()
3211 slave->target_last_arp_rx[i] = jiffies; in bond_validate_arp()
3217 struct arphdr *arp = (struct arphdr *)skb->data; in bond_arp_rcv()
3223 alen = arp_hdr_len(bond->dev); in bond_arp_rcv()
3233 if (arp->ar_hln != bond->dev->addr_len || in bond_arp_rcv()
3234 skb->pkt_type == PACKET_OTHERHOST || in bond_arp_rcv()
3235 skb->pkt_type == PACKET_LOOPBACK || in bond_arp_rcv()
3236 arp->ar_hrd != htons(ARPHRD_ETHER) || in bond_arp_rcv()
3237 arp->ar_pro != htons(ETH_P_IP) || in bond_arp_rcv()
3238 arp->ar_pln != 4) in bond_arp_rcv()
3242 arp_ptr += bond->dev->addr_len; in bond_arp_rcv()
3244 arp_ptr += 4 + bond->dev->addr_len; in bond_arp_rcv()
3247 slave_dbg(bond->dev, slave->dev, "%s: %s/%d av %d sv %d sip %pI4 tip %pI4\n", in bond_arp_rcv()
3248 __func__, slave->dev->name, bond_slave_state(slave), in bond_arp_rcv()
3249 bond->params.arp_validate, slave_do_arp_validate(bond, slave), in bond_arp_rcv()
3252 curr_active_slave = rcu_dereference(bond->curr_active_slave); in bond_arp_rcv()
3253 curr_arp_slave = rcu_dereference(bond->current_arp_slave); in bond_arp_rcv()
3257 * (a) the slave receiving the ARP is active (which includes the in bond_arp_rcv()
3260 * (b) the receiving slave isn't active, but there is a currently in bond_arp_rcv()
3261 * active slave and it received valid arp reply(s) after it became in bond_arp_rcv()
3262 * the currently active slave, or in bond_arp_rcv()
3282 curr_active_slave->last_link_up)) in bond_arp_rcv()
3284 else if (curr_arp_slave && (arp->ar_op == htons(ARPOP_REPLY)) && in bond_arp_rcv()
3289 if (arp != (struct arphdr *)skb->data) in bond_arp_rcv()
3298 struct net_device *bond_dev = slave->bond->dev; in bond_ns_send()
3299 struct net_device *slave_dev = slave->dev; in bond_ns_send()
3321 struct in6_addr *targets = bond->params.ns_targets; in bond_ns_send_all()
3329 slave_dbg(bond->dev, slave->dev, "%s: target %pI6c\n", in bond_ns_send_all()
3336 fl6.flowi6_oif = bond->dev->ifindex; in bond_ns_send_all()
3338 dst = ip6_route_output(dev_net(bond->dev), NULL, &fl6); in bond_ns_send_all()
3339 if (dst->error) { in bond_ns_send_all()
3341 /* there's no route to target - try to send arp in bond_ns_send_all()
3344 if (bond->params.arp_validate) in bond_ns_send_all()
3346 bond->dev->name, in bond_ns_send_all()
3353 if (dst->dev == bond->dev) in bond_ns_send_all()
3357 tags = bond_verify_device_path(bond->dev, dst->dev, 0); in bond_ns_send_all()
3363 /* Not our device - skip */ in bond_ns_send_all()
3364 slave_dbg(bond->dev, slave->dev, "no path to ns_ip6_target %pI6c via dst->dev %s\n", in bond_ns_send_all()
3365 &targets[i], dst->dev ? dst->dev->name : "NULL"); in bond_ns_send_all()
3371 if (!ipv6_dev_get_saddr(dev_net(dst->dev), dst->dev, &targets[i], 0, &saddr)) in bond_ns_send_all()
3384 struct in6_addr *addr = (struct in6_addr *)priv->data; in bond_confirm_addr6()
3396 if (bond_confirm_addr6(bond->dev, &priv)) in bond_has_this_ip6()
3400 if (netdev_walk_all_upper_dev_rcu(bond->dev, bond_confirm_addr6, &priv)) in bond_has_this_ip6()
3414 * 2. Dest address is neither all-nodes multicast address nor in bond_validate_na()
3420 slave_dbg(bond->dev, slave->dev, "%s: sip %pI6c tip %pI6c not found\n", in bond_validate_na()
3425 i = bond_get_targets_ip6(bond->params.ns_targets, saddr); in bond_validate_na()
3426 if (i == -1) { in bond_validate_na()
3427 slave_dbg(bond->dev, slave->dev, "%s: sip %pI6c not found in targets\n", in bond_validate_na()
3431 slave->last_rx = jiffies; in bond_validate_na()
3432 slave->target_last_arp_rx[i] = jiffies; in bond_validate_na()
3445 if (skb->pkt_type == PACKET_OTHERHOST || in bond_na_rcv()
3446 skb->pkt_type == PACKET_LOOPBACK) in bond_na_rcv()
3450 if (!combined || combined->ip6.nexthdr != NEXTHDR_ICMP || in bond_na_rcv()
3451 (combined->icmp6.icmp6_type != NDISC_NEIGHBOUR_SOLICITATION && in bond_na_rcv()
3452 combined->icmp6.icmp6_type != NDISC_NEIGHBOUR_ADVERTISEMENT)) in bond_na_rcv()
3455 saddr = &combined->ip6.saddr; in bond_na_rcv()
3456 daddr = &combined->ip6.daddr; in bond_na_rcv()
3458 slave_dbg(bond->dev, slave->dev, "%s: %s/%d av %d sv %d sip %pI6c tip %pI6c\n", in bond_na_rcv()
3459 __func__, slave->dev->name, bond_slave_state(slave), in bond_na_rcv()
3460 bond->params.arp_validate, slave_do_arp_validate(bond, slave), in bond_na_rcv()
3463 curr_active_slave = rcu_dereference(bond->curr_active_slave); in bond_na_rcv()
3464 curr_arp_slave = rcu_dereference(bond->current_arp_slave); in bond_na_rcv()
3473 curr_active_slave->last_link_up)) in bond_na_rcv()
3488 bool is_ipv6 = skb->protocol == __cpu_to_be16(ETH_P_IPV6); in bond_rcv_validate()
3490 bool is_arp = skb->protocol == __cpu_to_be16(ETH_P_ARP); in bond_rcv_validate()
3492 slave_dbg(bond->dev, slave->dev, "%s: skb->dev %s\n", in bond_rcv_validate()
3493 __func__, skb->dev->name); in bond_rcv_validate()
3502 slave->last_rx = jiffies; in bond_rcv_validate()
3524 * (last_act - arp_interval) <= jiffies <= (last_act + mod * arp_interval +
3530 int delta_in_ticks = msecs_to_jiffies(bond->params.arp_interval); in bond_time_in_interval()
3533 last_act - delta_in_ticks, in bond_time_in_interval()
3537 /* This function is called regularly to monitor each slave's link
3539 * is used in load-balancing mode. if the adapter has been dormant, then an
3541 * arp monitoring in active backup mode.
3554 oldcurrent = rcu_dereference(bond->curr_active_slave); in bond_loadbalance_arp_mon()
3557 * the picture unless it is null. also, slave->last_link_up is not in bond_loadbalance_arp_mon()
3568 if (slave->link != BOND_LINK_UP) { in bond_loadbalance_arp_mon()
3570 bond_time_in_interval(bond, slave->last_rx, 1)) { in bond_loadbalance_arp_mon()
3575 /* primary_slave has no meaning in round-robin in bond_loadbalance_arp_mon()
3581 slave_info(bond->dev, slave->dev, "link status definitely up\n"); in bond_loadbalance_arp_mon()
3584 slave_info(bond->dev, slave->dev, "interface is now up\n"); in bond_loadbalance_arp_mon()
3588 /* slave->link == BOND_LINK_UP */ in bond_loadbalance_arp_mon()
3591 * when the source ip is 0, so don't take the link down in bond_loadbalance_arp_mon()
3594 if (!bond_time_in_interval(bond, last_tx, bond->params.missed_max) || in bond_loadbalance_arp_mon()
3595 !bond_time_in_interval(bond, slave->last_rx, bond->params.missed_max)) { in bond_loadbalance_arp_mon()
3600 if (slave->link_failure_count < UINT_MAX) in bond_loadbalance_arp_mon()
3601 slave->link_failure_count++; in bond_loadbalance_arp_mon()
3603 slave_info(bond->dev, slave->dev, "interface is now down\n"); in bond_loadbalance_arp_mon()
3610 /* note: if switch is in round-robin mode, all links in bond_loadbalance_arp_mon()
3611 * must tx arp to ensure all links rx an arp - otherwise in bond_loadbalance_arp_mon()
3614 * do - all replies will be rx'ed on same link causing slaves in bond_loadbalance_arp_mon()
3615 * to be unstable during low/no traffic periods in bond_loadbalance_arp_mon()
3628 if (slave->link_new_state != BOND_LINK_NOCHANGE) in bond_loadbalance_arp_mon()
3629 slave->link = slave->link_new_state; in bond_loadbalance_arp_mon()
3646 if (bond->params.arp_interval) in bond_loadbalance_arp_mon()
3647 queue_delayed_work(bond->wq, &bond->arp_work, in bond_loadbalance_arp_mon()
3648 msecs_to_jiffies(bond->params.arp_interval)); in bond_loadbalance_arp_mon()
3651 /* Called to inspect slaves for active-backup mode ARP monitor link state
3652 * changes. Sets proposed link state in slaves to specify what action
3654 * if changes to link states must be committed.
3669 if (slave->link != BOND_LINK_UP) { in bond_ab_arp_inspect()
3673 } else if (slave->link == BOND_LINK_BACK) { in bond_ab_arp_inspect()
3681 * active. This avoids bouncing, as the last receive in bond_ab_arp_inspect()
3684 if (bond_time_in_interval(bond, slave->last_link_up, 2)) in bond_ab_arp_inspect()
3688 * - No current_arp_slave AND in bond_ab_arp_inspect()
3689 * - more than (missed_max+1)*delta since last receive AND in bond_ab_arp_inspect()
3690 * - the bond has an IP address in bond_ab_arp_inspect()
3692 * Note: a non-null current_arp_slave indicates in bond_ab_arp_inspect()
3695 * we only take the curr_active_slave down - this in bond_ab_arp_inspect()
3700 !rcu_access_pointer(bond->current_arp_slave) && in bond_ab_arp_inspect()
3701 !bond_time_in_interval(bond, last_rx, bond->params.missed_max + 1)) { in bond_ab_arp_inspect()
3706 /* Active slave is down if: in bond_ab_arp_inspect()
3707 * - more than missed_max*delta since transmitting OR in bond_ab_arp_inspect()
3708 * - (more than missed_max*delta since receive AND in bond_ab_arp_inspect()
3713 (!bond_time_in_interval(bond, last_tx, bond->params.missed_max) || in bond_ab_arp_inspect()
3714 !bond_time_in_interval(bond, last_rx, bond->params.missed_max))) { in bond_ab_arp_inspect()
3723 /* Called to commit link state changes noted by inspection step of
3724 * active-backup mode ARP monitor.
3736 switch (slave->link_new_state) { in bond_ab_arp_commit()
3742 if (rtnl_dereference(bond->curr_active_slave) != slave || in bond_ab_arp_commit()
3743 (!rtnl_dereference(bond->curr_active_slave) && in bond_ab_arp_commit()
3747 current_arp_slave = rtnl_dereference(bond->current_arp_slave); in bond_ab_arp_commit()
3754 RCU_INIT_POINTER(bond->current_arp_slave, NULL); in bond_ab_arp_commit()
3757 slave_info(bond->dev, slave->dev, "link status definitely up\n"); in bond_ab_arp_commit()
3759 if (!rtnl_dereference(bond->curr_active_slave) || in bond_ab_arp_commit()
3760 slave == rtnl_dereference(bond->primary_slave) || in bond_ab_arp_commit()
3761 slave->prio > rtnl_dereference(bond->curr_active_slave)->prio) in bond_ab_arp_commit()
3769 if (slave->link_failure_count < UINT_MAX) in bond_ab_arp_commit()
3770 slave->link_failure_count++; in bond_ab_arp_commit()
3777 slave_info(bond->dev, slave->dev, "link status definitely down, disabling slave\n"); in bond_ab_arp_commit()
3779 if (slave == rtnl_dereference(bond->curr_active_slave)) { in bond_ab_arp_commit()
3780 RCU_INIT_POINTER(bond->current_arp_slave, NULL); in bond_ab_arp_commit()
3793 * the current active slave. in bond_ab_arp_commit()
3795 if (rtnl_dereference(bond->curr_active_slave)) in bond_ab_arp_commit()
3796 RCU_INIT_POINTER(bond->current_arp_slave, NULL); in bond_ab_arp_commit()
3800 slave_err(bond->dev, slave->dev, in bond_ab_arp_commit()
3802 slave->link_new_state); in bond_ab_arp_commit()
3816 /* Send ARP probes for active-backup mode ARP monitor.
3823 *curr_arp_slave = rcu_dereference(bond->current_arp_slave), in bond_ab_arp_probe()
3824 *curr_active_slave = rcu_dereference(bond->curr_active_slave); in bond_ab_arp_probe()
3830 netdev_info(bond->dev, "PROBE: c_arp %s && cas %s BAD\n", in bond_ab_arp_probe()
3831 curr_arp_slave->dev->name, in bond_ab_arp_probe()
3832 curr_active_slave->dev->name); in bond_ab_arp_probe()
3856 /* if the link state is up at this point, we in bond_ab_arp_probe()
3857 * mark it down - this can happen if we have in bond_ab_arp_probe()
3858 * simultaneous link failures and in bond_ab_arp_probe()
3863 if (!bond_slave_is_up(slave) && slave->link == BOND_LINK_UP) { in bond_ab_arp_probe()
3866 if (slave->link_failure_count < UINT_MAX) in bond_ab_arp_probe()
3867 slave->link_failure_count++; in bond_ab_arp_probe()
3872 slave_info(bond->dev, slave->dev, "backup interface is now down\n"); in bond_ab_arp_probe()
3888 new_slave->last_link_up = jiffies; in bond_ab_arp_probe()
3889 rcu_assign_pointer(bond->current_arp_slave, new_slave); in bond_ab_arp_probe()
3893 if (slave->should_notify || slave->should_notify_link) { in bond_ab_arp_probe()
3907 delta_in_ticks = msecs_to_jiffies(bond->params.arp_interval); in bond_activebackup_arp_mon()
3936 if (bond->params.arp_interval) in bond_activebackup_arp_mon()
3937 queue_delayed_work(bond->wq, &bond->arp_work, delta_in_ticks); in bond_activebackup_arp_mon()
3944 bond->send_peer_notif--; in bond_activebackup_arp_mon()
3946 bond->dev); in bond_activebackup_arp_mon()
3968 /*-------------------------- netdev event handling --------------------------*/
4023 bond_dev = slave->bond->dev; in bond_slave_netdev_event()
4024 bond = slave->bond; in bond_slave_netdev_event()
4025 primary = rtnl_dereference(bond->primary_slave); in bond_slave_netdev_event()
4031 if (bond_dev->type != ARPHRD_ETHER) in bond_slave_netdev_event()
4040 * in weird state. Mark it as link-fail if the link was in bond_slave_netdev_event()
4041 * previously up or link-down if it hasn't yet come up, and in bond_slave_netdev_event()
4042 * let link-monitoring (miimon) set it right when correct in bond_slave_netdev_event()
4047 if (slave->last_link_up) in bond_slave_netdev_event()
4048 slave->link = BOND_LINK_FAIL; in bond_slave_netdev_event()
4050 slave->link = BOND_LINK_DOWN; in bond_slave_netdev_event()
4057 /* Refresh slave-array if applicable! in bond_slave_netdev_event()
4058 * If the setup does not use miimon or arpmon (mode-specific!), in bond_slave_netdev_event()
4059 * then these events will not cause the slave-array to be in bond_slave_netdev_event()
4071 * an active-backup bond, slaves need in bond_slave_netdev_event()
4084 !bond->params.primary[0]) in bond_slave_netdev_event()
4088 /* slave's name changed - he's no longer primary */ in bond_slave_netdev_event()
4089 RCU_INIT_POINTER(bond->primary_slave, NULL); in bond_slave_netdev_event()
4090 } else if (!strcmp(slave_dev->name, bond->params.primary)) { in bond_slave_netdev_event()
4092 rcu_assign_pointer(bond->primary_slave, slave); in bond_slave_netdev_event()
4093 } else { /* we didn't change primary - exit */ in bond_slave_netdev_event()
4097 netdev_info(bond->dev, "Primary slave changed to %s, reselecting active slave\n", in bond_slave_netdev_event()
4098 primary ? slave_dev->name : "none"); in bond_slave_netdev_event()
4105 if (!bond->notifier_ctx) { in bond_slave_netdev_event()
4106 bond->notifier_ctx = true; in bond_slave_netdev_event()
4108 bond->notifier_ctx = false; in bond_slave_netdev_event()
4113 call_netdevice_notifiers(event, slave->bond->dev); in bond_slave_netdev_event()
4140 if (!(event_dev->priv_flags & IFF_BONDING)) in bond_netdev_event()
4143 if (event_dev->flags & IFF_MASTER) { in bond_netdev_event()
4151 if (event_dev->flags & IFF_SLAVE) in bond_netdev_event()
4161 /*---------------------------- Hashing Policies -----------------------------*/
4172 return skb->data; in bond_pull_data()
4187 return ep->h_dest[5] ^ ep->h_source[5] ^ be16_to_cpu(ep->h_proto); in bond_eth_hash()
4203 *nhoff += iph->ihl << 2; in bond_flow_ip()
4205 *ip_proto = iph->protocol; in bond_flow_ip()
4214 *ip_proto = iph6->nexthdr; in bond_flow_ip()
4220 fk->ports.ports = __skb_flow_get_ports(skb, *nhoff, *ip_proto, data, hlen); in bond_flow_ip()
4238 srcmac_vendor = (srcmac_vendor << 8) | mac_hdr->h_source[i]; in bond_vlan_srcmac_hash()
4241 srcmac_dev = (srcmac_dev << 8) | mac_hdr->h_source[i]; in bond_vlan_srcmac_hash()
4253 bool l34 = bond->params.xmit_policy == BOND_XMIT_POLICY_LAYER34; in bond_flow_dissect()
4254 int ip_proto = -1; in bond_flow_dissect()
4256 switch (bond->params.xmit_policy) { in bond_flow_dissect()
4266 fk->ports.ports = 0; in bond_flow_dissect()
4267 memset(&fk->icmp, 0, sizeof(fk->icmp)); in bond_flow_dissect()
4277 skb_flow_get_icmp_tci(skb, &fk->icmp, data, nhoff, hlen); in bond_flow_dissect()
4279 if (!icmp_is_err(fk->icmp.type)) in bond_flow_dissect()
4284 if (!icmpv6_is_err(fk->icmp.type)) in bond_flow_dissect()
4320 if (bond->params.xmit_policy == BOND_XMIT_POLICY_VLAN_SRCMAC) in __bond_xmit_hash()
4323 if (bond->params.xmit_policy == BOND_XMIT_POLICY_LAYER2 || in __bond_xmit_hash()
4327 if (bond->params.xmit_policy == BOND_XMIT_POLICY_LAYER23 || in __bond_xmit_hash()
4328 bond->params.xmit_policy == BOND_XMIT_POLICY_ENCAP23) { in __bond_xmit_hash()
4337 return bond_ip_hash(hash, &flow, bond->params.xmit_policy); in __bond_xmit_hash()
4341 * bond_xmit_hash - generate a hash value based on the xmit policy
4350 if (bond->params.xmit_policy == BOND_XMIT_POLICY_ENCAP34 && in bond_xmit_hash()
4351 skb->l4_hash) in bond_xmit_hash()
4352 return skb->hash; in bond_xmit_hash()
4354 return __bond_xmit_hash(bond, skb, skb->data, skb->protocol, in bond_xmit_hash()
4360 * bond_xmit_hash_xdp - generate a hash value based on the xmit policy
4370 if (xdp->data + sizeof(struct ethhdr) > xdp->data_end) in bond_xmit_hash_xdp()
4373 eth = (struct ethhdr *)xdp->data; in bond_xmit_hash_xdp()
4375 return __bond_xmit_hash(bond, NULL, xdp->data, eth->h_proto, 0, in bond_xmit_hash_xdp()
4376 sizeof(struct ethhdr), xdp->data_end - xdp->data); in bond_xmit_hash_xdp()
4379 /*-------------------------- Device entry points ----------------------------*/
4383 INIT_DELAYED_WORK(&bond->mcast_work, in bond_work_init_all()
4385 INIT_DELAYED_WORK(&bond->alb_work, bond_alb_monitor); in bond_work_init_all()
4386 INIT_DELAYED_WORK(&bond->mii_work, bond_mii_monitor); in bond_work_init_all()
4387 INIT_DELAYED_WORK(&bond->arp_work, bond_arp_monitor); in bond_work_init_all()
4388 INIT_DELAYED_WORK(&bond->ad_work, bond_3ad_state_machine_handler); in bond_work_init_all()
4389 INIT_DELAYED_WORK(&bond->slave_arr_work, bond_slave_arr_handler); in bond_work_init_all()
4394 cancel_delayed_work_sync(&bond->mii_work); in bond_work_cancel_all()
4395 cancel_delayed_work_sync(&bond->arp_work); in bond_work_cancel_all()
4396 cancel_delayed_work_sync(&bond->alb_work); in bond_work_cancel_all()
4397 cancel_delayed_work_sync(&bond->ad_work); in bond_work_cancel_all()
4398 cancel_delayed_work_sync(&bond->mcast_work); in bond_work_cancel_all()
4399 cancel_delayed_work_sync(&bond->slave_arr_work); in bond_work_cancel_all()
4408 if (BOND_MODE(bond) == BOND_MODE_ROUNDROBIN && !bond->rr_tx_counter) { in bond_open()
4409 bond->rr_tx_counter = alloc_percpu(u32); in bond_open()
4410 if (!bond->rr_tx_counter) in bond_open()
4411 return -ENOMEM; in bond_open()
4414 /* reset slave->backup and slave->inactive */ in bond_open()
4418 slave != rcu_access_pointer(bond->curr_active_slave)) { in bond_open()
4433 return -ENOMEM; in bond_open()
4434 if (bond->params.tlb_dynamic_lb || BOND_MODE(bond) == BOND_MODE_ALB) in bond_open()
4435 queue_delayed_work(bond->wq, &bond->alb_work, 0); in bond_open()
4438 if (bond->params.miimon) /* link check interval, in milliseconds. */ in bond_open()
4439 queue_delayed_work(bond->wq, &bond->mii_work, 0); in bond_open()
4441 if (bond->params.arp_interval) { /* arp interval, in milliseconds. */ in bond_open()
4442 queue_delayed_work(bond->wq, &bond->arp_work, 0); in bond_open()
4443 bond->recv_probe = bond_rcv_validate; in bond_open()
4447 queue_delayed_work(bond->wq, &bond->ad_work, 0); in bond_open()
4449 bond->recv_probe = bond_3ad_lacpdu_recv; in bond_open()
4453 dev_mc_add(slave->dev, lacpdu_mcast_addr); in bond_open()
4468 bond->send_peer_notif = 0; in bond_close()
4471 bond->recv_probe = NULL; in bond_close()
4475 slave = rcu_dereference(bond->curr_active_slave); in bond_close()
4477 bond_hw_addr_flush(bond_dev, slave->dev); in bond_close()
4483 bond_hw_addr_flush(bond_dev, slave->dev); in bond_close()
4504 s64 delta = nv - ov; in bond_fold_stats()
4508 delta = (s64)(s32)((u32)nv - (u32)ov); in bond_fold_stats()
4526 iter = &dev->adj_list.lower; in bond_get_lowest_level_rcu()
4536 niter = &ldev->adj_list.lower; in bond_get_lowest_level_rcu()
4547 next = dev_stack[--cur]; in bond_get_lowest_level_rcu()
4574 spin_lock_nested(&bond->stats_lock, nest_level); in bond_get_stats()
4575 memcpy(stats, &bond->bond_stats, sizeof(*stats)); in bond_get_stats()
4579 dev_get_stats(slave->dev, &temp); in bond_get_stats()
4581 bond_fold_stats(stats, new, &slave->slave_stats); in bond_get_stats()
4584 memcpy(&slave->slave_stats, new, sizeof(*new)); in bond_get_stats()
4587 memcpy(&bond->bond_stats, stats, sizeof(*stats)); in bond_get_stats()
4588 spin_unlock(&bond->stats_lock); in bond_get_stats()
4603 return -EINVAL; in bond_eth_ioctl()
4605 mii->phy_id = 0; in bond_eth_ioctl()
4613 return -EINVAL; in bond_eth_ioctl()
4615 if (mii->reg_num == 1) { in bond_eth_ioctl()
4616 mii->val_out = 0; in bond_eth_ioctl()
4617 if (netif_carrier_ok(bond->dev)) in bond_eth_ioctl()
4618 mii->val_out = BMSR_LSTATUS; in bond_eth_ioctl()
4623 return -EOPNOTSUPP; in bond_eth_ioctl()
4645 u_binfo = (struct ifbond __user *)ifr->ifr_data; in bond_do_ioctl()
4648 return -EFAULT; in bond_do_ioctl()
4652 return -EFAULT; in bond_do_ioctl()
4656 u_sinfo = (struct ifslave __user *)ifr->ifr_data; in bond_do_ioctl()
4659 return -EFAULT; in bond_do_ioctl()
4664 return -EFAULT; in bond_do_ioctl()
4673 if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) in bond_do_ioctl()
4674 return -EPERM; in bond_do_ioctl()
4676 slave_dev = __dev_get_by_name(net, ifr->ifr_slave); in bond_do_ioctl()
4681 return -ENODEV; in bond_do_ioctl()
4694 bond_opt_initstr(&newval, slave_dev->name); in bond_do_ioctl()
4699 res = -EOPNOTSUPP; in bond_do_ioctl()
4725 return -EOPNOTSUPP; in bond_siocdevprivate()
4734 bond_dev->flags & IFF_PROMISC ? 1 : -1); in bond_change_rx_flags()
4738 bond_dev->flags & IFF_ALLMULTI ? 1 : -1); in bond_change_rx_flags()
4749 slave = rcu_dereference(bond->curr_active_slave); in bond_set_rx_mode()
4751 dev_uc_sync(slave->dev, bond_dev); in bond_set_rx_mode()
4752 dev_mc_sync(slave->dev, bond_dev); in bond_set_rx_mode()
4756 dev_uc_sync_multiple(slave->dev, bond_dev); in bond_set_rx_mode()
4757 dev_mc_sync_multiple(slave->dev, bond_dev); in bond_set_rx_mode()
4765 struct bonding *bond = netdev_priv(n->dev); in bond_neigh_init()
4775 slave_ops = slave->dev->netdev_ops; in bond_neigh_init()
4776 if (!slave_ops->ndo_neigh_setup) in bond_neigh_init()
4788 ret = slave_ops->ndo_neigh_setup(slave->dev, &parms); in bond_neigh_init()
4805 * underlying devices. In that case - do nothing, we're already set up from
4812 if (parms->dev == dev) in bond_neigh_setup()
4813 parms->neigh_setup = bond_neigh_init; in bond_neigh_setup()
4829 slave_dbg(bond_dev, slave->dev, "s %p c_m %p\n", in bond_change_mtu()
4830 slave, slave->dev->netdev_ops->ndo_change_mtu); in bond_change_mtu()
4832 res = dev_set_mtu(slave->dev, new_mtu); in bond_change_mtu()
4838 * different mtu values than the active slave we'll in bond_change_mtu()
4843 slave_dbg(bond_dev, slave->dev, "err %d setting mtu to %d\n", in bond_change_mtu()
4849 WRITE_ONCE(bond_dev->mtu, new_mtu); in bond_change_mtu()
4861 tmp_res = dev_set_mtu(rollback_slave->dev, bond_dev->mtu); in bond_change_mtu()
4863 slave_dbg(bond_dev, rollback_slave->dev, "unwind err %d\n", in bond_change_mtu()
4893 if (bond->params.fail_over_mac && in bond_set_mac_address()
4897 if (!is_valid_ether_addr(ss->__data)) in bond_set_mac_address()
4898 return -EADDRNOTAVAIL; in bond_set_mac_address()
4901 slave_dbg(bond_dev, slave->dev, "%s: slave=%p\n", in bond_set_mac_address()
4903 res = dev_set_mac_address(slave->dev, addr, NULL); in bond_set_mac_address()
4911 slave_dbg(bond_dev, slave->dev, "%s: err %d\n", in bond_set_mac_address()
4918 dev_addr_set(bond_dev, ss->__data); in bond_set_mac_address()
4922 memcpy(tmp_ss.__data, bond_dev->dev_addr, bond_dev->addr_len); in bond_set_mac_address()
4923 tmp_ss.ss_family = bond_dev->type; in bond_set_mac_address()
4932 tmp_res = dev_set_mac_address(rollback_slave->dev, in bond_set_mac_address()
4935 slave_dbg(bond_dev, rollback_slave->dev, "%s: unwind err %d\n", in bond_set_mac_address()
4944 * bond_get_slave_by_id - get xmit slave with slave_id
4946 * @slave_id: slave id up to slave_cnt-1 through which to transmit
4960 if (--i < 0) { in bond_get_slave_by_id()
4969 if (--i < 0) in bond_get_slave_by_id()
4979 * bond_rr_gen_slave_id - generate slave id based on packets_per_slave
4990 int packets_per_slave = bond->params.packets_per_slave; in bond_rr_gen_slave_id()
4997 slave_id = this_cpu_inc_return(*bond->rr_tx_counter); in bond_rr_gen_slave_id()
5001 bond->params.reciprocal_packets_per_slave; in bond_rr_gen_slave_id()
5002 slave_id = this_cpu_inc_return(*bond->rr_tx_counter); in bond_rr_gen_slave_id()
5024 if (skb->protocol == htons(ETH_P_IP)) { in bond_xmit_roundrobin_slave_get()
5032 if (iph->protocol == IPPROTO_IGMP) { in bond_xmit_roundrobin_slave_get()
5033 slave = rcu_dereference(bond->curr_active_slave); in bond_xmit_roundrobin_slave_get()
5041 slave_cnt = READ_ONCE(bond->slave_cnt); in bond_xmit_roundrobin_slave_get()
5056 void *data = xdp->data; in bond_xdp_xmit_roundrobin_slave_get()
5058 if (data + sizeof(struct ethhdr) > xdp->data_end) in bond_xdp_xmit_roundrobin_slave_get()
5065 if (eth->h_proto == htons(ETH_P_IP)) { in bond_xdp_xmit_roundrobin_slave_get()
5068 if (data + sizeof(struct iphdr) > xdp->data_end) in bond_xdp_xmit_roundrobin_slave_get()
5073 if (iph->protocol == IPPROTO_IGMP) { in bond_xdp_xmit_roundrobin_slave_get()
5074 slave = rcu_dereference(bond->curr_active_slave); in bond_xdp_xmit_roundrobin_slave_get()
5082 slave_cnt = READ_ONCE(bond->slave_cnt); in bond_xdp_xmit_roundrobin_slave_get()
5098 return bond_dev_queue_xmit(bond, skb, slave->dev); in bond_xmit_roundrobin()
5105 return rcu_dereference(bond->curr_active_slave); in bond_xmit_activebackup_slave_get()
5108 /* In active-backup mode, we know that bond->curr_active_slave is always valid if
5119 return bond_dev_queue_xmit(bond, skb, slave->dev); in bond_xmit_activebackup()
5130 queue_delayed_work(bond->wq, &bond->slave_arr_work, delay); in bond_slave_arr_work_rearm()
5166 * this to-be-skipped slave to send a packet out. in bond_skip_slave()
5168 for (idx = 0; slaves && idx < slaves->count; idx++) { in bond_skip_slave()
5169 if (skipslave == slaves->arr[idx]) { in bond_skip_slave()
5170 slaves->arr[idx] = in bond_skip_slave()
5171 slaves->arr[slaves->count - 1]; in bond_skip_slave()
5172 slaves->count--; in bond_skip_slave()
5184 usable = rtnl_dereference(bond->usable_slaves); in bond_set_slave_arr()
5185 rcu_assign_pointer(bond->usable_slaves, usable_slaves); in bond_set_slave_arr()
5188 all = rtnl_dereference(bond->all_slaves); in bond_set_slave_arr()
5189 rcu_assign_pointer(bond->all_slaves, all_slaves); in bond_set_slave_arr()
5198 /* Build the usable slaves array in control path for modes that use xmit-hash
5199 * to determine the slave interface -
5217 bond->slave_cnt), GFP_KERNEL); in bond_update_slave_arr()
5219 bond->slave_cnt), GFP_KERNEL); in bond_update_slave_arr()
5221 ret = -ENOMEM; in bond_update_slave_arr()
5227 spin_lock_bh(&bond->mode_lock); in bond_update_slave_arr()
5229 spin_unlock_bh(&bond->mode_lock); in bond_update_slave_arr()
5231 /* No active aggragator means it's not safe to use in bond_update_slave_arr()
5237 spin_unlock_bh(&bond->mode_lock); in bond_update_slave_arr()
5244 all_slaves->arr[all_slaves->count++] = slave; in bond_update_slave_arr()
5248 agg = SLAVE_AD_INFO(slave)->port.aggregator; in bond_update_slave_arr()
5249 if (!agg || agg->aggregator_identifier != agg_id) in bond_update_slave_arr()
5255 slave_dbg(bond->dev, slave->dev, "Adding slave to tx hash array[%d]\n", in bond_update_slave_arr()
5256 usable_slaves->count); in bond_update_slave_arr()
5258 usable_slaves->arr[usable_slaves->count++] = slave; in bond_update_slave_arr()
5265 bond_skip_slave(rtnl_dereference(bond->all_slaves), in bond_update_slave_arr()
5267 bond_skip_slave(rtnl_dereference(bond->usable_slaves), in bond_update_slave_arr()
5285 count = slaves ? READ_ONCE(slaves->count) : 0; in bond_xmit_3ad_xor_slave_get()
5289 slave = slaves->arr[hash % count]; in bond_xmit_3ad_xor_slave_get()
5301 slaves = rcu_dereference(bond->usable_slaves); in bond_xdp_xmit_3ad_xor_slave_get()
5302 count = slaves ? READ_ONCE(slaves->count) : 0; in bond_xdp_xmit_3ad_xor_slave_get()
5306 return slaves->arr[hash % count]; in bond_xdp_xmit_3ad_xor_slave_get()
5320 slaves = rcu_dereference(bond->usable_slaves); in bond_3ad_xor_xmit()
5323 return bond_dev_queue_xmit(bond, skb, slave->dev); in bond_3ad_xor_xmit()
5341 if (!(bond_slave_is_up(slave) && slave->link == BOND_LINK_UP)) in bond_xmit_broadcast()
5351 bond_dev->name, __func__); in bond_xmit_broadcast()
5356 if (bond_dev_queue_xmit(bond, skb2, slave->dev) == NETDEV_TX_OK) in bond_xmit_broadcast()
5370 /*------------------------- Device initialization ---------------------------*/
5384 if (READ_ONCE(slave->queue_id) == skb_get_queue_mapping(skb)) { in bond_slave_override()
5386 slave->link == BOND_LINK_UP) { in bond_slave_override()
5387 bond_dev_queue_xmit(bond, skb, slave->dev); in bond_slave_override()
5410 qdisc_skb_cb(skb)->slave_dev_queue_mapping = skb_get_queue_mapping(skb); in bond_select_queue()
5412 if (unlikely(txq >= dev->real_num_tx_queues)) { in bond_select_queue()
5414 txq -= dev->real_num_tx_queues; in bond_select_queue()
5415 } while (txq >= dev->real_num_tx_queues); in bond_select_queue()
5438 slaves = rcu_dereference(bond->all_slaves); in bond_xmit_get_slave()
5440 slaves = rcu_dereference(bond->usable_slaves); in bond_xmit_get_slave()
5458 return slave->dev; in bond_xmit_get_slave()
5464 switch (sk->sk_family) { in bond_sk_to_flow()
5468 ipv6_addr_type(&sk->sk_v6_daddr) != IPV6_ADDR_MAPPED) { in bond_sk_to_flow()
5469 flow->control.addr_type = FLOW_DISSECTOR_KEY_IPV6_ADDRS; in bond_sk_to_flow()
5470 flow->addrs.v6addrs.src = inet6_sk(sk)->saddr; in bond_sk_to_flow()
5471 flow->addrs.v6addrs.dst = sk->sk_v6_daddr; in bond_sk_to_flow()
5477 flow->control.addr_type = FLOW_DISSECTOR_KEY_IPV4_ADDRS; in bond_sk_to_flow()
5478 flow->addrs.v4addrs.src = inet_sk(sk)->inet_rcv_saddr; in bond_sk_to_flow()
5479 flow->addrs.v4addrs.dst = inet_sk(sk)->inet_daddr; in bond_sk_to_flow()
5483 flow->ports.src = inet_sk(sk)->inet_sport; in bond_sk_to_flow()
5484 flow->ports.dst = inet_sk(sk)->inet_dport; in bond_sk_to_flow()
5488 * bond_sk_hash_l34 - generate a hash value based on the socket's L3 and L4 fields
5516 slaves = rcu_dereference(bond->usable_slaves); in __bond_sk_get_lower_dev()
5517 count = slaves ? READ_ONCE(slaves->count) : 0; in __bond_sk_get_lower_dev()
5522 slave = slaves->arr[hash % count]; in __bond_sk_get_lower_dev()
5524 return slave->dev; in __bond_sk_get_lower_dev()
5545 struct net_device *tls_netdev = rcu_dereference(tls_get_ctx(skb->sk)->netdev); in bond_tls_device_xmit()
5643 return slave->dev; in bond_xdp_get_xmit_slave()
5651 int nxmit, err = -ENXIO; in bond_xdp_xmit()
5665 err = -ENXIO; in bond_xdp_xmit()
5669 err = slave_dev->netdev_ops->ndo_xdp_xmit(slave_dev, 1, frames1, flags); in bond_xdp_xmit()
5705 return -EOPNOTSUPP; in bond_xdp_set()
5708 old_prog = bond->xdp_prog; in bond_xdp_set()
5709 bond->xdp_prog = prog; in bond_xdp_set()
5712 struct net_device *slave_dev = slave->dev; in bond_xdp_set()
5714 if (!slave_dev->netdev_ops->ndo_bpf || in bond_xdp_set()
5715 !slave_dev->netdev_ops->ndo_xdp_xmit) { in bond_xdp_set()
5718 err = -EOPNOTSUPP; in bond_xdp_set()
5725 err = -EOPNOTSUPP; in bond_xdp_set()
5750 bond->xdp_prog = old_prog; in bond_xdp_set()
5755 struct net_device *slave_dev = rollback_slave->dev; in bond_xdp_set()
5773 switch (xdp->command) { in bond_xdp()
5775 return bond_xdp_set(dev, xdp->prog, xdp->extack); in bond_xdp()
5777 return -EINVAL; in bond_xdp()
5784 speed = slave->speed; in bond_mode_bcast_speed()
5786 speed = min(speed, slave->speed); in bond_mode_bcast_speed()
5794 struct ifreq *ifr = kernel_cfg->ifr; in bond_set_phc_index_flag()
5797 if (kernel_cfg->copied_to_user) { in bond_set_phc_index_flag()
5799 if (copy_from_user(&cfg, ifr->ifr_data, sizeof(cfg))) in bond_set_phc_index_flag()
5800 return -EFAULT; in bond_set_phc_index_flag()
5803 if (copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg))) in bond_set_phc_index_flag()
5804 return -EFAULT; in bond_set_phc_index_flag()
5806 kernel_cfg->flags |= HWTSTAMP_FLAG_BONDED_PHC_INDEX; in bond_set_phc_index_flag()
5821 return -EOPNOTSUPP; in bond_hwtstamp_get()
5838 if (!(cfg->flags & HWTSTAMP_FLAG_BONDED_PHC_INDEX)) in bond_hwtstamp_set()
5839 return -EOPNOTSUPP; in bond_hwtstamp_set()
5843 return -EOPNOTSUPP; in bond_hwtstamp_set()
5860 cmd->base.duplex = DUPLEX_UNKNOWN; in bond_ethtool_get_link_ksettings()
5861 cmd->base.port = PORT_OTHER; in bond_ethtool_get_link_ksettings()
5864 * do not need to check mode. Though link speed might not represent in bond_ethtool_get_link_ksettings()
5871 if (slave->speed != SPEED_UNKNOWN) { in bond_ethtool_get_link_ksettings()
5876 speed += slave->speed; in bond_ethtool_get_link_ksettings()
5878 if (cmd->base.duplex == DUPLEX_UNKNOWN && in bond_ethtool_get_link_ksettings()
5879 slave->duplex != DUPLEX_UNKNOWN) in bond_ethtool_get_link_ksettings()
5880 cmd->base.duplex = slave->duplex; in bond_ethtool_get_link_ksettings()
5883 cmd->base.speed = speed ? : SPEED_UNKNOWN; in bond_ethtool_get_link_ksettings()
5891 strscpy(drvinfo->driver, DRV_NAME, sizeof(drvinfo->driver)); in bond_ethtool_get_drvinfo()
5892 snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), "%d", in bond_ethtool_get_drvinfo()
5918 ret = ethtool_get_ts_info_by_layer(slave->dev, &ts_info); in bond_ethtool_get_ts_info()
5931 info->so_timestamping |= SOF_TIMESTAMPING_TX_SOFTWARE; in bond_ethtool_get_ts_info()
5988 if (bond->wq) in bond_destructor()
5989 destroy_workqueue(bond->wq); in bond_destructor()
5991 free_percpu(bond->rr_tx_counter); in bond_destructor()
5998 spin_lock_init(&bond->mode_lock); in bond_setup()
5999 bond->params = bonding_defaults; in bond_setup()
6002 bond->dev = bond_dev; in bond_setup()
6006 bond_dev->max_mtu = ETH_MAX_MTU; in bond_setup()
6007 bond_dev->netdev_ops = &bond_netdev_ops; in bond_setup()
6008 bond_dev->ethtool_ops = &bond_ethtool_ops; in bond_setup()
6010 bond_dev->needs_free_netdev = true; in bond_setup()
6011 bond_dev->priv_destructor = bond_destructor; in bond_setup()
6016 bond_dev->flags |= IFF_MASTER; in bond_setup()
6017 bond_dev->priv_flags |= IFF_BONDING | IFF_UNICAST_FLT | IFF_NO_QUEUE; in bond_setup()
6018 bond_dev->priv_flags &= ~(IFF_XMIT_DST_RELEASE | IFF_TX_SKB_SHARING); in bond_setup()
6021 /* set up xfrm device ops (only supported in active-backup right now) */ in bond_setup()
6022 bond_dev->xfrmdev_ops = &bond_xfrmdev_ops; in bond_setup()
6023 INIT_LIST_HEAD(&bond->ipsec_list); in bond_setup()
6024 mutex_init(&bond->ipsec_lock); in bond_setup()
6028 bond_dev->lltx = true; in bond_setup()
6031 bond_dev->netns_local = true; in bond_setup()
6040 bond_dev->hw_features = BOND_VLAN_FEATURES | in bond_setup()
6046 bond_dev->hw_features |= NETIF_F_GSO_ENCAP_ALL; in bond_setup()
6047 bond_dev->features |= bond_dev->hw_features; in bond_setup()
6048 bond_dev->features |= NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX; in bond_setup()
6050 bond_dev->hw_features |= BOND_XFRM_FEATURES; in bond_setup()
6051 /* Only enable XFRM features if this is an active-backup config */ in bond_setup()
6053 bond_dev->features |= BOND_XFRM_FEATURES; in bond_setup()
6070 __bond_release_one(bond_dev, slave->dev, true, true); in bond_uninit()
6074 mutex_destroy(&bond->ipsec_lock); in bond_uninit()
6079 list_del_rcu(&bond->bond_list); in bond_uninit()
6084 /*------------------------- Module initialization ---------------------------*/
6107 return -EINVAL; in bond_check_params()
6109 bond_mode = valptr->value; in bond_check_params()
6125 return -EINVAL; in bond_check_params()
6127 xmit_hashtype = valptr->value; in bond_check_params()
6142 return -EINVAL; in bond_check_params()
6144 lacp_fast = valptr->value; in bond_check_params()
6154 return -EINVAL; in bond_check_params()
6156 params->ad_select = valptr->value; in bond_check_params()
6160 params->ad_select = BOND_AD_STABLE; in bond_check_params()
6164 …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()
6170 pr_warn("Warning: miimon module parameter (%d), not in range 0-%d, so it was reset to 0\n", in bond_check_params()
6176 pr_warn("Warning: updelay module parameter (%d), not in range 0-%d, so it was reset to 0\n", in bond_check_params()
6182 pr_warn("Warning: downdelay module parameter (%d), not in range 0-%d, so it was reset to 0\n", in bond_check_params()
6194 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()
6202 …pr_warn("Warning: miimon must be specified, otherwise bonding will not detect link failure, speed … in bond_check_params()
6234 …pr_notice("In ALB mode you might experience client disconnections upon reconnection of a link if t… in bond_check_params()
6271 pr_warn("Warning: arp_interval module parameter (%d), not in range 0-%d, so it was reset to 0\n", in bond_check_params()
6281 if (!in4_pton(arp_ip_target[i], -1, (u8 *)&ip, -1, NULL) || in bond_check_params()
6287 if (bond_get_targets_ip(arp_target, ip) == -1) in bond_check_params()
6305 return -EINVAL; in bond_check_params()
6314 return -EINVAL; in bond_check_params()
6316 arp_validate_value = valptr->value; in bond_check_params()
6330 arp_all_targets_value = valptr->value; in bond_check_params()
6335 pr_info("MII link monitoring set to %d ms\n", miimon); in bond_check_params()
6340 arp_interval, valptr->string, arp_ip_count); in bond_check_params()
6351 …et module parameters must be specified, otherwise bonding will not detect link failures! see bondi… in bond_check_params()
6356 * in active backup, TLB or ALB modes in bond_check_params()
6370 return -EINVAL; in bond_check_params()
6372 primary_reselect_value = valptr->value; in bond_check_params()
6384 return -EINVAL; in bond_check_params()
6386 fail_over_mac_value = valptr->value; in bond_check_params()
6388 pr_warn("Warning: fail_over_mac only affects active-backup mode\n"); in bond_check_params()
6399 return -EINVAL; in bond_check_params()
6401 ad_actor_sys_prio = valptr->value; in bond_check_params()
6407 return -EINVAL; in bond_check_params()
6409 ad_user_port_key = valptr->value; in bond_check_params()
6415 return -EINVAL; in bond_check_params()
6417 tlb_dynamic_lb = valptr->value; in bond_check_params()
6426 params->mode = bond_mode; in bond_check_params()
6427 params->xmit_policy = xmit_hashtype; in bond_check_params()
6428 params->miimon = miimon; in bond_check_params()
6429 params->num_peer_notif = num_peer_notif; in bond_check_params()
6430 params->arp_interval = arp_interval; in bond_check_params()
6431 params->arp_validate = arp_validate_value; in bond_check_params()
6432 params->arp_all_targets = arp_all_targets_value; in bond_check_params()
6433 params->missed_max = 2; in bond_check_params()
6434 params->updelay = updelay; in bond_check_params()
6435 params->downdelay = downdelay; in bond_check_params()
6436 params->peer_notif_delay = 0; in bond_check_params()
6437 params->use_carrier = use_carrier; in bond_check_params()
6438 params->lacp_active = 1; in bond_check_params()
6439 params->lacp_fast = lacp_fast; in bond_check_params()
6440 params->primary[0] = 0; in bond_check_params()
6441 params->primary_reselect = primary_reselect_value; in bond_check_params()
6442 params->fail_over_mac = fail_over_mac_value; in bond_check_params()
6443 params->tx_queues = tx_queues; in bond_check_params()
6444 params->all_slaves_active = all_slaves_active; in bond_check_params()
6445 params->resend_igmp = resend_igmp; in bond_check_params()
6446 params->min_links = min_links; in bond_check_params()
6447 params->lp_interval = lp_interval; in bond_check_params()
6448 params->packets_per_slave = packets_per_slave; in bond_check_params()
6449 params->tlb_dynamic_lb = tlb_dynamic_lb; in bond_check_params()
6450 params->ad_actor_sys_prio = ad_actor_sys_prio; in bond_check_params()
6451 eth_zero_addr(params->ad_actor_system); in bond_check_params()
6452 params->ad_user_port_key = ad_user_port_key; in bond_check_params()
6453 params->coupled_control = 1; in bond_check_params()
6455 params->reciprocal_packets_per_slave = in bond_check_params()
6461 params->reciprocal_packets_per_slave = in bond_check_params()
6466 strscpy_pad(params->primary, primary, sizeof(params->primary)); in bond_check_params()
6468 memcpy(params->arp_targets, arp_target, sizeof(arp_target)); in bond_check_params()
6470 memset(params->ns_targets, 0, sizeof(struct in6_addr) * BOND_MAX_NS_TARGETS); in bond_check_params()
6484 bond->wq = alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, in bond_init()
6485 bond_dev->name); in bond_init()
6486 if (!bond->wq) in bond_init()
6487 return -ENOMEM; in bond_init()
6489 bond->notifier_ctx = false; in bond_init()
6491 spin_lock_init(&bond->stats_lock); in bond_init()
6494 list_add_tail_rcu(&bond->bond_list, &bn->dev_list); in bond_init()
6501 if (is_zero_ether_addr(bond_dev->dev_addr) && in bond_init()
6502 bond_dev->addr_assign_type == NET_ADDR_PERM) in bond_init()
6522 int res = -ENOMEM; in bond_create()
6534 bond_dev->rtnl_link_ops = &bond_link_ops; in bond_create()
6555 bn->net = net; in bond_net_init()
6556 INIT_LIST_HEAD(&bn->dev_list); in bond_net_init()
6586 list_for_each_entry_safe(bond, tmp_bond, &bn->dev_list, bond_list) in bond_net_exit_batch_rtnl()
6587 unregister_netdevice_queue(bond->dev, dev_kill_list); in bond_net_exit_batch_rtnl()