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

70 #include <linux/mii.h>
89 /*---------------------------- Module parameters ----------------------------*/
136 MODULE_PARM_DESC(use_carrier, "Use netif_carrier_ok (vs MII ioctls) in miimon; "
139 MODULE_PARM_DESC(mode, "Mode of operation; 0 for balance-rr, "
140 "1 for active-backup, 2 for balance-xor, "
141 "3 for broadcast, 4 for 802.3ad, 5 for balance-tlb, "
142 "6 for balance-alb");
164 MODULE_PARM_DESC(xmit_hash_policy, "balance-alb, balance-tlb, balance-xor, 802.3ad hashing method; "
179 MODULE_PARM_DESC(fail_over_mac, "For active-backup, do not set all slaves to "
190 MODULE_PARM_DESC(packets_per_slave, "Packets to send per slave in balance-rr "
198 /*----------------------------- Global variables ----------------------------*/
251 /*-------------------------- Forward declarations ---------------------------*/
262 /*---------------------------- General routines -----------------------------*/
267 [BOND_MODE_ROUNDROBIN] = "load balancing (round-robin)", in bond_mode_name()
268 [BOND_MODE_ACTIVEBACKUP] = "fault-tolerance (active-backup)", in bond_mode_name()
270 [BOND_MODE_BROADCAST] = "fault-tolerance (broadcast)", in bond_mode_name()
283 * bond_dev_queue_xmit - Prepare skb for xmit.
292 skb->dev = slave_dev; in bond_dev_queue_xmit()
294 BUILD_BUG_ON(sizeof(skb->queue_mapping) != in bond_dev_queue_xmit()
295 sizeof(qdisc_skb_cb(skb)->slave_dev_queue_mapping)); in bond_dev_queue_xmit()
296 skb_set_queue_mapping(skb, qdisc_skb_cb(skb)->slave_dev_queue_mapping); in bond_dev_queue_xmit()
298 if (unlikely(netpoll_tx_running(bond->dev))) in bond_dev_queue_xmit()
304 /*---------------------------------- VLAN -----------------------------------*/
323 * bond_vlan_rx_add_vid - Propagates adding an id to slaves
337 res = vlan_vid_add(slave->dev, proto, vid); in bond_vlan_rx_add_vid()
350 vlan_vid_del(rollback_slave->dev, proto, vid); in bond_vlan_rx_add_vid()
357 * bond_vlan_rx_kill_vid - Propagates deleting an id to slaves
370 vlan_vid_del(slave->dev, proto, vid); in bond_vlan_rx_kill_vid()
378 /*---------------------------------- XFRM -----------------------------------*/
382 * bond_ipsec_add_sa - program device with a security association
387 struct net_device *bond_dev = xs->xso.dev; in bond_ipsec_add_sa()
392 return -EINVAL; in bond_ipsec_add_sa()
395 slave = rcu_dereference(bond->curr_active_slave); in bond_ipsec_add_sa()
396 xs->xso.real_dev = slave->dev; in bond_ipsec_add_sa()
397 bond->xs = xs; in bond_ipsec_add_sa()
399 if (!(slave->dev->xfrmdev_ops in bond_ipsec_add_sa()
400 && slave->dev->xfrmdev_ops->xdo_dev_state_add)) { in bond_ipsec_add_sa()
401 slave_warn(bond_dev, slave->dev, "Slave does not support ipsec offload\n"); in bond_ipsec_add_sa()
402 return -EINVAL; in bond_ipsec_add_sa()
405 return slave->dev->xfrmdev_ops->xdo_dev_state_add(xs); in bond_ipsec_add_sa()
409 * bond_ipsec_del_sa - clear out this specific SA
414 struct net_device *bond_dev = xs->xso.dev; in bond_ipsec_del_sa()
422 slave = rcu_dereference(bond->curr_active_slave); in bond_ipsec_del_sa()
427 xs->xso.real_dev = slave->dev; in bond_ipsec_del_sa()
429 if (!(slave->dev->xfrmdev_ops in bond_ipsec_del_sa()
430 && slave->dev->xfrmdev_ops->xdo_dev_state_delete)) { in bond_ipsec_del_sa()
431 slave_warn(bond_dev, slave->dev, "%s: no slave xdo_dev_state_delete\n", __func__); in bond_ipsec_del_sa()
435 slave->dev->xfrmdev_ops->xdo_dev_state_delete(xs); in bond_ipsec_del_sa()
439 * bond_ipsec_offload_ok - can this packet use the xfrm hw offload
445 struct net_device *bond_dev = xs->xso.dev; in bond_ipsec_offload_ok()
447 struct slave *curr_active = rcu_dereference(bond->curr_active_slave); in bond_ipsec_offload_ok()
448 struct net_device *slave_dev = curr_active->dev; in bond_ipsec_offload_ok()
453 if (!(slave_dev->xfrmdev_ops in bond_ipsec_offload_ok()
454 && slave_dev->xfrmdev_ops->xdo_dev_offload_ok)) { in bond_ipsec_offload_ok()
459 xs->xso.real_dev = slave_dev; in bond_ipsec_offload_ok()
460 return slave_dev->xfrmdev_ops->xdo_dev_offload_ok(skb, xs); in bond_ipsec_offload_ok()
470 /*------------------------------- Link status -------------------------------*/
490 if (slave->link == BOND_LINK_UP) { in bond_set_carrier()
491 if (!netif_carrier_ok(bond->dev)) { in bond_set_carrier()
492 netif_carrier_on(bond->dev); in bond_set_carrier()
500 if (netif_carrier_ok(bond->dev)) { in bond_set_carrier()
501 netif_carrier_off(bond->dev); in bond_set_carrier()
509 * values are invalid, set speed and duplex to -1,
515 struct net_device *slave_dev = slave->dev; in bond_update_speed_duplex()
519 slave->speed = SPEED_UNKNOWN; in bond_update_speed_duplex()
520 slave->duplex = DUPLEX_UNKNOWN; in bond_update_speed_duplex()
525 if (ecmd.base.speed == 0 || ecmd.base.speed == ((__u32)-1)) in bond_update_speed_duplex()
535 slave->speed = ecmd.base.speed; in bond_update_speed_duplex()
536 slave->duplex = ecmd.base.duplex; in bond_update_speed_duplex()
557 /* if <dev> supports MII link status reporting, check its link status.
559 * We either do MII/ETHTOOL ioctls, or check netif_carrier_ok(),
566 * If reporting is non-zero, instead of faking link up, return -1 if
567 * both ETHTOOL and MII ioctls fail (meaning the device does not
575 const struct net_device_ops *slave_ops = slave_dev->netdev_ops; in bond_check_dev_link()
578 struct mii_ioctl_data *mii; in bond_check_dev_link() local
583 if (bond->params.use_carrier) in bond_check_dev_link()
587 if (slave_dev->ethtool_ops->get_link) in bond_check_dev_link()
588 return slave_dev->ethtool_ops->get_link(slave_dev) ? in bond_check_dev_link()
591 /* Ethtool can't be used, fallback to MII ioctls. */ in bond_check_dev_link()
592 ioctl = slave_ops->ndo_do_ioctl; in bond_check_dev_link()
606 /* Yes, the mii is overlaid on the ifreq.ifr_ifru */ in bond_check_dev_link()
607 strncpy(ifr.ifr_name, slave_dev->name, IFNAMSIZ); in bond_check_dev_link()
608 mii = if_mii(&ifr); in bond_check_dev_link()
610 mii->reg_num = MII_BMSR; in bond_check_dev_link()
612 return mii->val_out & BMSR_LSTATUS; in bond_check_dev_link()
616 /* If reporting, report that either there's no dev->do_ioctl, in bond_check_dev_link()
621 return reporting ? -1 : BMSR_LSTATUS; in bond_check_dev_link()
624 /*----------------------------- Multicast list ------------------------------*/
633 struct slave *curr_active = rtnl_dereference(bond->curr_active_slave); in bond_set_promiscuity()
636 err = dev_set_promiscuity(curr_active->dev, inc); in bond_set_promiscuity()
641 err = dev_set_promiscuity(slave->dev, inc); in bond_set_promiscuity()
656 struct slave *curr_active = rtnl_dereference(bond->curr_active_slave); in bond_set_allmulti()
659 err = dev_set_allmulti(curr_active->dev, inc); in bond_set_allmulti()
664 err = dev_set_allmulti(slave->dev, inc); in bond_set_allmulti()
682 queue_delayed_work(bond->wq, &bond->mcast_work, 1); in bond_resend_igmp_join_requests_delayed()
685 call_netdevice_notifiers(NETDEV_RESEND_IGMP, bond->dev); in bond_resend_igmp_join_requests_delayed()
687 if (bond->igmp_retrans > 1) { in bond_resend_igmp_join_requests_delayed()
688 bond->igmp_retrans--; in bond_resend_igmp_join_requests_delayed()
689 queue_delayed_work(bond->wq, &bond->mcast_work, HZ/5); in bond_resend_igmp_join_requests_delayed()
711 /*--------------------------- Active slave change ---------------------------*/
722 if (bond->dev->flags & IFF_PROMISC) in bond_hw_addr_swap()
723 dev_set_promiscuity(old_active->dev, -1); in bond_hw_addr_swap()
725 if (bond->dev->flags & IFF_ALLMULTI) in bond_hw_addr_swap()
726 dev_set_allmulti(old_active->dev, -1); in bond_hw_addr_swap()
728 bond_hw_addr_flush(bond->dev, old_active->dev); in bond_hw_addr_swap()
733 if (bond->dev->flags & IFF_PROMISC) in bond_hw_addr_swap()
734 dev_set_promiscuity(new_active->dev, 1); in bond_hw_addr_swap()
736 if (bond->dev->flags & IFF_ALLMULTI) in bond_hw_addr_swap()
737 dev_set_allmulti(new_active->dev, 1); in bond_hw_addr_swap()
739 netif_addr_lock_bh(bond->dev); in bond_hw_addr_swap()
740 dev_uc_sync(new_active->dev, bond->dev); in bond_hw_addr_swap()
741 dev_mc_sync(new_active->dev, bond->dev); in bond_hw_addr_swap()
742 netif_addr_unlock_bh(bond->dev); in bond_hw_addr_swap()
747 * bond_set_dev_addr - clone slave's address to bond
758 slave_dbg(bond_dev, slave_dev, "bond_dev=%p slave_dev=%p slave_dev->addr_len=%d\n", in bond_set_dev_addr()
759 bond_dev, slave_dev, slave_dev->addr_len); in bond_set_dev_addr()
760 err = dev_pre_changeaddr_notify(bond_dev, slave_dev->dev_addr, NULL); in bond_set_dev_addr()
764 memcpy(bond_dev->dev_addr, slave_dev->dev_addr, slave_dev->addr_len); in bond_set_dev_addr()
765 bond_dev->addr_assign_type = NET_ADDR_STOLEN; in bond_set_dev_addr()
780 if (ether_addr_equal(bond->dev->dev_addr, slave->dev->dev_addr)) in bond_get_old_active()
801 switch (bond->params.fail_over_mac) { in bond_do_fail_over_mac()
804 rv = bond_set_dev_addr(bond->dev, new_active->dev); in bond_do_fail_over_mac()
806 slave_err(bond->dev, new_active->dev, "Error %d setting bond MAC from slave\n", in bond_do_fail_over_mac()
807 -rv); in bond_do_fail_over_mac()
822 bond_hw_addr_copy(tmp_mac, new_active->dev->dev_addr, in bond_do_fail_over_mac()
823 new_active->dev->addr_len); in bond_do_fail_over_mac()
825 old_active->dev->dev_addr, in bond_do_fail_over_mac()
826 old_active->dev->addr_len); in bond_do_fail_over_mac()
827 ss.ss_family = new_active->dev->type; in bond_do_fail_over_mac()
829 bond_hw_addr_copy(ss.__data, bond->dev->dev_addr, in bond_do_fail_over_mac()
830 bond->dev->addr_len); in bond_do_fail_over_mac()
831 ss.ss_family = bond->dev->type; in bond_do_fail_over_mac()
834 rv = dev_set_mac_address(new_active->dev, in bond_do_fail_over_mac()
837 slave_err(bond->dev, new_active->dev, "Error %d setting MAC of new active slave\n", in bond_do_fail_over_mac()
838 -rv); in bond_do_fail_over_mac()
846 new_active->dev->addr_len); in bond_do_fail_over_mac()
847 ss.ss_family = old_active->dev->type; in bond_do_fail_over_mac()
849 rv = dev_set_mac_address(old_active->dev, in bond_do_fail_over_mac()
852 slave_err(bond->dev, old_active->dev, "Error %d setting MAC of old active slave\n", in bond_do_fail_over_mac()
853 -rv); in bond_do_fail_over_mac()
857 netdev_err(bond->dev, "bond_do_fail_over_mac impossible: bad policy %d\n", in bond_do_fail_over_mac()
858 bond->params.fail_over_mac); in bond_do_fail_over_mac()
866 struct slave *prim = rtnl_dereference(bond->primary_slave); in bond_choose_primary_or_current()
867 struct slave *curr = rtnl_dereference(bond->curr_active_slave); in bond_choose_primary_or_current()
869 if (!prim || prim->link != BOND_LINK_UP) { in bond_choose_primary_or_current()
870 if (!curr || curr->link != BOND_LINK_UP) in bond_choose_primary_or_current()
875 if (bond->force_primary) { in bond_choose_primary_or_current()
876 bond->force_primary = false; in bond_choose_primary_or_current()
880 if (!curr || curr->link != BOND_LINK_UP) in bond_choose_primary_or_current()
884 switch (bond->params.primary_reselect) { in bond_choose_primary_or_current()
888 if (prim->speed < curr->speed) in bond_choose_primary_or_current()
890 if (prim->speed == curr->speed && prim->duplex <= curr->duplex) in bond_choose_primary_or_current()
896 netdev_err(bond->dev, "impossible primary_reselect %d\n", in bond_choose_primary_or_current()
897 bond->params.primary_reselect); in bond_choose_primary_or_current()
903 * bond_find_best_slave - select the best available slave to be the active one
910 int mintime = bond->params.updelay; in bond_find_best_slave()
917 if (slave->link == BOND_LINK_UP) in bond_find_best_slave()
919 if (slave->link == BOND_LINK_BACK && bond_slave_is_up(slave) && in bond_find_best_slave()
920 slave->delay < mintime) { in bond_find_best_slave()
921 mintime = slave->delay; in bond_find_best_slave()
934 slave = rcu_dereference(bond->curr_active_slave); in bond_should_notify_peers()
937 netdev_dbg(bond->dev, "bond_should_notify_peers: slave %s\n", in bond_should_notify_peers()
938 slave ? slave->dev->name : "NULL"); in bond_should_notify_peers()
940 if (!slave || !bond->send_peer_notif || in bond_should_notify_peers()
941 bond->send_peer_notif % in bond_should_notify_peers()
942 max(1, bond->params.peer_notif_delay) != 0 || in bond_should_notify_peers()
943 !netif_carrier_ok(bond->dev) || in bond_should_notify_peers()
944 test_bit(__LINK_STATE_LINKWATCH_PENDING, &slave->dev->state)) in bond_should_notify_peers()
951 * change_active_interface - change the active slave into the specified one
957 * Setting include flags, mc-list, promiscuity, allmulti, etc.
971 old_active = rtnl_dereference(bond->curr_active_slave); in bond_change_active_slave()
977 if (old_active && bond->xs) in bond_change_active_slave()
978 bond_ipsec_del_sa(bond->xs); in bond_change_active_slave()
982 new_active->last_link_up = jiffies; in bond_change_active_slave()
984 if (new_active->link == BOND_LINK_BACK) { in bond_change_active_slave()
986 slave_info(bond->dev, new_active->dev, "making interface the new active one %d ms earlier\n", in bond_change_active_slave()
987 (bond->params.updelay - new_active->delay) * bond->params.miimon); in bond_change_active_slave()
990 new_active->delay = 0; in bond_change_active_slave()
1001 slave_info(bond->dev, new_active->dev, "making interface the new active one\n"); in bond_change_active_slave()
1018 rcu_assign_pointer(bond->curr_active_slave, new_active); in bond_change_active_slave()
1032 if (bond->params.fail_over_mac) in bond_change_active_slave()
1036 if (netif_running(bond->dev)) { in bond_change_active_slave()
1037 bond->send_peer_notif = in bond_change_active_slave()
1038 bond->params.num_peer_notif * in bond_change_active_slave()
1039 max(1, bond->params.peer_notif_delay); in bond_change_active_slave()
1044 call_netdevice_notifiers(NETDEV_BONDING_FAILOVER, bond->dev); in bond_change_active_slave()
1046 bond->send_peer_notif--; in bond_change_active_slave()
1048 bond->dev); in bond_change_active_slave()
1054 if (new_active && bond->xs) { in bond_change_active_slave()
1055 xfrm_dev_state_flush(dev_net(bond->dev), bond->dev, true); in bond_change_active_slave()
1056 bond_ipsec_add_sa(bond->xs); in bond_change_active_slave()
1065 if (netif_running(bond->dev) && (bond->params.resend_igmp > 0) && in bond_change_active_slave()
1068 bond->igmp_retrans = bond->params.resend_igmp; in bond_change_active_slave()
1069 queue_delayed_work(bond->wq, &bond->mcast_work, 1); in bond_change_active_slave()
1074 * bond_select_active_slave - select a new active slave, if needed
1078 * - The old curr_active_slave has been released or lost its link.
1079 * - The primary_slave has got its link back.
1080 * - A slave has got its link back and there's no old curr_active_slave.
1092 if (best_slave != rtnl_dereference(bond->curr_active_slave)) { in bond_select_active_slave()
1098 if (netif_carrier_ok(bond->dev)) in bond_select_active_slave()
1099 netdev_info(bond->dev, "active interface up!\n"); in bond_select_active_slave()
1101 netdev_info(bond->dev, "now running without any active interface!\n"); in bond_select_active_slave()
1112 err = -ENOMEM; in slave_enable_netpoll()
1116 err = __netpoll_setup(np, slave->dev); in slave_enable_netpoll()
1121 slave->np = np; in slave_enable_netpoll()
1127 struct netpoll *np = slave->np; in slave_disable_netpoll()
1132 slave->np = NULL; in slave_disable_netpoll()
1154 SLAVE_AD_INFO(slave)->port.aggregator; in bond_poll_controller()
1157 agg->aggregator_identifier != ad_info.aggregator_id) in bond_poll_controller()
1161 netpoll_poll_dev(slave->dev); in bond_poll_controller()
1205 /*---------------------------------- IOCTL ----------------------------------*/
1222 slave->dev->features, in bond_fix_features()
1251 struct net_device *bond_dev = bond->dev; in bond_compute_features()
1265 slave->dev->vlan_features, BOND_VLAN_FEATURES); in bond_compute_features()
1268 slave->dev->hw_enc_features, in bond_compute_features()
1273 slave->dev->hw_enc_features, in bond_compute_features()
1278 slave->dev->mpls_features, in bond_compute_features()
1281 dst_release_flag &= slave->dev->priv_flags; in bond_compute_features()
1282 if (slave->dev->hard_header_len > max_hard_header_len) in bond_compute_features()
1283 max_hard_header_len = slave->dev->hard_header_len; in bond_compute_features()
1285 gso_max_size = min(gso_max_size, slave->dev->gso_max_size); in bond_compute_features()
1286 gso_max_segs = min(gso_max_segs, slave->dev->gso_max_segs); in bond_compute_features()
1288 bond_dev->hard_header_len = max_hard_header_len; in bond_compute_features()
1291 bond_dev->vlan_features = vlan_features; in bond_compute_features()
1292 bond_dev->hw_enc_features = enc_features | NETIF_F_GSO_ENCAP_ALL | in bond_compute_features()
1297 bond_dev->hw_enc_features |= xfrm_features; in bond_compute_features()
1299 bond_dev->mpls_features = mpls_features; in bond_compute_features()
1300 bond_dev->gso_max_segs = gso_max_segs; in bond_compute_features()
1303 bond_dev->priv_flags &= ~IFF_XMIT_DST_RELEASE; in bond_compute_features()
1304 if ((bond_dev->priv_flags & IFF_XMIT_DST_RELEASE_PERM) && in bond_compute_features()
1306 bond_dev->priv_flags |= IFF_XMIT_DST_RELEASE; in bond_compute_features()
1314 bond_dev->header_ops = slave_dev->header_ops; in bond_setup_by_slave()
1316 bond_dev->type = slave_dev->type; in bond_setup_by_slave()
1317 bond_dev->hard_header_len = slave_dev->hard_header_len; in bond_setup_by_slave()
1318 bond_dev->needed_headroom = slave_dev->needed_headroom; in bond_setup_by_slave()
1319 bond_dev->addr_len = slave_dev->addr_len; in bond_setup_by_slave()
1321 memcpy(bond_dev->broadcast, slave_dev->broadcast, in bond_setup_by_slave()
1322 slave_dev->addr_len); in bond_setup_by_slave()
1326 * duplicates except for alb non-mcast/bcast.
1334 skb->pkt_type != PACKET_BROADCAST && in bond_should_deliver_exact_match()
1335 skb->pkt_type != PACKET_MULTICAST) in bond_should_deliver_exact_match()
1357 slave = bond_slave_get_rcu(skb->dev); in bond_handle_frame()
1358 bond = slave->bond; in bond_handle_frame()
1360 recv_probe = READ_ONCE(bond->recv_probe); in bond_handle_frame()
1371 * be suppressed we want to make an exception for link-local packets. in bond_handle_frame()
1377 * (including link-local ones) can have their originating interface in bond_handle_frame()
1381 if (is_link_local_ether_addr(eth_hdr(skb)->h_dest)) in bond_handle_frame()
1386 skb->dev = bond->dev; in bond_handle_frame()
1389 netif_is_bridge_port(bond->dev) && in bond_handle_frame()
1390 skb->pkt_type == PACKET_HOST) { in bond_handle_frame()
1393 skb->data - skb_mac_header(skb)))) { in bond_handle_frame()
1397 bond_hw_addr_copy(eth_hdr(skb)->h_dest, bond->dev->dev_addr, in bond_handle_frame()
1398 bond->dev->addr_len); in bond_handle_frame()
1427 switch (bond->params.xmit_policy) { in bond_lag_hash_type()
1453 return netdev_master_upper_dev_link(slave->dev, bond->dev, slave, in bond_master_upper_dev_link()
1459 netdev_upper_dev_unlink(slave->dev, bond->dev); in bond_upper_dev_unlink()
1460 slave->dev->flags &= ~IFF_SLAVE; in bond_upper_dev_unlink()
1468 cancel_delayed_work_sync(&slave->notify_work); in slave_kobj_release()
1486 err = kobject_init_and_add(&slave->kobj, &slave_ktype, in bond_kobj_init()
1487 &(slave->dev->dev.kobj), "bonding_slave"); in bond_kobj_init()
1489 kobject_put(&slave->kobj); in bond_kobj_init()
1503 slave->bond = bond; in bond_alloc_slave()
1504 slave->dev = slave_dev; in bond_alloc_slave()
1513 kobject_put(&slave->kobj); in bond_alloc_slave()
1517 INIT_DELAYED_WORK(&slave->notify_work, bond_netdev_notify_work); in bond_alloc_slave()
1524 info->bond_mode = BOND_MODE(bond); in bond_fill_ifbond()
1525 info->miimon = bond->params.miimon; in bond_fill_ifbond()
1526 info->num_slaves = bond->slave_cnt; in bond_fill_ifbond()
1531 strcpy(info->slave_name, slave->dev->name); in bond_fill_ifslave()
1532 info->link = slave->link; in bond_fill_ifslave()
1533 info->state = bond_slave_state(slave); in bond_fill_ifslave()
1534 info->link_failure_count = slave->link_failure_count; in bond_fill_ifslave()
1546 bond_fill_ifbond(slave->bond, &binfo.master); in bond_netdev_notify_work()
1547 netdev_bonding_info_change(slave->dev, &binfo); in bond_netdev_notify_work()
1550 queue_delayed_work(slave->bond->wq, &slave->notify_work, 1); in bond_netdev_notify_work()
1556 queue_delayed_work(slave->bond->wq, &slave->notify_work, 0); in bond_queue_slave_event()
1563 info.link_up = slave->link == BOND_LINK_UP || in bond_lower_state_changed()
1564 slave->link == BOND_LINK_FAIL; in bond_lower_state_changed()
1566 netdev_lower_state_changed(slave->dev, &info); in bond_lower_state_changed()
1574 const struct net_device_ops *slave_ops = slave_dev->netdev_ops; in bond_enslave()
1580 if (!bond->params.use_carrier && in bond_enslave()
1581 slave_dev->ethtool_ops->get_link == NULL && in bond_enslave()
1582 slave_ops->ndo_do_ioctl == NULL) { in bond_enslave()
1586 /* already in-use? */ in bond_enslave()
1591 return -EBUSY; in bond_enslave()
1597 return -EPERM; in bond_enslave()
1602 if (slave_dev->features & NETIF_F_VLAN_CHALLENGED) { in bond_enslave()
1607 return -EPERM; in bond_enslave()
1615 if (slave_dev->features & NETIF_F_HW_ESP) in bond_enslave()
1616 slave_dbg(bond_dev, slave_dev, "is esp-hw-offload capable\n"); in bond_enslave()
1623 if (slave_dev->flags & IFF_UP) { in bond_enslave()
1625 slave_err(bond_dev, slave_dev, "slave is up - this may be due to an out of date ifenslave\n"); in bond_enslave()
1626 return -EPERM; in bond_enslave()
1629 /* set bonding device ether type by slave - bonding netdevices are in bond_enslave()
1633 * bond ether type mutual exclusion - don't allow slaves of dissimilar in bond_enslave()
1637 if (bond_dev->type != slave_dev->type) { in bond_enslave()
1639 bond_dev->type, slave_dev->type); in bond_enslave()
1646 return -EBUSY; in bond_enslave()
1653 if (slave_dev->type != ARPHRD_ETHER) in bond_enslave()
1657 bond_dev->priv_flags &= ~IFF_TX_SKB_SHARING; in bond_enslave()
1663 } else if (bond_dev->type != slave_dev->type) { in bond_enslave()
1666 slave_dev->type, bond_dev->type); in bond_enslave()
1667 return -EINVAL; in bond_enslave()
1670 if (slave_dev->type == ARPHRD_INFINIBAND && in bond_enslave()
1672 NL_SET_ERR_MSG(extack, "Only active-backup mode is supported for infiniband slaves"); in bond_enslave()
1673 slave_warn(bond_dev, slave_dev, "Type (%d) supports only active-backup mode\n", in bond_enslave()
1674 slave_dev->type); in bond_enslave()
1675 res = -EOPNOTSUPP; in bond_enslave()
1679 if (!slave_ops->ndo_set_mac_address || in bond_enslave()
1680 slave_dev->type == ARPHRD_INFINIBAND) { in bond_enslave()
1683 bond->params.fail_over_mac != BOND_FOM_ACTIVE) { in bond_enslave()
1685 bond->params.fail_over_mac = BOND_FOM_ACTIVE; in bond_enslave()
1686 slave_warn(bond_dev, slave_dev, "Setting fail_over_mac to active for active-backup mode\n"); in bond_enslave()
1690 res = -EOPNOTSUPP; in bond_enslave()
1702 bond->dev->addr_assign_type == NET_ADDR_RANDOM) { in bond_enslave()
1703 res = bond_set_dev_addr(bond->dev, slave_dev); in bond_enslave()
1710 res = -ENOMEM; in bond_enslave()
1717 new_slave->queue_id = 0; in bond_enslave()
1720 new_slave->original_mtu = slave_dev->mtu; in bond_enslave()
1721 res = dev_set_mtu(slave_dev, bond->dev->mtu); in bond_enslave()
1731 bond_hw_addr_copy(new_slave->perm_hwaddr, slave_dev->dev_addr, in bond_enslave()
1732 slave_dev->addr_len); in bond_enslave()
1734 if (!bond->params.fail_over_mac || in bond_enslave()
1739 memcpy(ss.__data, bond_dev->dev_addr, bond_dev->addr_len); in bond_enslave()
1740 ss.ss_family = slave_dev->type; in bond_enslave()
1750 slave_dev->flags |= IFF_SLAVE; in bond_enslave()
1759 slave_dev->priv_flags |= IFF_BONDING; in bond_enslave()
1761 dev_get_stats(new_slave->dev, &new_slave->slave_stats); in bond_enslave()
1780 new_slave->delay = 0; in bond_enslave()
1781 new_slave->link_failure_count = 0; in bond_enslave()
1785 new_slave->link = BOND_LINK_DOWN; in bond_enslave()
1787 new_slave->last_rx = jiffies - in bond_enslave()
1788 (msecs_to_jiffies(bond->params.arp_interval) + 1); in bond_enslave()
1790 new_slave->target_last_arp_rx[i] = new_slave->last_rx; in bond_enslave()
1792 if (bond->params.miimon && !bond->params.use_carrier) { in bond_enslave()
1795 if ((link_reporting == -1) && !bond->params.arp_interval) { in bond_enslave()
1797 * does not support ETHTOOL/MII and in bond_enslave()
1804 …slave_warn(bond_dev, slave_dev, "MII and ETHTOOL support not available for slave, and arp_interval… in bond_enslave()
1805 } else if (link_reporting == -1) { in bond_enslave()
1806 /* unable get link status using mii/ethtool */ in bond_enslave()
1807 … slave; the network driver associated with this interface does not support MII or ETHTOOL link sta… in bond_enslave()
1812 new_slave->link = BOND_LINK_NOCHANGE; in bond_enslave()
1813 if (bond->params.miimon) { in bond_enslave()
1815 if (bond->params.updelay) { in bond_enslave()
1819 new_slave->delay = bond->params.updelay; in bond_enslave()
1829 } else if (bond->params.arp_interval) { in bond_enslave()
1839 if (new_slave->link != BOND_LINK_DOWN) in bond_enslave()
1840 new_slave->last_link_up = jiffies; in bond_enslave()
1842 new_slave->link == BOND_LINK_DOWN ? "DOWN" : in bond_enslave()
1843 (new_slave->link == BOND_LINK_UP ? "UP" : "BACK")); in bond_enslave()
1845 if (bond_uses_primary(bond) && bond->params.primary[0]) { in bond_enslave()
1847 if (strcmp(bond->params.primary, new_slave->dev->name) == 0) { in bond_enslave()
1848 rcu_assign_pointer(bond->primary_slave, new_slave); in bond_enslave()
1849 bond->force_primary = true; in bond_enslave()
1866 SLAVE_AD_INFO(new_slave)->id = 1; in bond_enslave()
1872 SLAVE_AD_INFO(new_slave)->id = in bond_enslave()
1873 SLAVE_AD_INFO(prev_slave)->id + 1; in bond_enslave()
1893 if (!rcu_access_pointer(bond->curr_active_slave) && in bond_enslave()
1894 new_slave->link == BOND_LINK_UP) in bond_enslave()
1895 rcu_assign_pointer(bond->curr_active_slave, new_slave); in bond_enslave()
1901 if (bond->dev->npinfo) { in bond_enslave()
1904 res = -EBUSY; in bond_enslave()
1910 if (!(bond_dev->features & NETIF_F_LRO)) in bond_enslave()
1937 if (bond_dev->flags & IFF_PROMISC) { in bond_enslave()
1944 if (bond_dev->flags & IFF_ALLMULTI) { in bond_enslave()
1947 if (bond_dev->flags & IFF_PROMISC) in bond_enslave()
1948 dev_set_promiscuity(slave_dev, -1); in bond_enslave()
1966 bond->slave_cnt++; in bond_enslave()
1982 new_slave->link != BOND_LINK_DOWN ? "an up" : "a down"); in bond_enslave()
2000 if (rcu_access_pointer(bond->primary_slave) == new_slave) in bond_enslave()
2001 RCU_INIT_POINTER(bond->primary_slave, NULL); in bond_enslave()
2002 if (rcu_access_pointer(bond->curr_active_slave) == new_slave) { in bond_enslave()
2014 slave_dev->priv_flags &= ~IFF_BONDING; in bond_enslave()
2018 slave_dev->flags &= ~IFF_SLAVE; in bond_enslave()
2019 if (!bond->params.fail_over_mac || in bond_enslave()
2021 /* XXX TODO - fom follow mode needs to change master's in bond_enslave()
2025 bond_hw_addr_copy(ss.__data, new_slave->perm_hwaddr, in bond_enslave()
2026 new_slave->dev->addr_len); in bond_enslave()
2027 ss.ss_family = slave_dev->type; in bond_enslave()
2032 dev_set_mtu(slave_dev, new_slave->original_mtu); in bond_enslave()
2035 kobject_put(&new_slave->kobj); in bond_enslave()
2040 if (ether_addr_equal_64bits(bond_dev->dev_addr, in bond_enslave()
2041 slave_dev->dev_addr)) in bond_enslave()
2043 if (bond_dev->type != ARPHRD_ETHER) { in bond_enslave()
2046 bond_dev->flags |= IFF_MASTER; in bond_enslave()
2047 bond_dev->priv_flags &= ~IFF_TX_SKB_SHARING; in bond_enslave()
2056 * is RTNL-locked. If "all" is true it means that the function is being called
2072 int old_flags = bond_dev->flags; in __bond_release_one()
2073 netdev_features_t old_features = bond_dev->features; in __bond_release_one()
2076 if (!(slave_dev->flags & IFF_SLAVE) || in __bond_release_one()
2079 return -EINVAL; in __bond_release_one()
2089 return -EINVAL; in __bond_release_one()
2097 bond_get_stats(bond->dev, &bond->bond_stats); in __bond_release_one()
2114 oldcurrent = rcu_access_pointer(bond->curr_active_slave); in __bond_release_one()
2116 RCU_INIT_POINTER(bond->current_arp_slave, NULL); in __bond_release_one()
2118 if (!all && (!bond->params.fail_over_mac || in __bond_release_one()
2120 if (ether_addr_equal_64bits(bond_dev->dev_addr, slave->perm_hwaddr) && in __bond_release_one()
2122 …slave_warn(bond_dev, slave_dev, "the permanent HWaddr of slave - %pM - is still in use by bond - s… in __bond_release_one()
2123 slave->perm_hwaddr); in __bond_release_one()
2126 if (rtnl_dereference(bond->primary_slave) == slave) in __bond_release_one()
2127 RCU_INIT_POINTER(bond->primary_slave, NULL); in __bond_release_one()
2142 RCU_INIT_POINTER(bond->curr_active_slave, NULL); in __bond_release_one()
2158 bond->slave_cnt--; in __bond_release_one()
2161 call_netdevice_notifiers(NETDEV_CHANGEADDR, bond->dev); in __bond_release_one()
2162 call_netdevice_notifiers(NETDEV_RELEASE, bond->dev); in __bond_release_one()
2166 if (!(bond_dev->features & NETIF_F_VLAN_CHALLENGED) && in __bond_release_one()
2168 …slave_info(bond_dev, slave_dev, "last VLAN challenged slave left bond - VLAN blocking is removed\n… in __bond_release_one()
2184 dev_set_promiscuity(slave_dev, -1); in __bond_release_one()
2188 dev_set_allmulti(slave_dev, -1); in __bond_release_one()
2198 if (bond->params.fail_over_mac != BOND_FOM_ACTIVE || in __bond_release_one()
2201 bond_hw_addr_copy(ss.__data, slave->perm_hwaddr, in __bond_release_one()
2202 slave->dev->addr_len); in __bond_release_one()
2203 ss.ss_family = slave_dev->type; in __bond_release_one()
2208 __dev_set_mtu(slave_dev, slave->original_mtu); in __bond_release_one()
2210 dev_set_mtu(slave_dev, slave->original_mtu); in __bond_release_one()
2213 slave_dev->priv_flags &= ~IFF_BONDING; in __bond_release_one()
2215 kobject_put(&slave->kobj); in __bond_release_one()
2237 bond_dev->reg_state != NETREG_UNREGISTERING) { in bond_release_and_destroy()
2238 bond_dev->priv_flags |= IFF_DISABLE_NETPOLL; in bond_release_and_destroy()
2256 int i = 0, res = -ENODEV; in bond_slave_info_query()
2260 if (i++ == (int)info->slave_id) { in bond_slave_info_query()
2270 /*-------------------------------- Monitoring -------------------------------*/
2280 ignore_updelay = !rcu_dereference(bond->curr_active_slave); in bond_miimon_inspect()
2285 link_state = bond_check_dev_link(bond, slave->dev, 0); in bond_miimon_inspect()
2287 switch (slave->link) { in bond_miimon_inspect()
2294 slave->delay = bond->params.downdelay; in bond_miimon_inspect()
2295 if (slave->delay) { in bond_miimon_inspect()
2296 slave_info(bond->dev, slave->dev, "link status down for %sinterface, disabling it in %d ms\n", in bond_miimon_inspect()
2301 bond->params.downdelay * bond->params.miimon); in bond_miimon_inspect()
2308 slave->last_link_up = jiffies; in bond_miimon_inspect()
2309 slave_info(bond->dev, slave->dev, "link status up again after %d ms\n", in bond_miimon_inspect()
2310 (bond->params.downdelay - slave->delay) * in bond_miimon_inspect()
2311 bond->params.miimon); in bond_miimon_inspect()
2316 if (slave->delay <= 0) { in bond_miimon_inspect()
2322 slave->delay--; in bond_miimon_inspect()
2331 slave->delay = bond->params.updelay; in bond_miimon_inspect()
2333 if (slave->delay) { in bond_miimon_inspect()
2334 slave_info(bond->dev, slave->dev, "link status up, enabling it in %d ms\n", in bond_miimon_inspect()
2336 bond->params.updelay * in bond_miimon_inspect()
2337 bond->params.miimon); in bond_miimon_inspect()
2343 slave_info(bond->dev, slave->dev, "link status down again after %d ms\n", in bond_miimon_inspect()
2344 (bond->params.updelay - slave->delay) * in bond_miimon_inspect()
2345 bond->params.miimon); in bond_miimon_inspect()
2351 slave->delay = 0; in bond_miimon_inspect()
2353 if (slave->delay <= 0) { in bond_miimon_inspect()
2360 slave->delay--; in bond_miimon_inspect()
2392 switch (slave->link_new_state) { in bond_miimon_commit()
2401 slave->link == BOND_LINK_UP) in bond_miimon_commit()
2408 slave->link = BOND_LINK_DOWN; in bond_miimon_commit()
2410 slave_warn(bond->dev, slave->dev, in bond_miimon_commit()
2416 slave->last_link_up = jiffies; in bond_miimon_commit()
2418 primary = rtnl_dereference(bond->primary_slave); in bond_miimon_commit()
2427 slave_info(bond->dev, slave->dev, "link status definitely up, %u Mbps %s duplex\n", in bond_miimon_commit()
2428 slave->speed == SPEED_UNKNOWN ? 0 : slave->speed, in bond_miimon_commit()
2429 slave->duplex ? "full" : "half"); in bond_miimon_commit()
2433 if (!bond->curr_active_slave || slave == primary) in bond_miimon_commit()
2439 if (slave->link_failure_count < UINT_MAX) in bond_miimon_commit()
2440 slave->link_failure_count++; in bond_miimon_commit()
2450 slave_info(bond->dev, slave->dev, "link status definitely down, disabling slave\n"); in bond_miimon_commit()
2454 if (slave == rcu_access_pointer(bond->curr_active_slave)) in bond_miimon_commit()
2460 slave_err(bond->dev, slave->dev, "invalid new link %d on slave\n", in bond_miimon_commit()
2461 slave->link_new_state); in bond_miimon_commit()
2478 * Really a wrapper that splits the mii monitor into two phases: an
2493 delay = msecs_to_jiffies(bond->params.miimon); in bond_mii_monitor()
2501 if (bond->send_peer_notif) { in bond_mii_monitor()
2504 bond->send_peer_notif--; in bond_mii_monitor()
2528 if (bond->params.miimon) in bond_mii_monitor()
2529 queue_delayed_work(bond->wq, &bond->mii_work, delay); in bond_mii_monitor()
2534 call_netdevice_notifiers(NETDEV_NOTIFY_PEERS, bond->dev); in bond_mii_monitor()
2542 __be32 ip = *(__be32 *)priv->data; in bond_upper_dev_walk()
2554 if (ip == bond_confirm_addr(bond->dev, 0, ip)) in bond_has_this_ip()
2558 if (netdev_walk_all_upper_dev_rcu(bond->dev, bond_upper_dev_walk, &priv)) in bond_has_this_ip()
2567 * "native" to a VLAN) might not pass non-tagged frames.
2574 struct net_device *slave_dev = slave->dev; in bond_arp_send()
2575 struct net_device *bond_dev = slave->bond->dev; in bond_arp_send()
2581 NULL, slave_dev->dev_addr, NULL); in bond_arp_send()
2588 if (!tags || tags->vlan_proto == VLAN_N_VID) in bond_arp_send()
2594 while (tags->vlan_proto != VLAN_N_VID) { in bond_arp_send()
2595 if (!tags->vlan_id) { in bond_arp_send()
2601 ntohs(outer_tag->vlan_proto), tags->vlan_id); in bond_arp_send()
2602 skb = vlan_insert_tag_set_proto(skb, tags->vlan_proto, in bond_arp_send()
2603 tags->vlan_id); in bond_arp_send()
2612 if (outer_tag->vlan_id) { in bond_arp_send()
2614 ntohs(outer_tag->vlan_proto), outer_tag->vlan_id); in bond_arp_send()
2615 __vlan_hwaccel_put_tag(skb, outer_tag->vlan_proto, in bond_arp_send()
2616 outer_tag->vlan_id); in bond_arp_send()
2640 return ERR_PTR(-ENOMEM); in bond_verify_device_path()
2665 struct rtable *rt; in bond_arp_send_all() local
2667 __be32 *targets = bond->params.arp_targets, addr; in bond_arp_send_all()
2671 slave_dbg(bond->dev, slave->dev, "%s: target %pI4\n", in bond_arp_send_all()
2676 rt = ip_route_output(dev_net(bond->dev), targets[i], 0, in bond_arp_send_all()
2678 if (IS_ERR(rt)) { in bond_arp_send_all()
2679 /* there's no route to target - try to send arp in bond_arp_send_all()
2682 if (bond->params.arp_validate) in bond_arp_send_all()
2684 bond->dev->name, in bond_arp_send_all()
2692 if (rt->dst.dev == bond->dev) in bond_arp_send_all()
2696 tags = bond_verify_device_path(bond->dev, rt->dst.dev, 0); in bond_arp_send_all()
2702 /* Not our device - skip */ in bond_arp_send_all()
2703 slave_dbg(bond->dev, slave->dev, "no path to arp_ip_target %pI4 via rt.dev %s\n", in bond_arp_send_all()
2704 &targets[i], rt->dst.dev ? rt->dst.dev->name : "NULL"); in bond_arp_send_all()
2706 ip_rt_put(rt); in bond_arp_send_all()
2710 addr = bond_confirm_addr(rt->dst.dev, targets[i], 0); in bond_arp_send_all()
2711 ip_rt_put(rt); in bond_arp_send_all()
2722 slave_dbg(bond->dev, slave->dev, "%s: sip %pI4 tip %pI4 not found\n", in bond_validate_arp()
2727 i = bond_get_targets_ip(bond->params.arp_targets, sip); in bond_validate_arp()
2728 if (i == -1) { in bond_validate_arp()
2729 slave_dbg(bond->dev, slave->dev, "%s: sip %pI4 not found in targets\n", in bond_validate_arp()
2733 slave->last_rx = jiffies; in bond_validate_arp()
2734 slave->target_last_arp_rx[i] = jiffies; in bond_validate_arp()
2740 struct arphdr *arp = (struct arphdr *)skb->data; in bond_arp_rcv()
2744 int is_arp = skb->protocol == __cpu_to_be16(ETH_P_ARP); in bond_arp_rcv()
2750 slave->last_rx = jiffies; in bond_arp_rcv()
2756 alen = arp_hdr_len(bond->dev); in bond_arp_rcv()
2758 slave_dbg(bond->dev, slave->dev, "%s: skb->dev %s\n", in bond_arp_rcv()
2759 __func__, skb->dev->name); in bond_arp_rcv()
2769 if (arp->ar_hln != bond->dev->addr_len || in bond_arp_rcv()
2770 skb->pkt_type == PACKET_OTHERHOST || in bond_arp_rcv()
2771 skb->pkt_type == PACKET_LOOPBACK || in bond_arp_rcv()
2772 arp->ar_hrd != htons(ARPHRD_ETHER) || in bond_arp_rcv()
2773 arp->ar_pro != htons(ETH_P_IP) || in bond_arp_rcv()
2774 arp->ar_pln != 4) in bond_arp_rcv()
2778 arp_ptr += bond->dev->addr_len; in bond_arp_rcv()
2780 arp_ptr += 4 + bond->dev->addr_len; in bond_arp_rcv()
2783 slave_dbg(bond->dev, slave->dev, "%s: %s/%d av %d sv %d sip %pI4 tip %pI4\n", in bond_arp_rcv()
2784 __func__, slave->dev->name, bond_slave_state(slave), in bond_arp_rcv()
2785 bond->params.arp_validate, slave_do_arp_validate(bond, slave), in bond_arp_rcv()
2788 curr_active_slave = rcu_dereference(bond->curr_active_slave); in bond_arp_rcv()
2789 curr_arp_slave = rcu_dereference(bond->current_arp_slave); in bond_arp_rcv()
2818 curr_active_slave->last_link_up)) in bond_arp_rcv()
2820 else if (curr_arp_slave && (arp->ar_op == htons(ARPOP_REPLY)) && in bond_arp_rcv()
2822 dev_trans_start(curr_arp_slave->dev), 1)) in bond_arp_rcv()
2826 if (arp != (struct arphdr *)skb->data) in bond_arp_rcv()
2832 * (last_act - arp_interval) <= jiffies <= (last_act + mod * arp_interval +
2838 int delta_in_ticks = msecs_to_jiffies(bond->params.arp_interval); in bond_time_in_interval()
2841 last_act - delta_in_ticks, in bond_time_in_interval()
2847 * is used in load-balancing mode. if the adapter has been dormant, then an
2862 oldcurrent = rcu_dereference(bond->curr_active_slave); in bond_loadbalance_arp_mon()
2865 * the picture unless it is null. also, slave->last_link_up is not in bond_loadbalance_arp_mon()
2872 unsigned long trans_start = dev_trans_start(slave->dev); in bond_loadbalance_arp_mon()
2876 if (slave->link != BOND_LINK_UP) { in bond_loadbalance_arp_mon()
2878 bond_time_in_interval(bond, slave->last_rx, 1)) { in bond_loadbalance_arp_mon()
2883 /* primary_slave has no meaning in round-robin in bond_loadbalance_arp_mon()
2889 slave_info(bond->dev, slave->dev, "link status definitely up\n"); in bond_loadbalance_arp_mon()
2892 slave_info(bond->dev, slave->dev, "interface is now up\n"); in bond_loadbalance_arp_mon()
2896 /* slave->link == BOND_LINK_UP */ in bond_loadbalance_arp_mon()
2903 !bond_time_in_interval(bond, slave->last_rx, 2)) { in bond_loadbalance_arp_mon()
2908 if (slave->link_failure_count < UINT_MAX) in bond_loadbalance_arp_mon()
2909 slave->link_failure_count++; in bond_loadbalance_arp_mon()
2911 slave_info(bond->dev, slave->dev, "interface is now down\n"); in bond_loadbalance_arp_mon()
2918 /* note: if switch is in round-robin mode, all links in bond_loadbalance_arp_mon()
2919 * must tx arp to ensure all links rx an arp - otherwise in bond_loadbalance_arp_mon()
2922 * do - all replies will be rx'ed on same link causing slaves in bond_loadbalance_arp_mon()
2936 if (slave->link_new_state != BOND_LINK_NOCHANGE) in bond_loadbalance_arp_mon()
2937 slave->link = slave->link_new_state; in bond_loadbalance_arp_mon()
2954 if (bond->params.arp_interval) in bond_loadbalance_arp_mon()
2955 queue_delayed_work(bond->wq, &bond->arp_work, in bond_loadbalance_arp_mon()
2956 msecs_to_jiffies(bond->params.arp_interval)); in bond_loadbalance_arp_mon()
2959 /* Called to inspect slaves for active-backup mode ARP monitor link state
2977 if (slave->link != BOND_LINK_UP) { in bond_ab_arp_inspect()
2981 } else if (slave->link == BOND_LINK_BACK) { in bond_ab_arp_inspect()
2992 if (bond_time_in_interval(bond, slave->last_link_up, 2)) in bond_ab_arp_inspect()
2996 * - No current_arp_slave AND in bond_ab_arp_inspect()
2997 * - more than 3*delta since last receive AND in bond_ab_arp_inspect()
2998 * - the bond has an IP address in bond_ab_arp_inspect()
3000 * Note: a non-null current_arp_slave indicates in bond_ab_arp_inspect()
3003 * we only take the curr_active_slave down - this in bond_ab_arp_inspect()
3008 !rcu_access_pointer(bond->current_arp_slave) && in bond_ab_arp_inspect()
3015 * - more than 2*delta since transmitting OR in bond_ab_arp_inspect()
3016 * - (more than 2*delta since receive AND in bond_ab_arp_inspect()
3019 trans_start = dev_trans_start(slave->dev); in bond_ab_arp_inspect()
3032 * active-backup mode ARP monitor.
3043 switch (slave->link_new_state) { in bond_ab_arp_commit()
3048 trans_start = dev_trans_start(slave->dev); in bond_ab_arp_commit()
3049 if (rtnl_dereference(bond->curr_active_slave) != slave || in bond_ab_arp_commit()
3050 (!rtnl_dereference(bond->curr_active_slave) && in bond_ab_arp_commit()
3054 current_arp_slave = rtnl_dereference(bond->current_arp_slave); in bond_ab_arp_commit()
3061 RCU_INIT_POINTER(bond->current_arp_slave, NULL); in bond_ab_arp_commit()
3064 slave_info(bond->dev, slave->dev, "link status definitely up\n"); in bond_ab_arp_commit()
3066 if (!rtnl_dereference(bond->curr_active_slave) || in bond_ab_arp_commit()
3067 slave == rtnl_dereference(bond->primary_slave)) in bond_ab_arp_commit()
3075 if (slave->link_failure_count < UINT_MAX) in bond_ab_arp_commit()
3076 slave->link_failure_count++; in bond_ab_arp_commit()
3083 slave_info(bond->dev, slave->dev, "link status definitely down, disabling slave\n"); in bond_ab_arp_commit()
3085 if (slave == rtnl_dereference(bond->curr_active_slave)) { in bond_ab_arp_commit()
3086 RCU_INIT_POINTER(bond->current_arp_slave, NULL); in bond_ab_arp_commit()
3101 if (rtnl_dereference(bond->curr_active_slave)) in bond_ab_arp_commit()
3102 RCU_INIT_POINTER(bond->current_arp_slave, NULL); in bond_ab_arp_commit()
3106 slave_err(bond->dev, slave->dev, in bond_ab_arp_commit()
3108 slave->link_new_state); in bond_ab_arp_commit()
3121 /* Send ARP probes for active-backup mode ARP monitor.
3128 *curr_arp_slave = rcu_dereference(bond->current_arp_slave), in bond_ab_arp_probe()
3129 *curr_active_slave = rcu_dereference(bond->curr_active_slave); in bond_ab_arp_probe()
3135 netdev_info(bond->dev, "PROBE: c_arp %s && cas %s BAD\n", in bond_ab_arp_probe()
3136 curr_arp_slave->dev->name, in bond_ab_arp_probe()
3137 curr_active_slave->dev->name); in bond_ab_arp_probe()
3162 * mark it down - this can happen if we have in bond_ab_arp_probe()
3168 if (!bond_slave_is_up(slave) && slave->link == BOND_LINK_UP) { in bond_ab_arp_probe()
3171 if (slave->link_failure_count < UINT_MAX) in bond_ab_arp_probe()
3172 slave->link_failure_count++; in bond_ab_arp_probe()
3177 slave_info(bond->dev, slave->dev, "backup interface is now down\n"); in bond_ab_arp_probe()
3193 new_slave->last_link_up = jiffies; in bond_ab_arp_probe()
3194 rcu_assign_pointer(bond->current_arp_slave, new_slave); in bond_ab_arp_probe()
3198 if (slave->should_notify || slave->should_notify_link) { in bond_ab_arp_probe()
3212 delta_in_ticks = msecs_to_jiffies(bond->params.arp_interval); in bond_activebackup_arp_mon()
3241 if (bond->params.arp_interval) in bond_activebackup_arp_mon()
3242 queue_delayed_work(bond->wq, &bond->arp_work, delta_in_ticks); in bond_activebackup_arp_mon()
3250 bond->dev); in bond_activebackup_arp_mon()
3271 /*-------------------------- netdev event handling --------------------------*/
3323 bond_dev = slave->bond->dev; in bond_slave_netdev_event()
3324 bond = slave->bond; in bond_slave_netdev_event()
3325 primary = rtnl_dereference(bond->primary_slave); in bond_slave_netdev_event()
3331 if (bond_dev->type != ARPHRD_ETHER) in bond_slave_netdev_event()
3340 * in weird state. Mark it as link-fail if the link was in bond_slave_netdev_event()
3341 * previously up or link-down if it hasn't yet come up, and in bond_slave_netdev_event()
3342 * let link-monitoring (miimon) set it right when correct in bond_slave_netdev_event()
3347 if (slave->last_link_up) in bond_slave_netdev_event()
3348 slave->link = BOND_LINK_FAIL; in bond_slave_netdev_event()
3350 slave->link = BOND_LINK_DOWN; in bond_slave_netdev_event()
3357 /* Refresh slave-array if applicable! in bond_slave_netdev_event()
3358 * If the setup does not use miimon or arpmon (mode-specific!), in bond_slave_netdev_event()
3359 * then these events will not cause the slave-array to be in bond_slave_netdev_event()
3371 * an active-backup bond, slaves need in bond_slave_netdev_event()
3384 !bond->params.primary[0]) in bond_slave_netdev_event()
3388 /* slave's name changed - he's no longer primary */ in bond_slave_netdev_event()
3389 RCU_INIT_POINTER(bond->primary_slave, NULL); in bond_slave_netdev_event()
3390 } else if (!strcmp(slave_dev->name, bond->params.primary)) { in bond_slave_netdev_event()
3392 rcu_assign_pointer(bond->primary_slave, slave); in bond_slave_netdev_event()
3393 } else { /* we didn't change primary - exit */ in bond_slave_netdev_event()
3397 netdev_info(bond->dev, "Primary slave changed to %s, reselecting active slave\n", in bond_slave_netdev_event()
3398 primary ? slave_dev->name : "none"); in bond_slave_netdev_event()
3409 call_netdevice_notifiers(event, slave->bond->dev); in bond_slave_netdev_event()
3433 if (!(event_dev->priv_flags & IFF_BONDING)) in bond_netdev_event()
3436 if (event_dev->flags & IFF_MASTER) { in bond_netdev_event()
3444 if (event_dev->flags & IFF_SLAVE) in bond_netdev_event()
3454 /*---------------------------- Hashing Policies -----------------------------*/
3463 return ep->h_dest[5] ^ ep->h_source[5] ^ ep->h_proto; in bond_eth_hash()
3473 if (skb->protocol == htons(ETH_P_IP)) { in bond_flow_ip()
3476 iph = (const struct iphdr *)(skb->data + *noff); in bond_flow_ip()
3478 *noff += iph->ihl << 2; in bond_flow_ip()
3480 *proto = iph->protocol; in bond_flow_ip()
3481 } else if (skb->protocol == htons(ETH_P_IPV6)) { in bond_flow_ip()
3484 iph6 = (const struct ipv6hdr *)(skb->data + *noff); in bond_flow_ip()
3487 *proto = iph6->nexthdr; in bond_flow_ip()
3493 fk->ports.ports = skb_flow_get_ports(skb, *noff, *proto); in bond_flow_ip()
3502 bool l34 = bond->params.xmit_policy == BOND_XMIT_POLICY_LAYER34; in bond_flow_dissect()
3503 int noff, proto = -1; in bond_flow_dissect()
3505 if (bond->params.xmit_policy > BOND_XMIT_POLICY_LAYER23) { in bond_flow_dissect()
3511 fk->ports.ports = 0; in bond_flow_dissect()
3512 memset(&fk->icmp, 0, sizeof(fk->icmp)); in bond_flow_dissect()
3523 skb_flow_get_icmp_tci(skb, &fk->icmp, skb->data, in bond_flow_dissect()
3527 if (!icmp_is_err(fk->icmp.type)) in bond_flow_dissect()
3532 if (!icmpv6_is_err(fk->icmp.type)) in bond_flow_dissect()
3544 * bond_xmit_hash - generate a hash value based on the xmit policy
3556 if (bond->params.xmit_policy == BOND_XMIT_POLICY_ENCAP34 && in bond_xmit_hash()
3557 skb->l4_hash) in bond_xmit_hash()
3558 return skb->hash; in bond_xmit_hash()
3560 if (bond->params.xmit_policy == BOND_XMIT_POLICY_LAYER2 || in bond_xmit_hash()
3564 if (bond->params.xmit_policy == BOND_XMIT_POLICY_LAYER23 || in bond_xmit_hash()
3565 bond->params.xmit_policy == BOND_XMIT_POLICY_ENCAP23) { in bond_xmit_hash()
3581 /*-------------------------- Device entry points ----------------------------*/
3585 INIT_DELAYED_WORK(&bond->mcast_work, in bond_work_init_all()
3587 INIT_DELAYED_WORK(&bond->alb_work, bond_alb_monitor); in bond_work_init_all()
3588 INIT_DELAYED_WORK(&bond->mii_work, bond_mii_monitor); in bond_work_init_all()
3589 INIT_DELAYED_WORK(&bond->arp_work, bond_arp_monitor); in bond_work_init_all()
3590 INIT_DELAYED_WORK(&bond->ad_work, bond_3ad_state_machine_handler); in bond_work_init_all()
3591 INIT_DELAYED_WORK(&bond->slave_arr_work, bond_slave_arr_handler); in bond_work_init_all()
3596 cancel_delayed_work_sync(&bond->mii_work); in bond_work_cancel_all()
3597 cancel_delayed_work_sync(&bond->arp_work); in bond_work_cancel_all()
3598 cancel_delayed_work_sync(&bond->alb_work); in bond_work_cancel_all()
3599 cancel_delayed_work_sync(&bond->ad_work); in bond_work_cancel_all()
3600 cancel_delayed_work_sync(&bond->mcast_work); in bond_work_cancel_all()
3601 cancel_delayed_work_sync(&bond->slave_arr_work); in bond_work_cancel_all()
3610 /* reset slave->backup and slave->inactive */ in bond_open()
3614 slave != rcu_access_pointer(bond->curr_active_slave)) { in bond_open()
3629 return -ENOMEM; in bond_open()
3630 if (bond->params.tlb_dynamic_lb || BOND_MODE(bond) == BOND_MODE_ALB) in bond_open()
3631 queue_delayed_work(bond->wq, &bond->alb_work, 0); in bond_open()
3634 if (bond->params.miimon) /* link check interval, in milliseconds. */ in bond_open()
3635 queue_delayed_work(bond->wq, &bond->mii_work, 0); in bond_open()
3637 if (bond->params.arp_interval) { /* arp interval, in milliseconds. */ in bond_open()
3638 queue_delayed_work(bond->wq, &bond->arp_work, 0); in bond_open()
3639 bond->recv_probe = bond_arp_rcv; in bond_open()
3643 queue_delayed_work(bond->wq, &bond->ad_work, 0); in bond_open()
3645 bond->recv_probe = bond_3ad_lacpdu_recv; in bond_open()
3660 bond->send_peer_notif = 0; in bond_close()
3663 bond->recv_probe = NULL; in bond_close()
3683 s64 delta = nv - ov; in bond_fold_stats()
3687 delta = (s64)(s32)((u32)nv - (u32)ov); in bond_fold_stats()
3705 iter = &dev->adj_list.lower; in bond_get_lowest_level_rcu()
3715 niter = &ldev->adj_list.lower; in bond_get_lowest_level_rcu()
3726 next = dev_stack[--cur]; in bond_get_lowest_level_rcu()
3753 spin_lock_nested(&bond->stats_lock, nest_level); in bond_get_stats()
3754 memcpy(stats, &bond->bond_stats, sizeof(*stats)); in bond_get_stats()
3758 dev_get_stats(slave->dev, &temp); in bond_get_stats()
3760 bond_fold_stats(stats, new, &slave->slave_stats); in bond_get_stats()
3763 memcpy(&slave->slave_stats, new, sizeof(*new)); in bond_get_stats()
3766 memcpy(&bond->bond_stats, stats, sizeof(*stats)); in bond_get_stats()
3767 spin_unlock(&bond->stats_lock); in bond_get_stats()
3779 struct mii_ioctl_data *mii = NULL; in bond_do_ioctl() local
3788 mii = if_mii(ifr); in bond_do_ioctl()
3789 if (!mii) in bond_do_ioctl()
3790 return -EINVAL; in bond_do_ioctl()
3792 mii->phy_id = 0; in bond_do_ioctl()
3798 mii = if_mii(ifr); in bond_do_ioctl()
3799 if (!mii) in bond_do_ioctl()
3800 return -EINVAL; in bond_do_ioctl()
3802 if (mii->reg_num == 1) { in bond_do_ioctl()
3803 mii->val_out = 0; in bond_do_ioctl()
3804 if (netif_carrier_ok(bond->dev)) in bond_do_ioctl()
3805 mii->val_out = BMSR_LSTATUS; in bond_do_ioctl()
3811 u_binfo = (struct ifbond __user *)ifr->ifr_data; in bond_do_ioctl()
3814 return -EFAULT; in bond_do_ioctl()
3818 return -EFAULT; in bond_do_ioctl()
3823 u_sinfo = (struct ifslave __user *)ifr->ifr_data; in bond_do_ioctl()
3826 return -EFAULT; in bond_do_ioctl()
3831 return -EFAULT; in bond_do_ioctl()
3840 if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) in bond_do_ioctl()
3841 return -EPERM; in bond_do_ioctl()
3843 slave_dev = __dev_get_by_name(net, ifr->ifr_slave); in bond_do_ioctl()
3848 return -ENODEV; in bond_do_ioctl()
3865 bond_opt_initstr(&newval, slave_dev->name); in bond_do_ioctl()
3870 res = -EOPNOTSUPP; in bond_do_ioctl()
3882 bond_dev->flags & IFF_PROMISC ? 1 : -1); in bond_change_rx_flags()
3886 bond_dev->flags & IFF_ALLMULTI ? 1 : -1); in bond_change_rx_flags()
3897 slave = rcu_dereference(bond->curr_active_slave); in bond_set_rx_mode()
3899 dev_uc_sync(slave->dev, bond_dev); in bond_set_rx_mode()
3900 dev_mc_sync(slave->dev, bond_dev); in bond_set_rx_mode()
3904 dev_uc_sync_multiple(slave->dev, bond_dev); in bond_set_rx_mode()
3905 dev_mc_sync_multiple(slave->dev, bond_dev); in bond_set_rx_mode()
3913 struct bonding *bond = netdev_priv(n->dev); in bond_neigh_init()
3923 slave_ops = slave->dev->netdev_ops; in bond_neigh_init()
3924 if (!slave_ops->ndo_neigh_setup) in bond_neigh_init()
3936 ret = slave_ops->ndo_neigh_setup(slave->dev, &parms); in bond_neigh_init()
3953 * underlying devices. In that case - do nothing, we're already set up from
3960 if (parms->dev == dev) in bond_neigh_setup()
3961 parms->neigh_setup = bond_neigh_init; in bond_neigh_setup()
3977 slave_dbg(bond_dev, slave->dev, "s %p c_m %p\n", in bond_change_mtu()
3978 slave, slave->dev->netdev_ops->ndo_change_mtu); in bond_change_mtu()
3980 res = dev_set_mtu(slave->dev, new_mtu); in bond_change_mtu()
3991 slave_dbg(bond_dev, slave->dev, "err %d setting mtu to %d\n", in bond_change_mtu()
3997 bond_dev->mtu = new_mtu; in bond_change_mtu()
4009 tmp_res = dev_set_mtu(rollback_slave->dev, bond_dev->mtu); in bond_change_mtu()
4011 slave_dbg(bond_dev, rollback_slave->dev, "unwind err %d\n", in bond_change_mtu()
4041 if (bond->params.fail_over_mac && in bond_set_mac_address()
4045 if (!is_valid_ether_addr(ss->__data)) in bond_set_mac_address()
4046 return -EADDRNOTAVAIL; in bond_set_mac_address()
4049 slave_dbg(bond_dev, slave->dev, "%s: slave=%p\n", in bond_set_mac_address()
4051 res = dev_set_mac_address(slave->dev, addr, NULL); in bond_set_mac_address()
4059 slave_dbg(bond_dev, slave->dev, "%s: err %d\n", in bond_set_mac_address()
4066 memcpy(bond_dev->dev_addr, ss->__data, bond_dev->addr_len); in bond_set_mac_address()
4070 memcpy(tmp_ss.__data, bond_dev->dev_addr, bond_dev->addr_len); in bond_set_mac_address()
4071 tmp_ss.ss_family = bond_dev->type; in bond_set_mac_address()
4080 tmp_res = dev_set_mac_address(rollback_slave->dev, in bond_set_mac_address()
4083 slave_dbg(bond_dev, rollback_slave->dev, "%s: unwind err %d\n", in bond_set_mac_address()
4092 * bond_get_slave_by_id - get xmit slave with slave_id
4094 * @slave_id: slave id up to slave_cnt-1 through which to transmit
4108 if (--i < 0) { in bond_get_slave_by_id()
4117 if (--i < 0) in bond_get_slave_by_id()
4127 * bond_rr_gen_slave_id - generate slave id based on packets_per_slave
4138 int packets_per_slave = bond->params.packets_per_slave; in bond_rr_gen_slave_id()
4145 slave_id = bond->rr_tx_counter; in bond_rr_gen_slave_id()
4149 bond->params.reciprocal_packets_per_slave; in bond_rr_gen_slave_id()
4150 slave_id = reciprocal_divide(bond->rr_tx_counter, in bond_rr_gen_slave_id()
4154 bond->rr_tx_counter++; in bond_rr_gen_slave_id()
4172 if (skb->protocol == htons(ETH_P_IP)) { in bond_xmit_roundrobin_slave_get()
4180 if (iph->protocol == IPPROTO_IGMP) { in bond_xmit_roundrobin_slave_get()
4181 slave = rcu_dereference(bond->curr_active_slave); in bond_xmit_roundrobin_slave_get()
4189 slave_cnt = READ_ONCE(bond->slave_cnt); in bond_xmit_roundrobin_slave_get()
4205 return bond_dev_queue_xmit(bond, skb, slave->dev); in bond_xmit_roundrobin()
4213 return rcu_dereference(bond->curr_active_slave); in bond_xmit_activebackup_slave_get()
4216 /* In active-backup mode, we know that bond->curr_active_slave is always valid if
4227 return bond_dev_queue_xmit(bond, skb, slave->dev); in bond_xmit_activebackup()
4238 queue_delayed_work(bond->wq, &bond->slave_arr_work, delay); in bond_slave_arr_work_rearm()
4274 * this to-be-skipped slave to send a packet out. in bond_skip_slave()
4276 for (idx = 0; slaves && idx < slaves->count; idx++) { in bond_skip_slave()
4277 if (skipslave == slaves->arr[idx]) { in bond_skip_slave()
4278 slaves->arr[idx] = in bond_skip_slave()
4279 slaves->arr[slaves->count - 1]; in bond_skip_slave()
4280 slaves->count--; in bond_skip_slave()
4292 usable = rtnl_dereference(bond->usable_slaves); in bond_set_slave_arr()
4293 rcu_assign_pointer(bond->usable_slaves, usable_slaves); in bond_set_slave_arr()
4296 all = rtnl_dereference(bond->all_slaves); in bond_set_slave_arr()
4297 rcu_assign_pointer(bond->all_slaves, all_slaves); in bond_set_slave_arr()
4305 usable = rtnl_dereference(bond->usable_slaves); in bond_reset_slave_arr()
4307 RCU_INIT_POINTER(bond->usable_slaves, NULL); in bond_reset_slave_arr()
4311 all = rtnl_dereference(bond->all_slaves); in bond_reset_slave_arr()
4313 RCU_INIT_POINTER(bond->all_slaves, NULL); in bond_reset_slave_arr()
4318 /* Build the usable slaves array in control path for modes that use xmit-hash
4319 * to determine the slave interface -
4335 WARN_ON(lockdep_is_held(&bond->mode_lock)); in bond_update_slave_arr()
4339 bond->slave_cnt), GFP_KERNEL); in bond_update_slave_arr()
4341 bond->slave_cnt), GFP_KERNEL); in bond_update_slave_arr()
4343 ret = -ENOMEM; in bond_update_slave_arr()
4363 all_slaves->arr[all_slaves->count++] = slave; in bond_update_slave_arr()
4367 agg = SLAVE_AD_INFO(slave)->port.aggregator; in bond_update_slave_arr()
4368 if (!agg || agg->aggregator_identifier != agg_id) in bond_update_slave_arr()
4374 slave_dbg(bond->dev, slave->dev, "Adding slave to tx hash array[%d]\n", in bond_update_slave_arr()
4375 usable_slaves->count); in bond_update_slave_arr()
4377 usable_slaves->arr[usable_slaves->count++] = slave; in bond_update_slave_arr()
4384 bond_skip_slave(rtnl_dereference(bond->all_slaves), in bond_update_slave_arr()
4386 bond_skip_slave(rtnl_dereference(bond->usable_slaves), in bond_update_slave_arr()
4404 count = slaves ? READ_ONCE(slaves->count) : 0; in bond_xmit_3ad_xor_slave_get()
4408 slave = slaves->arr[hash % count]; in bond_xmit_3ad_xor_slave_get()
4423 slaves = rcu_dereference(bond->usable_slaves); in bond_3ad_xor_xmit()
4426 return bond_dev_queue_xmit(bond, skb, slave->dev); in bond_3ad_xor_xmit()
4442 if (bond_slave_is_up(slave) && slave->link == BOND_LINK_UP) { in bond_xmit_broadcast()
4447 bond_dev->name, __func__); in bond_xmit_broadcast()
4450 bond_dev_queue_xmit(bond, skb2, slave->dev); in bond_xmit_broadcast()
4453 if (slave && bond_slave_is_up(slave) && slave->link == BOND_LINK_UP) in bond_xmit_broadcast()
4454 return bond_dev_queue_xmit(bond, skb, slave->dev); in bond_xmit_broadcast()
4459 /*------------------------- Device initialization ---------------------------*/
4473 if (slave->queue_id == skb_get_queue_mapping(skb)) { in bond_slave_override()
4475 slave->link == BOND_LINK_UP) { in bond_slave_override()
4476 bond_dev_queue_xmit(bond, skb, slave->dev); in bond_slave_override()
4499 qdisc_skb_cb(skb)->slave_dev_queue_mapping = skb_get_queue_mapping(skb); in bond_select_queue()
4501 if (unlikely(txq >= dev->real_num_tx_queues)) { in bond_select_queue()
4503 txq -= dev->real_num_tx_queues; in bond_select_queue()
4504 } while (txq >= dev->real_num_tx_queues); in bond_select_queue()
4527 slaves = rcu_dereference(bond->all_slaves); in bond_xmit_get_slave()
4529 slaves = rcu_dereference(bond->usable_slaves); in bond_xmit_get_slave()
4547 return slave->dev; in bond_xmit_get_slave()
4605 speed = slave->speed; in bond_mode_bcast_speed()
4607 speed = min(speed, slave->speed); in bond_mode_bcast_speed()
4620 cmd->base.duplex = DUPLEX_UNKNOWN; in bond_ethtool_get_link_ksettings()
4621 cmd->base.port = PORT_OTHER; in bond_ethtool_get_link_ksettings()
4630 if (slave->speed != SPEED_UNKNOWN) { in bond_ethtool_get_link_ksettings()
4635 speed += slave->speed; in bond_ethtool_get_link_ksettings()
4637 if (cmd->base.duplex == DUPLEX_UNKNOWN && in bond_ethtool_get_link_ksettings()
4638 slave->duplex != DUPLEX_UNKNOWN) in bond_ethtool_get_link_ksettings()
4639 cmd->base.duplex = slave->duplex; in bond_ethtool_get_link_ksettings()
4642 cmd->base.speed = speed ? : SPEED_UNKNOWN; in bond_ethtool_get_link_ksettings()
4650 strlcpy(drvinfo->driver, DRV_NAME, sizeof(drvinfo->driver)); in bond_ethtool_get_drvinfo()
4651 snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), "%d", in bond_ethtool_get_drvinfo()
4696 if (bond->wq) in bond_destructor()
4697 destroy_workqueue(bond->wq); in bond_destructor()
4704 spin_lock_init(&bond->mode_lock); in bond_setup()
4705 bond->params = bonding_defaults; in bond_setup()
4708 bond->dev = bond_dev; in bond_setup()
4712 bond_dev->max_mtu = ETH_MAX_MTU; in bond_setup()
4713 bond_dev->netdev_ops = &bond_netdev_ops; in bond_setup()
4714 bond_dev->ethtool_ops = &bond_ethtool_ops; in bond_setup()
4716 bond_dev->needs_free_netdev = true; in bond_setup()
4717 bond_dev->priv_destructor = bond_destructor; in bond_setup()
4722 bond_dev->flags |= IFF_MASTER; in bond_setup()
4723 bond_dev->priv_flags |= IFF_BONDING | IFF_UNICAST_FLT | IFF_NO_QUEUE; in bond_setup()
4724 bond_dev->priv_flags &= ~(IFF_XMIT_DST_RELEASE | IFF_TX_SKB_SHARING); in bond_setup()
4727 /* set up xfrm device ops (only supported in active-backup right now) */ in bond_setup()
4728 bond_dev->xfrmdev_ops = &bond_xfrmdev_ops; in bond_setup()
4729 bond->xs = NULL; in bond_setup()
4733 bond_dev->features |= NETIF_F_LLTX; in bond_setup()
4743 bond_dev->features |= NETIF_F_NETNS_LOCAL; in bond_setup()
4745 bond_dev->hw_features = BOND_VLAN_FEATURES | in bond_setup()
4749 bond_dev->hw_features |= NETIF_F_GSO_ENCAP_ALL | NETIF_F_GSO_UDP_L4; in bond_setup()
4751 bond_dev->hw_features |= BOND_XFRM_FEATURES; in bond_setup()
4753 bond_dev->features |= bond_dev->hw_features; in bond_setup()
4754 bond_dev->features |= NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX; in bond_setup()
4756 /* Disable XFRM features if this isn't an active-backup config */ in bond_setup()
4758 bond_dev->features &= ~BOND_XFRM_FEATURES; in bond_setup()
4776 __bond_release_one(bond_dev, slave->dev, true, true); in bond_uninit()
4779 usable = rtnl_dereference(bond->usable_slaves); in bond_uninit()
4781 RCU_INIT_POINTER(bond->usable_slaves, NULL); in bond_uninit()
4785 all = rtnl_dereference(bond->all_slaves); in bond_uninit()
4787 RCU_INIT_POINTER(bond->all_slaves, NULL); in bond_uninit()
4791 list_del(&bond->bond_list); in bond_uninit()
4796 /*------------------------- Module initialization ---------------------------*/
4819 return -EINVAL; in bond_check_params()
4821 bond_mode = valptr->value; in bond_check_params()
4837 return -EINVAL; in bond_check_params()
4839 xmit_hashtype = valptr->value; in bond_check_params()
4854 return -EINVAL; in bond_check_params()
4856 lacp_fast = valptr->value; in bond_check_params()
4866 return -EINVAL; in bond_check_params()
4868 params->ad_select = valptr->value; in bond_check_params()
4872 params->ad_select = BOND_AD_STABLE; in bond_check_params()
4876 …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()
4882 pr_warn("Warning: miimon module parameter (%d), not in range 0-%d, so it was reset to 0\n", in bond_check_params()
4888 pr_warn("Warning: updelay module parameter (%d), not in range 0-%d, so it was reset to 0\n", in bond_check_params()
4894 pr_warn("Warning: downdelay module parameter (%d), not in range 0-%d, so it was reset to 0\n", in bond_check_params()
4906 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()
4983 pr_warn("Warning: arp_interval module parameter (%d), not in range 0-%d, so it was reset to 0\n", in bond_check_params()
4993 if (!in4_pton(arp_ip_target[i], -1, (u8 *)&ip, -1, NULL) || in bond_check_params()
4999 if (bond_get_targets_ip(arp_target, ip) == -1) in bond_check_params()
5017 return -EINVAL; in bond_check_params()
5026 return -EINVAL; in bond_check_params()
5028 arp_validate_value = valptr->value; in bond_check_params()
5042 arp_all_targets_value = valptr->value; in bond_check_params()
5047 pr_info("MII link monitoring set to %d ms\n", miimon); in bond_check_params()
5052 arp_interval, valptr->string, arp_ip_count); in bond_check_params()
5082 return -EINVAL; in bond_check_params()
5084 primary_reselect_value = valptr->value; in bond_check_params()
5096 return -EINVAL; in bond_check_params()
5098 fail_over_mac_value = valptr->value; in bond_check_params()
5100 pr_warn("Warning: fail_over_mac only affects active-backup mode\n"); in bond_check_params()
5111 return -EINVAL; in bond_check_params()
5113 ad_actor_sys_prio = valptr->value; in bond_check_params()
5119 return -EINVAL; in bond_check_params()
5121 ad_user_port_key = valptr->value; in bond_check_params()
5127 return -EINVAL; in bond_check_params()
5129 tlb_dynamic_lb = valptr->value; in bond_check_params()
5138 params->mode = bond_mode; in bond_check_params()
5139 params->xmit_policy = xmit_hashtype; in bond_check_params()
5140 params->miimon = miimon; in bond_check_params()
5141 params->num_peer_notif = num_peer_notif; in bond_check_params()
5142 params->arp_interval = arp_interval; in bond_check_params()
5143 params->arp_validate = arp_validate_value; in bond_check_params()
5144 params->arp_all_targets = arp_all_targets_value; in bond_check_params()
5145 params->updelay = updelay; in bond_check_params()
5146 params->downdelay = downdelay; in bond_check_params()
5147 params->peer_notif_delay = 0; in bond_check_params()
5148 params->use_carrier = use_carrier; in bond_check_params()
5149 params->lacp_fast = lacp_fast; in bond_check_params()
5150 params->primary[0] = 0; in bond_check_params()
5151 params->primary_reselect = primary_reselect_value; in bond_check_params()
5152 params->fail_over_mac = fail_over_mac_value; in bond_check_params()
5153 params->tx_queues = tx_queues; in bond_check_params()
5154 params->all_slaves_active = all_slaves_active; in bond_check_params()
5155 params->resend_igmp = resend_igmp; in bond_check_params()
5156 params->min_links = min_links; in bond_check_params()
5157 params->lp_interval = lp_interval; in bond_check_params()
5158 params->packets_per_slave = packets_per_slave; in bond_check_params()
5159 params->tlb_dynamic_lb = tlb_dynamic_lb; in bond_check_params()
5160 params->ad_actor_sys_prio = ad_actor_sys_prio; in bond_check_params()
5161 eth_zero_addr(params->ad_actor_system); in bond_check_params()
5162 params->ad_user_port_key = ad_user_port_key; in bond_check_params()
5164 params->reciprocal_packets_per_slave = in bond_check_params()
5170 params->reciprocal_packets_per_slave = in bond_check_params()
5175 strncpy(params->primary, primary, IFNAMSIZ); in bond_check_params()
5176 params->primary[IFNAMSIZ - 1] = 0; in bond_check_params()
5179 memcpy(params->arp_targets, arp_target, sizeof(arp_target)); in bond_check_params()
5192 bond->wq = alloc_ordered_workqueue(bond_dev->name, WQ_MEM_RECLAIM); in bond_init()
5193 if (!bond->wq) in bond_init()
5194 return -ENOMEM; in bond_init()
5196 spin_lock_init(&bond->stats_lock); in bond_init()
5199 list_add_tail(&bond->bond_list, &bn->dev_list); in bond_init()
5206 if (is_zero_ether_addr(bond_dev->dev_addr) && in bond_init()
5207 bond_dev->addr_assign_type == NET_ADDR_PERM) in bond_init()
5238 return -ENOMEM; in bond_create()
5247 bond_info->rx_hashtbl_used_head = RLB_NULL_INDEX; in bond_create()
5250 bond_dev->rtnl_link_ops = &bond_link_ops; in bond_create()
5272 bn->net = net; in bond_net_init()
5273 INIT_LIST_HEAD(&bn->dev_list); in bond_net_init()
5291 list_for_each_entry_safe(bond, tmp_bond, &bn->dev_list, bond_list) in bond_net_exit()
5292 unregister_netdevice_queue(bond->dev, &list); in bond_net_exit()