Lines Matching +full:assigned +full:- +full:addresses
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright(c) 1999 - 2004 Intel Corporation. All rights reserved.
37 u8 padding[ETH_ZLEN - ETH_HLEN];
77 entry->load_history = 1 + entry->tx_bytes / in tlb_init_table_entry()
79 entry->tx_bytes = 0; in tlb_init_table_entry()
82 entry->tx_slave = NULL; in tlb_init_table_entry()
83 entry->next = TLB_NULL_INDEX; in tlb_init_table_entry()
84 entry->prev = TLB_NULL_INDEX; in tlb_init_table_entry()
119 spin_lock_bh(&bond->mode_lock); in tlb_clear_slave()
121 spin_unlock_bh(&bond->mode_lock); in tlb_clear_slave()
134 return -ENOMEM; in tlb_initialize()
136 spin_lock_bh(&bond->mode_lock); in tlb_initialize()
138 bond_info->tx_hashtbl = new_hashtbl; in tlb_initialize()
141 tlb_init_table_entry(&bond_info->tx_hashtbl[i], 0); in tlb_initialize()
143 spin_unlock_bh(&bond->mode_lock); in tlb_initialize()
153 spin_lock_bh(&bond->mode_lock); in tlb_deinitialize()
155 kfree(bond_info->tx_hashtbl); in tlb_deinitialize()
156 bond_info->tx_hashtbl = NULL; in tlb_deinitialize()
158 spin_unlock_bh(&bond->mode_lock); in tlb_deinitialize()
163 return (s64) (slave->speed << 20) - /* Convert to Megabit per sec */ in compute_gap()
198 hash_table = bond_info->tx_hashtbl; in __tlb_choose_channel()
206 u32 next_index = slave_info->head; in __tlb_choose_channel()
215 slave_info->head = hash_index; in __tlb_choose_channel()
216 slave_info->load += in __tlb_choose_channel()
236 spin_lock(&bond->mode_lock); in tlb_choose_channel()
238 spin_unlock(&bond->mode_lock); in tlb_choose_channel()
254 spin_lock_bh(&bond->mode_lock); in rlb_update_entry_from_arp()
256 hash_index = _simple_hash((u8 *)&(arp->ip_src), sizeof(arp->ip_src)); in rlb_update_entry_from_arp()
257 client_info = &(bond_info->rx_hashtbl[hash_index]); in rlb_update_entry_from_arp()
259 if ((client_info->assigned) && in rlb_update_entry_from_arp()
260 (client_info->ip_src == arp->ip_dst) && in rlb_update_entry_from_arp()
261 (client_info->ip_dst == arp->ip_src) && in rlb_update_entry_from_arp()
262 (!ether_addr_equal_64bits(client_info->mac_dst, arp->mac_src))) { in rlb_update_entry_from_arp()
264 ether_addr_copy(client_info->mac_dst, arp->mac_src); in rlb_update_entry_from_arp()
265 client_info->ntt = 1; in rlb_update_entry_from_arp()
266 bond_info->rx_ntt = 1; in rlb_update_entry_from_arp()
269 spin_unlock_bh(&bond->mode_lock); in rlb_update_entry_from_arp()
277 if (skb->protocol != cpu_to_be16(ETH_P_ARP)) in rlb_arp_recv()
284 /* We received an ARP from arp->ip_src. in rlb_arp_recv()
287 * However, if arp->mac_src is different than what is stored in in rlb_arp_recv()
296 if (arp->op_code == htons(ARPOP_REPLY)) { in rlb_arp_recv()
299 slave_dbg(bond->dev, slave->dev, "Server received an ARP Reply from client\n"); in rlb_arp_recv()
317 if (!before || before->speed < slave->speed) in __rlb_next_rx_slave()
320 if (!rx_slave || rx_slave->speed < slave->speed) in __rlb_next_rx_slave()
323 if (slave == bond_info->rx_slave) in __rlb_next_rx_slave()
329 if (!rx_slave || (before && rx_slave->speed < before->speed)) in __rlb_next_rx_slave()
333 bond_info->rx_slave = rx_slave; in __rlb_next_rx_slave()
360 struct slave *curr_active = rtnl_dereference(bond->curr_active_slave); in rlb_teach_disabled_mac_on_primary()
365 if (!bond->alb_info.primary_is_promisc) { in rlb_teach_disabled_mac_on_primary()
366 if (!dev_set_promiscuity(curr_active->dev, 1)) in rlb_teach_disabled_mac_on_primary()
367 bond->alb_info.primary_is_promisc = 1; in rlb_teach_disabled_mac_on_primary()
369 bond->alb_info.primary_is_promisc = 0; in rlb_teach_disabled_mac_on_primary()
372 bond->alb_info.rlb_promisc_timeout_counter = 0; in rlb_teach_disabled_mac_on_primary()
388 spin_lock_bh(&bond->mode_lock); in rlb_clear_slave()
390 rx_hash_table = bond_info->rx_hashtbl; in rlb_clear_slave()
391 index = bond_info->rx_hashtbl_used_head; in rlb_clear_slave()
400 bond_info->rx_hashtbl[index].ntt = 1; in rlb_clear_slave()
401 bond_info->rx_ntt = 1; in rlb_clear_slave()
409 bond_info->rlb_update_retry_counter = in rlb_clear_slave()
418 spin_unlock_bh(&bond->mode_lock); in rlb_clear_slave()
420 if (slave != rtnl_dereference(bond->curr_active_slave)) in rlb_clear_slave()
421 rlb_teach_disabled_mac_on_primary(bond, slave->dev->dev_addr); in rlb_clear_slave()
428 if (!client_info->slave || !is_valid_ether_addr(client_info->mac_dst)) in rlb_update_client()
435 client_info->ip_dst, in rlb_update_client()
436 client_info->slave->dev, in rlb_update_client()
437 client_info->ip_src, in rlb_update_client()
438 client_info->mac_dst, in rlb_update_client()
439 client_info->slave->dev->dev_addr, in rlb_update_client()
440 client_info->mac_dst); in rlb_update_client()
442 slave_err(client_info->slave->bond->dev, in rlb_update_client()
443 client_info->slave->dev, in rlb_update_client()
448 skb->dev = client_info->slave->dev; in rlb_update_client()
450 if (client_info->vlan_id) { in rlb_update_client()
452 client_info->vlan_id); in rlb_update_client()
466 spin_lock_bh(&bond->mode_lock); in rlb_update_rx_clients()
468 hash_index = bond_info->rx_hashtbl_used_head; in rlb_update_rx_clients()
470 hash_index = client_info->used_next) { in rlb_update_rx_clients()
471 client_info = &(bond_info->rx_hashtbl[hash_index]); in rlb_update_rx_clients()
472 if (client_info->ntt) { in rlb_update_rx_clients()
474 if (bond_info->rlb_update_retry_counter == 0) in rlb_update_rx_clients()
475 client_info->ntt = 0; in rlb_update_rx_clients()
482 bond_info->rlb_update_delay_counter = RLB_UPDATE_DELAY; in rlb_update_rx_clients()
484 spin_unlock_bh(&bond->mode_lock); in rlb_update_rx_clients()
487 /* The slave was assigned a new mac address - update the clients */
495 spin_lock_bh(&bond->mode_lock); in rlb_req_update_slave_clients()
497 hash_index = bond_info->rx_hashtbl_used_head; in rlb_req_update_slave_clients()
499 hash_index = client_info->used_next) { in rlb_req_update_slave_clients()
500 client_info = &(bond_info->rx_hashtbl[hash_index]); in rlb_req_update_slave_clients()
502 if ((client_info->slave == slave) && in rlb_req_update_slave_clients()
503 is_valid_ether_addr(client_info->mac_dst)) { in rlb_req_update_slave_clients()
504 client_info->ntt = 1; in rlb_req_update_slave_clients()
511 bond_info->rx_ntt = 1; in rlb_req_update_slave_clients()
513 bond_info->rlb_update_retry_counter = RLB_UPDATE_RETRY; in rlb_req_update_slave_clients()
516 spin_unlock_bh(&bond->mode_lock); in rlb_req_update_slave_clients()
526 spin_lock(&bond->mode_lock); in rlb_req_update_subnet_clients()
528 hash_index = bond_info->rx_hashtbl_used_head; in rlb_req_update_subnet_clients()
530 hash_index = client_info->used_next) { in rlb_req_update_subnet_clients()
531 client_info = &(bond_info->rx_hashtbl[hash_index]); in rlb_req_update_subnet_clients()
533 if (!client_info->slave) { in rlb_req_update_subnet_clients()
534 netdev_err(bond->dev, "found a client with no channel in the client's hash table\n"); in rlb_req_update_subnet_clients()
537 /* update all clients using this src_ip, that are not assigned in rlb_req_update_subnet_clients()
541 if ((client_info->ip_src == src_ip) && in rlb_req_update_subnet_clients()
542 !ether_addr_equal_64bits(client_info->slave->dev->dev_addr, in rlb_req_update_subnet_clients()
543 bond->dev->dev_addr) && in rlb_req_update_subnet_clients()
544 is_valid_ether_addr(client_info->mac_dst)) { in rlb_req_update_subnet_clients()
545 client_info->ntt = 1; in rlb_req_update_subnet_clients()
546 bond_info->rx_ntt = 1; in rlb_req_update_subnet_clients()
550 spin_unlock(&bond->mode_lock); in rlb_req_update_subnet_clients()
562 spin_lock(&bond->mode_lock); in rlb_choose_channel()
564 curr_active_slave = rcu_dereference(bond->curr_active_slave); in rlb_choose_channel()
566 hash_index = _simple_hash((u8 *)&arp->ip_dst, sizeof(arp->ip_dst)); in rlb_choose_channel()
567 client_info = &(bond_info->rx_hashtbl[hash_index]); in rlb_choose_channel()
569 if (client_info->assigned) { in rlb_choose_channel()
570 if ((client_info->ip_src == arp->ip_src) && in rlb_choose_channel()
571 (client_info->ip_dst == arp->ip_dst)) { in rlb_choose_channel()
572 /* the entry is already assigned to this client */ in rlb_choose_channel()
573 if (!is_broadcast_ether_addr(arp->mac_dst)) { in rlb_choose_channel()
575 ether_addr_copy(client_info->mac_dst, arp->mac_dst); in rlb_choose_channel()
577 ether_addr_copy(client_info->mac_src, arp->mac_src); in rlb_choose_channel()
579 assigned_slave = client_info->slave; in rlb_choose_channel()
581 spin_unlock(&bond->mode_lock); in rlb_choose_channel()
585 /* the entry is already assigned to some other client, in rlb_choose_channel()
587 * that the new client can be assigned to this entry. in rlb_choose_channel()
590 client_info->slave != curr_active_slave) { in rlb_choose_channel()
591 client_info->slave = curr_active_slave; in rlb_choose_channel()
600 if (!(client_info->assigned && in rlb_choose_channel()
601 client_info->ip_src == arp->ip_src)) { in rlb_choose_channel()
605 u32 hash_src = _simple_hash((u8 *)&arp->ip_src, in rlb_choose_channel()
606 sizeof(arp->ip_src)); in rlb_choose_channel()
611 client_info->ip_src = arp->ip_src; in rlb_choose_channel()
612 client_info->ip_dst = arp->ip_dst; in rlb_choose_channel()
613 /* arp->mac_dst is broadcast for arp requests. in rlb_choose_channel()
617 ether_addr_copy(client_info->mac_dst, arp->mac_dst); in rlb_choose_channel()
618 ether_addr_copy(client_info->mac_src, arp->mac_src); in rlb_choose_channel()
619 client_info->slave = assigned_slave; in rlb_choose_channel()
621 if (is_valid_ether_addr(client_info->mac_dst)) { in rlb_choose_channel()
622 client_info->ntt = 1; in rlb_choose_channel()
623 bond->alb_info.rx_ntt = 1; in rlb_choose_channel()
625 client_info->ntt = 0; in rlb_choose_channel()
628 if (vlan_get_tag(skb, &client_info->vlan_id)) in rlb_choose_channel()
629 client_info->vlan_id = 0; in rlb_choose_channel()
631 if (!client_info->assigned) { in rlb_choose_channel()
632 u32 prev_tbl_head = bond_info->rx_hashtbl_used_head; in rlb_choose_channel()
634 bond_info->rx_hashtbl_used_head = hash_index; in rlb_choose_channel()
635 client_info->used_next = prev_tbl_head; in rlb_choose_channel()
637 bond_info->rx_hashtbl[prev_tbl_head].used_prev = in rlb_choose_channel()
640 client_info->assigned = 1; in rlb_choose_channel()
644 spin_unlock(&bond->mode_lock); in rlb_choose_channel()
666 if (!bond_slave_has_mac_rcu(bond, arp->mac_src)) in rlb_arp_xmit()
669 dev = ip_dev_find(dev_net(bond->dev), arp->ip_src); in rlb_arp_xmit()
678 if (arp->op_code == htons(ARPOP_REPLY)) { in rlb_arp_xmit()
682 bond_hw_addr_copy(arp->mac_src, tx_slave->dev->dev_addr, in rlb_arp_xmit()
683 tx_slave->dev->addr_len); in rlb_arp_xmit()
684 netdev_dbg(bond->dev, "(slave %s): Server sent ARP Reply packet\n", in rlb_arp_xmit()
685 tx_slave ? tx_slave->dev->name : "NULL"); in rlb_arp_xmit()
686 } else if (arp->op_code == htons(ARPOP_REQUEST)) { in rlb_arp_xmit()
697 bond->alb_info.rlb_update_delay_counter = RLB_UPDATE_DELAY; in rlb_arp_xmit()
702 * updated with their assigned mac. in rlb_arp_xmit()
704 rlb_req_update_subnet_clients(bond, arp->ip_src); in rlb_arp_xmit()
705 netdev_dbg(bond->dev, "(slave %s): Server sent ARP Request packet\n", in rlb_arp_xmit()
706 tx_slave ? tx_slave->dev->name : "NULL"); in rlb_arp_xmit()
720 spin_lock_bh(&bond->mode_lock); in rlb_rebalance()
723 hash_index = bond_info->rx_hashtbl_used_head; in rlb_rebalance()
725 hash_index = client_info->used_next) { in rlb_rebalance()
726 client_info = &(bond_info->rx_hashtbl[hash_index]); in rlb_rebalance()
728 if (assigned_slave && (client_info->slave != assigned_slave)) { in rlb_rebalance()
729 client_info->slave = assigned_slave; in rlb_rebalance()
730 if (!is_zero_ether_addr(client_info->mac_dst)) { in rlb_rebalance()
731 client_info->ntt = 1; in rlb_rebalance()
739 bond_info->rx_ntt = 1; in rlb_rebalance()
740 spin_unlock_bh(&bond->mode_lock); in rlb_rebalance()
746 entry->used_next = RLB_NULL_INDEX; in rlb_init_table_entry_dst()
747 entry->used_prev = RLB_NULL_INDEX; in rlb_init_table_entry_dst()
748 entry->assigned = 0; in rlb_init_table_entry_dst()
749 entry->slave = NULL; in rlb_init_table_entry_dst()
750 entry->vlan_id = 0; in rlb_init_table_entry_dst()
754 entry->src_first = RLB_NULL_INDEX; in rlb_init_table_entry_src()
755 entry->src_prev = RLB_NULL_INDEX; in rlb_init_table_entry_src()
756 entry->src_next = RLB_NULL_INDEX; in rlb_init_table_entry_src()
769 u32 next_index = bond_info->rx_hashtbl[index].used_next; in rlb_delete_table_entry_dst()
770 u32 prev_index = bond_info->rx_hashtbl[index].used_prev; in rlb_delete_table_entry_dst()
772 if (index == bond_info->rx_hashtbl_used_head) in rlb_delete_table_entry_dst()
773 bond_info->rx_hashtbl_used_head = next_index; in rlb_delete_table_entry_dst()
775 bond_info->rx_hashtbl[prev_index].used_next = next_index; in rlb_delete_table_entry_dst()
777 bond_info->rx_hashtbl[next_index].used_prev = prev_index; in rlb_delete_table_entry_dst()
784 u32 next_index = bond_info->rx_hashtbl[index].src_next; in rlb_src_unlink()
785 u32 prev_index = bond_info->rx_hashtbl[index].src_prev; in rlb_src_unlink()
787 bond_info->rx_hashtbl[index].src_next = RLB_NULL_INDEX; in rlb_src_unlink()
788 bond_info->rx_hashtbl[index].src_prev = RLB_NULL_INDEX; in rlb_src_unlink()
791 bond_info->rx_hashtbl[next_index].src_prev = prev_index; in rlb_src_unlink()
797 if (bond_info->rx_hashtbl[prev_index].src_first == index) in rlb_src_unlink()
798 bond_info->rx_hashtbl[prev_index].src_first = next_index; in rlb_src_unlink()
800 bond_info->rx_hashtbl[prev_index].src_next = next_index; in rlb_src_unlink()
807 struct rlb_client_info *entry = &(bond_info->rx_hashtbl[index]); in rlb_delete_table_entry()
823 bond_info->rx_hashtbl[ip_dst_hash].src_prev = ip_src_hash; in rlb_src_link()
824 next = bond_info->rx_hashtbl[ip_src_hash].src_first; in rlb_src_link()
825 bond_info->rx_hashtbl[ip_dst_hash].src_next = next; in rlb_src_link()
827 bond_info->rx_hashtbl[next].src_prev = ip_dst_hash; in rlb_src_link()
828 bond_info->rx_hashtbl[ip_src_hash].src_first = ip_dst_hash; in rlb_src_link()
831 /* deletes all rx_hashtbl entries with arp->ip_src if their mac_src does
832 * not match arp->mac_src
837 u32 ip_src_hash = _simple_hash((u8 *)&(arp->ip_src), sizeof(arp->ip_src)); in rlb_purge_src_ip()
840 spin_lock_bh(&bond->mode_lock); in rlb_purge_src_ip()
842 index = bond_info->rx_hashtbl[ip_src_hash].src_first; in rlb_purge_src_ip()
844 struct rlb_client_info *entry = &(bond_info->rx_hashtbl[index]); in rlb_purge_src_ip()
845 u32 next_index = entry->src_next; in rlb_purge_src_ip()
847 if (entry->ip_src == arp->ip_src && in rlb_purge_src_ip()
848 !ether_addr_equal_64bits(arp->mac_src, entry->mac_src)) in rlb_purge_src_ip()
852 spin_unlock_bh(&bond->mode_lock); in rlb_purge_src_ip()
864 return -1; in rlb_initialize()
866 spin_lock_bh(&bond->mode_lock); in rlb_initialize()
868 bond_info->rx_hashtbl = new_hashtbl; in rlb_initialize()
870 bond_info->rx_hashtbl_used_head = RLB_NULL_INDEX; in rlb_initialize()
873 rlb_init_table_entry(bond_info->rx_hashtbl + i); in rlb_initialize()
875 spin_unlock_bh(&bond->mode_lock); in rlb_initialize()
878 bond->recv_probe = rlb_arp_recv; in rlb_initialize()
887 spin_lock_bh(&bond->mode_lock); in rlb_deinitialize()
889 kfree(bond_info->rx_hashtbl); in rlb_deinitialize()
890 bond_info->rx_hashtbl = NULL; in rlb_deinitialize()
891 bond_info->rx_hashtbl_used_head = RLB_NULL_INDEX; in rlb_deinitialize()
893 spin_unlock_bh(&bond->mode_lock); in rlb_deinitialize()
901 spin_lock_bh(&bond->mode_lock); in rlb_clear_vlan()
903 curr_index = bond_info->rx_hashtbl_used_head; in rlb_clear_vlan()
905 struct rlb_client_info *curr = &(bond_info->rx_hashtbl[curr_index]); in rlb_clear_vlan()
906 u32 next_index = bond_info->rx_hashtbl[curr_index].used_next; in rlb_clear_vlan()
908 if (curr->vlan_id == vlan_id) in rlb_clear_vlan()
914 spin_unlock_bh(&bond->mode_lock); in rlb_clear_vlan()
938 skb->network_header = skb->mac_header + ETH_HLEN; in alb_send_lp_vid()
939 skb->protocol = pkt.type; in alb_send_lp_vid()
940 skb->priority = TC_PRIO_CONTROL; in alb_send_lp_vid()
941 skb->dev = slave->dev; in alb_send_lp_vid()
943 slave_dbg(slave->bond->dev, slave->dev, in alb_send_lp_vid()
962 struct alb_walk_data *data = (struct alb_walk_data *)priv->data; in alb_upper_dev_walk()
963 bool strict_match = data->strict_match; in alb_upper_dev_walk()
964 const u8 *mac_addr = data->mac_addr; in alb_upper_dev_walk()
965 struct bonding *bond = data->bond; in alb_upper_dev_walk()
966 struct slave *slave = data->slave; in alb_upper_dev_walk()
970 bond->dev->lower_level == upper->lower_level - 1) { in alb_upper_dev_walk()
971 if (upper->addr_assign_type == NET_ADDR_STOLEN) { in alb_upper_dev_walk()
976 alb_send_lp_vid(slave, upper->dev_addr, in alb_upper_dev_walk()
986 tags = bond_verify_device_path(bond->dev, upper, 0); in alb_upper_dev_walk()
988 return -ENOMEM; in alb_upper_dev_walk()
990 alb_send_lp_vid(slave, upper->dev_addr, in alb_upper_dev_walk()
1018 netdev_walk_all_upper_dev_rcu(bond->dev, alb_upper_dev_walk, &priv); in alb_send_learning_packets()
1025 struct net_device *dev = slave->dev; in alb_set_slave_mac_addr()
1028 if (BOND_MODE(slave->bond) == BOND_MODE_TLB) { in alb_set_slave_mac_addr()
1033 /* for rlb each slave must have a unique hw mac addresses so that in alb_set_slave_mac_addr()
1037 ss.ss_family = dev->type; in alb_set_slave_mac_addr()
1039 …slave_err(slave->bond->dev, dev, "dev_set_mac_address on slave failed! ALB mode requires that the … in alb_set_slave_mac_addr()
1040 return -EOPNOTSUPP; in alb_set_slave_mac_addr()
1045 /* Swap MAC addresses between two slaves.
1053 bond_hw_addr_copy(tmp_mac_addr, slave1->dev->dev_addr, in alb_swap_mac_addr()
1054 slave1->dev->addr_len); in alb_swap_mac_addr()
1055 alb_set_slave_mac_addr(slave1, slave2->dev->dev_addr, in alb_swap_mac_addr()
1056 slave2->dev->addr_len); in alb_swap_mac_addr()
1058 slave1->dev->addr_len); in alb_swap_mac_addr()
1076 alb_send_learning_packets(slave1, slave1->dev->dev_addr, false); in alb_fasten_mac_swap()
1077 if (bond->alb_info.rlb_enabled) { in alb_fasten_mac_swap()
1088 alb_send_learning_packets(slave2, slave2->dev->dev_addr, false); in alb_fasten_mac_swap()
1089 if (bond->alb_info.rlb_enabled) { in alb_fasten_mac_swap()
1099 if (bond->alb_info.rlb_enabled && slaves_state_differ) { in alb_fasten_mac_swap()
1100 /* A disabled slave was assigned an active mac addr */ in alb_fasten_mac_swap()
1102 disabled_slave->dev->dev_addr); in alb_fasten_mac_swap()
1126 perm_curr_diff = !ether_addr_equal_64bits(slave->perm_hwaddr, in alb_change_hw_addr_on_detach()
1127 slave->dev->dev_addr); in alb_change_hw_addr_on_detach()
1128 perm_bond_diff = !ether_addr_equal_64bits(slave->perm_hwaddr, in alb_change_hw_addr_on_detach()
1129 bond->dev->dev_addr); in alb_change_hw_addr_on_detach()
1132 found_slave = bond_slave_has_mac(bond, slave->perm_hwaddr); in alb_change_hw_addr_on_detach()
1152 * addresses of the other slaves.
1165 struct slave *has_bond_addr = rcu_access_pointer(bond->curr_active_slave); in alb_handle_addr_collision_on_attach()
1178 if (!ether_addr_equal_64bits(slave->perm_hwaddr, bond->dev->dev_addr)) { in alb_handle_addr_collision_on_attach()
1179 if (!bond_slave_has_mac(bond, slave->dev->dev_addr)) in alb_handle_addr_collision_on_attach()
1182 /* Try setting slave mac to bond address and fall-through in alb_handle_addr_collision_on_attach()
1185 alb_set_slave_mac_addr(slave, bond->dev->dev_addr, in alb_handle_addr_collision_on_attach()
1186 bond->dev->addr_len); in alb_handle_addr_collision_on_attach()
1193 if (!bond_slave_has_mac(bond, tmp_slave1->perm_hwaddr)) { in alb_handle_addr_collision_on_attach()
1202 if (ether_addr_equal_64bits(tmp_slave1->dev->dev_addr, in alb_handle_addr_collision_on_attach()
1203 bond->dev->dev_addr)) { in alb_handle_addr_collision_on_attach()
1211 alb_set_slave_mac_addr(slave, free_mac_slave->perm_hwaddr, in alb_handle_addr_collision_on_attach()
1212 free_mac_slave->dev->addr_len); in alb_handle_addr_collision_on_attach()
1214 …slave_warn(bond->dev, slave->dev, "the slave hw address is in use by the bond; giving it the hw ad… in alb_handle_addr_collision_on_attach()
1215 free_mac_slave->dev->name); in alb_handle_addr_collision_on_attach()
1218 …slave_err(bond->dev, slave->dev, "the slave hw address is in use by the bond; couldn't find a slav… in alb_handle_addr_collision_on_attach()
1219 return -EFAULT; in alb_handle_addr_collision_on_attach()
1231 * their dev_addr field to different addresses (based on their permanent hw
1232 * addresses).
1247 if (bond->alb_info.rlb_enabled) in alb_set_mac_address()
1252 bond_hw_addr_copy(tmp_addr, slave->dev->dev_addr, in alb_set_mac_address()
1253 slave->dev->addr_len); in alb_set_mac_address()
1255 res = dev_set_mac_address(slave->dev, addr, NULL); in alb_set_mac_address()
1258 dev_addr_set(slave->dev, tmp_addr); in alb_set_mac_address()
1267 memcpy(ss.__data, bond->dev->dev_addr, bond->dev->addr_len); in alb_set_mac_address()
1268 ss.ss_family = bond->dev->type; in alb_set_mac_address()
1274 bond_hw_addr_copy(tmp_addr, rollback_slave->dev->dev_addr, in alb_set_mac_address()
1275 rollback_slave->dev->addr_len); in alb_set_mac_address()
1276 dev_set_mac_address(rollback_slave->dev, in alb_set_mac_address()
1278 dev_addr_set(rollback_slave->dev, tmp_addr); in alb_set_mac_address()
1294 if (ip6hdr->nexthdr != IPPROTO_ICMPV6) in alb_determine_nd()
1301 return hdr->icmp6_type == NDISC_NEIGHBOUR_ADVERTISEMENT || in alb_determine_nd()
1302 hdr->icmp6_type == NDISC_NEIGHBOUR_SOLICITATION; in alb_determine_nd()
1321 bond->alb_info.rlb_enabled = 1; in bond_alb_initialize()
1323 bond->alb_info.rlb_enabled = 0; in bond_alb_initialize()
1335 if (bond_info->rlb_enabled) in bond_alb_deinitialize()
1347 tx_slave = rcu_dereference(bond->curr_active_slave); in bond_do_alb_xmit()
1348 if (bond->params.tlb_dynamic_lb) in bond_do_alb_xmit()
1349 bond_info->unbalanced_load += skb->len; in bond_do_alb_xmit()
1353 if (tx_slave != rcu_access_pointer(bond->curr_active_slave)) { in bond_do_alb_xmit()
1354 ether_addr_copy(eth_data->h_source, in bond_do_alb_xmit()
1355 tx_slave->dev->dev_addr); in bond_do_alb_xmit()
1358 return bond_dev_queue_xmit(bond, skb, tx_slave->dev); in bond_do_alb_xmit()
1361 if (tx_slave && bond->params.tlb_dynamic_lb) { in bond_do_alb_xmit()
1362 spin_lock(&bond->mode_lock); in bond_do_alb_xmit()
1364 spin_unlock(&bond->mode_lock); in bond_do_alb_xmit()
1368 return bond_tx_drop(bond->dev, skb); in bond_do_alb_xmit()
1382 if (!is_multicast_ether_addr(eth_data->h_dest)) { in bond_xmit_tlb_slave_get()
1383 switch (skb->protocol) { in bond_xmit_tlb_slave_get()
1390 if (bond->params.tlb_dynamic_lb) { in bond_xmit_tlb_slave_get()
1393 skb->len); in bond_xmit_tlb_slave_get()
1398 slaves = rcu_dereference(bond->usable_slaves); in bond_xmit_tlb_slave_get()
1399 count = slaves ? READ_ONCE(slaves->count) : 0; in bond_xmit_tlb_slave_get()
1401 tx_slave = slaves->arr[hash_index % in bond_xmit_tlb_slave_get()
1434 switch (ntohs(skb->protocol)) { in bond_xmit_alb_slave_get()
1438 if (is_broadcast_ether_addr(eth_data->h_dest) || in bond_xmit_alb_slave_get()
1444 if (iph->daddr == ip_bcast || iph->protocol == IPPROTO_IGMP) { in bond_xmit_alb_slave_get()
1448 hash_start = (char *)&(iph->daddr); in bond_xmit_alb_slave_get()
1449 hash_size = sizeof(iph->daddr); in bond_xmit_alb_slave_get()
1458 if (is_broadcast_ether_addr(eth_data->h_dest)) { in bond_xmit_alb_slave_get()
1463 /* IPv6 uses all-nodes multicast as an equivalent to in bond_xmit_alb_slave_get()
1466 if (ether_addr_equal_64bits(eth_data->h_dest, mac_v6_allmcast)) { in bond_xmit_alb_slave_get()
1477 /* Additionally, DAD probes should not be tx-balanced as that in bond_xmit_alb_slave_get()
1478 * will lead to false positives for duplicate addresses and in bond_xmit_alb_slave_get()
1482 if (ipv6_addr_any(&ip6hdr->saddr)) { in bond_xmit_alb_slave_get()
1487 hash_start = (char *)&ip6hdr->daddr; in bond_xmit_alb_slave_get()
1488 hash_size = sizeof(ip6hdr->daddr); in bond_xmit_alb_slave_get()
1493 if (bond_info->rlb_enabled) in bond_xmit_alb_slave_get()
1502 if (bond->params.tlb_dynamic_lb) { in bond_xmit_alb_slave_get()
1504 tx_slave = tlb_choose_channel(bond, hash_index, skb->len); in bond_xmit_alb_slave_get()
1514 slaves = rcu_dereference(bond->usable_slaves); in bond_xmit_alb_slave_get()
1515 count = slaves ? READ_ONCE(slaves->count) : 0; in bond_xmit_alb_slave_get()
1517 tx_slave = slaves->arr[bond_xmit_hash(bond, skb) % in bond_xmit_alb_slave_get()
1542 atomic_set(&bond_info->tx_rebalance_counter, 0); in bond_alb_monitor()
1543 bond_info->lp_counter = 0; in bond_alb_monitor()
1549 atomic_inc(&bond_info->tx_rebalance_counter); in bond_alb_monitor()
1550 bond_info->lp_counter++; in bond_alb_monitor()
1553 if (bond_info->lp_counter >= BOND_ALB_LP_TICKS(bond)) { in bond_alb_monitor()
1558 * user mac addresses (!strict_match). Otherwise, only in bond_alb_monitor()
1562 strict_match = (slave != rcu_access_pointer(bond->curr_active_slave) || in bond_alb_monitor()
1563 bond_info->rlb_enabled); in bond_alb_monitor()
1564 alb_send_learning_packets(slave, slave->dev->dev_addr, in bond_alb_monitor()
1567 bond_info->lp_counter = 0; in bond_alb_monitor()
1571 if (atomic_read(&bond_info->tx_rebalance_counter) >= BOND_TLB_REBALANCE_TICKS) { in bond_alb_monitor()
1574 if (slave == rcu_access_pointer(bond->curr_active_slave)) { in bond_alb_monitor()
1576 bond_info->unbalanced_load / in bond_alb_monitor()
1578 bond_info->unbalanced_load = 0; in bond_alb_monitor()
1581 atomic_set(&bond_info->tx_rebalance_counter, 0); in bond_alb_monitor()
1584 if (bond_info->rlb_enabled) { in bond_alb_monitor()
1585 if (bond_info->primary_is_promisc && in bond_alb_monitor()
1586 (++bond_info->rlb_promisc_timeout_counter >= RLB_PROMISC_TIMEOUT)) { in bond_alb_monitor()
1595 bond_info->rlb_promisc_timeout_counter = 0; in bond_alb_monitor()
1601 dev_set_promiscuity(rtnl_dereference(bond->curr_active_slave)->dev, in bond_alb_monitor()
1602 -1); in bond_alb_monitor()
1603 bond_info->primary_is_promisc = 0; in bond_alb_monitor()
1609 if (bond_info->rlb_rebalance) { in bond_alb_monitor()
1610 bond_info->rlb_rebalance = 0; in bond_alb_monitor()
1615 if (bond_info->rx_ntt) { in bond_alb_monitor()
1616 if (bond_info->rlb_update_delay_counter) { in bond_alb_monitor()
1617 --bond_info->rlb_update_delay_counter; in bond_alb_monitor()
1620 if (bond_info->rlb_update_retry_counter) in bond_alb_monitor()
1621 --bond_info->rlb_update_retry_counter; in bond_alb_monitor()
1623 bond_info->rx_ntt = 0; in bond_alb_monitor()
1629 queue_delayed_work(bond->wq, &bond->alb_work, alb_delta_in_ticks); in bond_alb_monitor()
1639 res = alb_set_slave_mac_addr(slave, slave->perm_hwaddr, in bond_alb_init_slave()
1640 slave->dev->addr_len); in bond_alb_init_slave()
1651 atomic_set(&bond->alb_info.tx_rebalance_counter, in bond_alb_init_slave()
1654 if (bond->alb_info.rlb_enabled) in bond_alb_init_slave()
1655 bond->alb_info.rlb_rebalance = 1; in bond_alb_init_slave()
1660 /* Remove slave from tlb and rlb hash tables, and fix up MAC addresses
1672 if (bond->alb_info.rlb_enabled) { in bond_alb_deinit_slave()
1673 bond->alb_info.rx_slave = NULL; in bond_alb_deinit_slave()
1685 if (bond->alb_info.rlb_enabled) in bond_alb_handle_link_change()
1689 atomic_set(&bond_info->tx_rebalance_counter, in bond_alb_handle_link_change()
1691 if (bond->alb_info.rlb_enabled) { in bond_alb_handle_link_change()
1692 bond->alb_info.rlb_rebalance = 1; in bond_alb_handle_link_change()
1703 pr_err("Failed to build slave-array for TLB mode.\n"); in bond_alb_handle_link_change()
1708 * bond_alb_handle_active_change - assign new curr_active_slave
1712 * Set the bond->curr_active_slave to @new_slave and handle
1722 curr_active = rtnl_dereference(bond->curr_active_slave); in bond_alb_handle_active_change()
1726 if (curr_active && bond->alb_info.primary_is_promisc) { in bond_alb_handle_active_change()
1727 dev_set_promiscuity(curr_active->dev, -1); in bond_alb_handle_active_change()
1728 bond->alb_info.primary_is_promisc = 0; in bond_alb_handle_active_change()
1729 bond->alb_info.rlb_promisc_timeout_counter = 0; in bond_alb_handle_active_change()
1733 rcu_assign_pointer(bond->curr_active_slave, new_slave); in bond_alb_handle_active_change()
1739 * i.e. swap mac addresses of old curr_active_slave and new curr_active_slave in bond_alb_handle_active_change()
1742 swap_slave = bond_slave_has_mac(bond, bond->dev->dev_addr); in bond_alb_handle_active_change()
1745 * ignored so we can mess with their MAC addresses without in bond_alb_handle_active_change()
1753 * and thus filter bond->dev_addr's packets, so force bond's mac in bond_alb_handle_active_change()
1759 bond_hw_addr_copy(tmp_addr, new_slave->dev->dev_addr, in bond_alb_handle_active_change()
1760 new_slave->dev->addr_len); in bond_alb_handle_active_change()
1762 bond_hw_addr_copy(ss.__data, bond->dev->dev_addr, in bond_alb_handle_active_change()
1763 bond->dev->addr_len); in bond_alb_handle_active_change()
1764 ss.ss_family = bond->dev->type; in bond_alb_handle_active_change()
1766 dev_set_mac_address(new_slave->dev, (struct sockaddr *)&ss, in bond_alb_handle_active_change()
1769 dev_addr_set(new_slave->dev, tmp_addr); in bond_alb_handle_active_change()
1779 alb_set_slave_mac_addr(new_slave, bond->dev->dev_addr, in bond_alb_handle_active_change()
1780 bond->dev->addr_len); in bond_alb_handle_active_change()
1781 alb_send_learning_packets(new_slave, bond->dev->dev_addr, in bond_alb_handle_active_change()
1795 if (!is_valid_ether_addr(ss->__data)) in bond_alb_set_mac_address()
1796 return -EADDRNOTAVAIL; in bond_alb_set_mac_address()
1802 dev_addr_set(bond_dev, ss->__data); in bond_alb_set_mac_address()
1808 curr_active = rtnl_dereference(bond->curr_active_slave); in bond_alb_set_mac_address()
1812 swap_slave = bond_slave_has_mac(bond, bond_dev->dev_addr); in bond_alb_set_mac_address()
1818 alb_set_slave_mac_addr(curr_active, bond_dev->dev_addr, in bond_alb_set_mac_address()
1819 bond_dev->addr_len); in bond_alb_set_mac_address()
1822 bond_dev->dev_addr, false); in bond_alb_set_mac_address()
1823 if (bond->alb_info.rlb_enabled) { in bond_alb_set_mac_address()
1834 if (bond->alb_info.rlb_enabled) in bond_alb_clear_vlan()