2 * Copyright(c) 1999 - 2004 Intel Corporation. All rights reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 * The full GNU General Public License is included in this distribution in the
19 * file called LICENSE.
23 //#define BONDING_DEBUG 1
25 #include <linux/skbuff.h>
26 #include <linux/netdevice.h>
27 #include <linux/etherdevice.h>
28 #include <linux/pkt_sched.h>
29 #include <linux/spinlock.h>
30 #include <linux/slab.h>
31 #include <linux/timer.h>
33 #include <linux/ipv6.h>
34 #include <linux/if_arp.h>
35 #include <linux/if_ether.h>
36 #include <linux/if_bonding.h>
37 #include <linux/if_vlan.h>
42 #include <asm/byteorder.h>
47 #define ALB_TIMER_TICKS_PER_SEC 10 /* should be a divisor of HZ */
48 #define BOND_TLB_REBALANCE_INTERVAL 10 /* In seconds, periodic re-balancing.
49 * Used for division - never set
52 #define BOND_ALB_LP_INTERVAL 1 /* In seconds, periodic send of
53 * learning packets to the switch
56 #define BOND_TLB_REBALANCE_TICKS (BOND_TLB_REBALANCE_INTERVAL \
57 * ALB_TIMER_TICKS_PER_SEC)
59 #define BOND_ALB_LP_TICKS (BOND_ALB_LP_INTERVAL \
60 * ALB_TIMER_TICKS_PER_SEC)
62 #define TLB_HASH_TABLE_SIZE 256 /* The size of the clients hash table.
63 * Note that this value MUST NOT be smaller
64 * because the key hash table is BYTE wide !
68 #define TLB_NULL_INDEX 0xffffffff
69 #define MAX_LP_BURST 3
72 #define RLB_HASH_TABLE_SIZE 256
73 #define RLB_NULL_INDEX 0xffffffff
74 #define RLB_UPDATE_DELAY 2*ALB_TIMER_TICKS_PER_SEC /* 2 seconds */
75 #define RLB_ARP_BURST_SIZE 2
76 #define RLB_UPDATE_RETRY 3 /* 3-ticks - must be smaller than the rlb
77 * rebalance interval (5 min).
79 /* RLB_PROMISC_TIMEOUT = 10 sec equals the time that the current slave is
80 * promiscuous after failover
82 #define RLB_PROMISC_TIMEOUT 10*ALB_TIMER_TICKS_PER_SEC
84 static const u8 mac_bcast[ETH_ALEN] = {0xff,0xff,0xff,0xff,0xff,0xff};
85 static const u8 mac_v6_allmcast[ETH_ALEN] = {0x33,0x33,0x00,0x00,0x00,0x01};
86 static const int alb_delta_in_ticks = HZ / ALB_TIMER_TICKS_PER_SEC;
93 u8 padding[ETH_ZLEN - ETH_HLEN];
98 __be16 prot_addr_space;
102 u8 mac_src[ETH_ALEN]; /* sender hardware address */
103 __be32 ip_src; /* sender IP address */
104 u8 mac_dst[ETH_ALEN]; /* target hardware address */
105 __be32 ip_dst; /* target IP address */
109 static inline struct arp_pkt *arp_pkt(const struct sk_buff *skb)
111 return (struct arp_pkt *)skb_network_header(skb);
114 /* Forward declaration */
115 static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[]);
117 static inline u8 _simple_hash(const u8 *hash_start, int hash_size)
122 for (i = 0; i < hash_size; i++) {
123 hash ^= hash_start[i];
129 /*********************** tlb specific functions ***************************/
131 static inline void _lock_tx_hashtbl(struct bonding *bond)
133 spin_lock_bh(&(BOND_ALB_INFO(bond).tx_hashtbl_lock));
136 static inline void _unlock_tx_hashtbl(struct bonding *bond)
138 spin_unlock_bh(&(BOND_ALB_INFO(bond).tx_hashtbl_lock));
141 /* Caller must hold tx_hashtbl lock */
142 static inline void tlb_init_table_entry(struct tlb_client_info *entry, int save_load)
145 entry->load_history = 1 + entry->tx_bytes /
146 BOND_TLB_REBALANCE_INTERVAL;
150 entry->tx_slave = NULL;
151 entry->next = TLB_NULL_INDEX;
152 entry->prev = TLB_NULL_INDEX;
155 static inline void tlb_init_slave(struct slave *slave)
157 SLAVE_TLB_INFO(slave).load = 0;
158 SLAVE_TLB_INFO(slave).head = TLB_NULL_INDEX;
161 /* Caller must hold bond lock for read */
162 static void tlb_clear_slave(struct bonding *bond, struct slave *slave, int save_load)
164 struct tlb_client_info *tx_hash_table;
167 _lock_tx_hashtbl(bond);
169 /* clear slave from tx_hashtbl */
170 tx_hash_table = BOND_ALB_INFO(bond).tx_hashtbl;
172 index = SLAVE_TLB_INFO(slave).head;
173 while (index != TLB_NULL_INDEX) {
174 u32 next_index = tx_hash_table[index].next;
175 tlb_init_table_entry(&tx_hash_table[index], save_load);
179 tlb_init_slave(slave);
181 _unlock_tx_hashtbl(bond);
184 /* Must be called before starting the monitor timer */
185 static int tlb_initialize(struct bonding *bond)
187 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
188 int size = TLB_HASH_TABLE_SIZE * sizeof(struct tlb_client_info);
189 struct tlb_client_info *new_hashtbl;
192 spin_lock_init(&(bond_info->tx_hashtbl_lock));
194 new_hashtbl = kzalloc(size, GFP_KERNEL);
196 printk(KERN_ERR DRV_NAME
197 ": %s: Error: Failed to allocate TLB hash table\n",
201 _lock_tx_hashtbl(bond);
203 bond_info->tx_hashtbl = new_hashtbl;
205 for (i = 0; i < TLB_HASH_TABLE_SIZE; i++) {
206 tlb_init_table_entry(&bond_info->tx_hashtbl[i], 1);
209 _unlock_tx_hashtbl(bond);
214 /* Must be called only after all slaves have been released */
215 static void tlb_deinitialize(struct bonding *bond)
217 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
219 _lock_tx_hashtbl(bond);
221 kfree(bond_info->tx_hashtbl);
222 bond_info->tx_hashtbl = NULL;
224 _unlock_tx_hashtbl(bond);
227 /* Caller must hold bond lock for read */
228 static struct slave *tlb_get_least_loaded_slave(struct bonding *bond)
230 struct slave *slave, *least_loaded;
234 /* Find the first enabled slave */
235 bond_for_each_slave(bond, slave, i) {
236 if (SLAVE_IS_OK(slave)) {
246 least_loaded = slave;
247 max_gap = (s64)(slave->speed << 20) - /* Convert to Megabit per sec */
248 (s64)(SLAVE_TLB_INFO(slave).load << 3); /* Bytes to bits */
250 /* Find the slave with the largest gap */
251 bond_for_each_slave_from(bond, slave, i, least_loaded) {
252 if (SLAVE_IS_OK(slave)) {
253 s64 gap = (s64)(slave->speed << 20) -
254 (s64)(SLAVE_TLB_INFO(slave).load << 3);
256 least_loaded = slave;
265 /* Caller must hold bond lock for read */
266 static struct slave *tlb_choose_channel(struct bonding *bond, u32 hash_index, u32 skb_len)
268 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
269 struct tlb_client_info *hash_table;
270 struct slave *assigned_slave;
272 _lock_tx_hashtbl(bond);
274 hash_table = bond_info->tx_hashtbl;
275 assigned_slave = hash_table[hash_index].tx_slave;
276 if (!assigned_slave) {
277 assigned_slave = tlb_get_least_loaded_slave(bond);
279 if (assigned_slave) {
280 struct tlb_slave_info *slave_info =
281 &(SLAVE_TLB_INFO(assigned_slave));
282 u32 next_index = slave_info->head;
284 hash_table[hash_index].tx_slave = assigned_slave;
285 hash_table[hash_index].next = next_index;
286 hash_table[hash_index].prev = TLB_NULL_INDEX;
288 if (next_index != TLB_NULL_INDEX) {
289 hash_table[next_index].prev = hash_index;
292 slave_info->head = hash_index;
294 hash_table[hash_index].load_history;
298 if (assigned_slave) {
299 hash_table[hash_index].tx_bytes += skb_len;
302 _unlock_tx_hashtbl(bond);
304 return assigned_slave;
307 /*********************** rlb specific functions ***************************/
308 static inline void _lock_rx_hashtbl(struct bonding *bond)
310 spin_lock_bh(&(BOND_ALB_INFO(bond).rx_hashtbl_lock));
313 static inline void _unlock_rx_hashtbl(struct bonding *bond)
315 spin_unlock_bh(&(BOND_ALB_INFO(bond).rx_hashtbl_lock));
318 /* when an ARP REPLY is received from a client update its info
321 static void rlb_update_entry_from_arp(struct bonding *bond, struct arp_pkt *arp)
323 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
324 struct rlb_client_info *client_info;
327 _lock_rx_hashtbl(bond);
329 hash_index = _simple_hash((u8*)&(arp->ip_src), sizeof(arp->ip_src));
330 client_info = &(bond_info->rx_hashtbl[hash_index]);
332 if ((client_info->assigned) &&
333 (client_info->ip_src == arp->ip_dst) &&
334 (client_info->ip_dst == arp->ip_src)) {
335 /* update the clients MAC address */
336 memcpy(client_info->mac_dst, arp->mac_src, ETH_ALEN);
337 client_info->ntt = 1;
338 bond_info->rx_ntt = 1;
341 _unlock_rx_hashtbl(bond);
344 static int rlb_arp_recv(struct sk_buff *skb, struct net_device *bond_dev, struct packet_type *ptype, struct net_device *orig_dev)
346 struct bonding *bond = bond_dev->priv;
347 struct arp_pkt *arp = (struct arp_pkt *)skb->data;
348 int res = NET_RX_DROP;
350 if (dev_net(bond_dev) != &init_net)
353 if (!(bond_dev->flags & IFF_MASTER))
357 dprintk("Packet has no ARP data\n");
361 if (skb->len < sizeof(struct arp_pkt)) {
362 dprintk("Packet is too small to be an ARP\n");
366 if (arp->op_code == htons(ARPOP_REPLY)) {
367 /* update rx hash table for this ARP */
368 rlb_update_entry_from_arp(bond, arp);
369 dprintk("Server received an ARP Reply from client\n");
372 res = NET_RX_SUCCESS;
380 /* Caller must hold bond lock for read */
381 static struct slave *rlb_next_rx_slave(struct bonding *bond)
383 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
384 struct slave *rx_slave, *slave, *start_at;
387 if (bond_info->next_rx_slave) {
388 start_at = bond_info->next_rx_slave;
390 start_at = bond->first_slave;
395 bond_for_each_slave_from(bond, slave, i, start_at) {
396 if (SLAVE_IS_OK(slave)) {
399 } else if (slave->speed > rx_slave->speed) {
406 bond_info->next_rx_slave = rx_slave->next;
412 /* teach the switch the mac of a disabled slave
413 * on the primary for fault tolerance
415 * Caller must hold bond->curr_slave_lock for write or bond lock for write
417 static void rlb_teach_disabled_mac_on_primary(struct bonding *bond, u8 addr[])
419 if (!bond->curr_active_slave) {
423 if (!bond->alb_info.primary_is_promisc) {
424 if (!dev_set_promiscuity(bond->curr_active_slave->dev, 1))
425 bond->alb_info.primary_is_promisc = 1;
427 bond->alb_info.primary_is_promisc = 0;
430 bond->alb_info.rlb_promisc_timeout_counter = 0;
432 alb_send_learning_packets(bond->curr_active_slave, addr);
435 /* slave being removed should not be active at this point
437 * Caller must hold bond lock for read
439 static void rlb_clear_slave(struct bonding *bond, struct slave *slave)
441 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
442 struct rlb_client_info *rx_hash_table;
443 u32 index, next_index;
445 /* clear slave from rx_hashtbl */
446 _lock_rx_hashtbl(bond);
448 rx_hash_table = bond_info->rx_hashtbl;
449 index = bond_info->rx_hashtbl_head;
450 for (; index != RLB_NULL_INDEX; index = next_index) {
451 next_index = rx_hash_table[index].next;
452 if (rx_hash_table[index].slave == slave) {
453 struct slave *assigned_slave = rlb_next_rx_slave(bond);
455 if (assigned_slave) {
456 rx_hash_table[index].slave = assigned_slave;
457 if (memcmp(rx_hash_table[index].mac_dst,
458 mac_bcast, ETH_ALEN)) {
459 bond_info->rx_hashtbl[index].ntt = 1;
460 bond_info->rx_ntt = 1;
461 /* A slave has been removed from the
462 * table because it is either disabled
463 * or being released. We must retry the
464 * update to avoid clients from not
465 * being updated & disconnecting when
468 bond_info->rlb_update_retry_counter =
471 } else { /* there is no active slave */
472 rx_hash_table[index].slave = NULL;
477 _unlock_rx_hashtbl(bond);
479 write_lock_bh(&bond->curr_slave_lock);
481 if (slave != bond->curr_active_slave) {
482 rlb_teach_disabled_mac_on_primary(bond, slave->dev->dev_addr);
485 write_unlock_bh(&bond->curr_slave_lock);
488 static void rlb_update_client(struct rlb_client_info *client_info)
492 if (!client_info->slave) {
496 for (i = 0; i < RLB_ARP_BURST_SIZE; i++) {
499 skb = arp_create(ARPOP_REPLY, ETH_P_ARP,
501 client_info->slave->dev,
503 client_info->mac_dst,
504 client_info->slave->dev->dev_addr,
505 client_info->mac_dst);
507 printk(KERN_ERR DRV_NAME
508 ": %s: Error: failed to create an ARP packet\n",
509 client_info->slave->dev->master->name);
513 skb->dev = client_info->slave->dev;
515 if (client_info->tag) {
516 skb = vlan_put_tag(skb, client_info->vlan_id);
518 printk(KERN_ERR DRV_NAME
519 ": %s: Error: failed to insert VLAN tag\n",
520 client_info->slave->dev->master->name);
529 /* sends ARP REPLIES that update the clients that need updating */
530 static void rlb_update_rx_clients(struct bonding *bond)
532 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
533 struct rlb_client_info *client_info;
536 _lock_rx_hashtbl(bond);
538 hash_index = bond_info->rx_hashtbl_head;
539 for (; hash_index != RLB_NULL_INDEX; hash_index = client_info->next) {
540 client_info = &(bond_info->rx_hashtbl[hash_index]);
541 if (client_info->ntt) {
542 rlb_update_client(client_info);
543 if (bond_info->rlb_update_retry_counter == 0) {
544 client_info->ntt = 0;
549 /* do not update the entries again untill this counter is zero so that
550 * not to confuse the clients.
552 bond_info->rlb_update_delay_counter = RLB_UPDATE_DELAY;
554 _unlock_rx_hashtbl(bond);
557 /* The slave was assigned a new mac address - update the clients */
558 static void rlb_req_update_slave_clients(struct bonding *bond, struct slave *slave)
560 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
561 struct rlb_client_info *client_info;
565 _lock_rx_hashtbl(bond);
567 hash_index = bond_info->rx_hashtbl_head;
568 for (; hash_index != RLB_NULL_INDEX; hash_index = client_info->next) {
569 client_info = &(bond_info->rx_hashtbl[hash_index]);
571 if ((client_info->slave == slave) &&
572 memcmp(client_info->mac_dst, mac_bcast, ETH_ALEN)) {
573 client_info->ntt = 1;
578 // update the team's flag only after the whole iteration
580 bond_info->rx_ntt = 1;
582 bond_info->rlb_update_retry_counter = RLB_UPDATE_RETRY;
585 _unlock_rx_hashtbl(bond);
588 /* mark all clients using src_ip to be updated */
589 static void rlb_req_update_subnet_clients(struct bonding *bond, __be32 src_ip)
591 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
592 struct rlb_client_info *client_info;
595 _lock_rx_hashtbl(bond);
597 hash_index = bond_info->rx_hashtbl_head;
598 for (; hash_index != RLB_NULL_INDEX; hash_index = client_info->next) {
599 client_info = &(bond_info->rx_hashtbl[hash_index]);
601 if (!client_info->slave) {
602 printk(KERN_ERR DRV_NAME
603 ": %s: Error: found a client with no channel in "
604 "the client's hash table\n",
608 /*update all clients using this src_ip, that are not assigned
609 * to the team's address (curr_active_slave) and have a known
610 * unicast mac address.
612 if ((client_info->ip_src == src_ip) &&
613 memcmp(client_info->slave->dev->dev_addr,
614 bond->dev->dev_addr, ETH_ALEN) &&
615 memcmp(client_info->mac_dst, mac_bcast, ETH_ALEN)) {
616 client_info->ntt = 1;
617 bond_info->rx_ntt = 1;
621 _unlock_rx_hashtbl(bond);
624 /* Caller must hold both bond and ptr locks for read */
625 static struct slave *rlb_choose_channel(struct sk_buff *skb, struct bonding *bond)
627 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
628 struct arp_pkt *arp = arp_pkt(skb);
629 struct slave *assigned_slave;
630 struct rlb_client_info *client_info;
633 _lock_rx_hashtbl(bond);
635 hash_index = _simple_hash((u8 *)&arp->ip_dst, sizeof(arp->ip_src));
636 client_info = &(bond_info->rx_hashtbl[hash_index]);
638 if (client_info->assigned) {
639 if ((client_info->ip_src == arp->ip_src) &&
640 (client_info->ip_dst == arp->ip_dst)) {
641 /* the entry is already assigned to this client */
642 if (memcmp(arp->mac_dst, mac_bcast, ETH_ALEN)) {
643 /* update mac address from arp */
644 memcpy(client_info->mac_dst, arp->mac_dst, ETH_ALEN);
647 assigned_slave = client_info->slave;
648 if (assigned_slave) {
649 _unlock_rx_hashtbl(bond);
650 return assigned_slave;
653 /* the entry is already assigned to some other client,
654 * move the old client to primary (curr_active_slave) so
655 * that the new client can be assigned to this entry.
657 if (bond->curr_active_slave &&
658 client_info->slave != bond->curr_active_slave) {
659 client_info->slave = bond->curr_active_slave;
660 rlb_update_client(client_info);
664 /* assign a new slave */
665 assigned_slave = rlb_next_rx_slave(bond);
667 if (assigned_slave) {
668 client_info->ip_src = arp->ip_src;
669 client_info->ip_dst = arp->ip_dst;
670 /* arp->mac_dst is broadcast for arp reqeusts.
671 * will be updated with clients actual unicast mac address
672 * upon receiving an arp reply.
674 memcpy(client_info->mac_dst, arp->mac_dst, ETH_ALEN);
675 client_info->slave = assigned_slave;
677 if (memcmp(client_info->mac_dst, mac_bcast, ETH_ALEN)) {
678 client_info->ntt = 1;
679 bond->alb_info.rx_ntt = 1;
681 client_info->ntt = 0;
684 if (!list_empty(&bond->vlan_list)) {
685 if (!vlan_get_tag(skb, &client_info->vlan_id))
686 client_info->tag = 1;
689 if (!client_info->assigned) {
690 u32 prev_tbl_head = bond_info->rx_hashtbl_head;
691 bond_info->rx_hashtbl_head = hash_index;
692 client_info->next = prev_tbl_head;
693 if (prev_tbl_head != RLB_NULL_INDEX) {
694 bond_info->rx_hashtbl[prev_tbl_head].prev =
697 client_info->assigned = 1;
701 _unlock_rx_hashtbl(bond);
703 return assigned_slave;
706 /* chooses (and returns) transmit channel for arp reply
707 * does not choose channel for other arp types since they are
708 * sent on the curr_active_slave
710 static struct slave *rlb_arp_xmit(struct sk_buff *skb, struct bonding *bond)
712 struct arp_pkt *arp = arp_pkt(skb);
713 struct slave *tx_slave = NULL;
715 if (arp->op_code == htons(ARPOP_REPLY)) {
716 /* the arp must be sent on the selected
719 tx_slave = rlb_choose_channel(skb, bond);
721 memcpy(arp->mac_src,tx_slave->dev->dev_addr, ETH_ALEN);
723 dprintk("Server sent ARP Reply packet\n");
724 } else if (arp->op_code == htons(ARPOP_REQUEST)) {
725 /* Create an entry in the rx_hashtbl for this client as a
727 * When the arp reply is received the entry will be updated
728 * with the correct unicast address of the client.
730 rlb_choose_channel(skb, bond);
732 /* The ARP relpy packets must be delayed so that
733 * they can cancel out the influence of the ARP request.
735 bond->alb_info.rlb_update_delay_counter = RLB_UPDATE_DELAY;
737 /* arp requests are broadcast and are sent on the primary
738 * the arp request will collapse all clients on the subnet to
739 * the primary slave. We must register these clients to be
740 * updated with their assigned mac.
742 rlb_req_update_subnet_clients(bond, arp->ip_src);
743 dprintk("Server sent ARP Request packet\n");
749 /* Caller must hold bond lock for read */
750 static void rlb_rebalance(struct bonding *bond)
752 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
753 struct slave *assigned_slave;
754 struct rlb_client_info *client_info;
758 _lock_rx_hashtbl(bond);
761 hash_index = bond_info->rx_hashtbl_head;
762 for (; hash_index != RLB_NULL_INDEX; hash_index = client_info->next) {
763 client_info = &(bond_info->rx_hashtbl[hash_index]);
764 assigned_slave = rlb_next_rx_slave(bond);
765 if (assigned_slave && (client_info->slave != assigned_slave)) {
766 client_info->slave = assigned_slave;
767 client_info->ntt = 1;
772 /* update the team's flag only after the whole iteration */
774 bond_info->rx_ntt = 1;
776 _unlock_rx_hashtbl(bond);
779 /* Caller must hold rx_hashtbl lock */
780 static void rlb_init_table_entry(struct rlb_client_info *entry)
782 memset(entry, 0, sizeof(struct rlb_client_info));
783 entry->next = RLB_NULL_INDEX;
784 entry->prev = RLB_NULL_INDEX;
787 static int rlb_initialize(struct bonding *bond)
789 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
790 struct packet_type *pk_type = &(BOND_ALB_INFO(bond).rlb_pkt_type);
791 struct rlb_client_info *new_hashtbl;
792 int size = RLB_HASH_TABLE_SIZE * sizeof(struct rlb_client_info);
795 spin_lock_init(&(bond_info->rx_hashtbl_lock));
797 new_hashtbl = kmalloc(size, GFP_KERNEL);
799 printk(KERN_ERR DRV_NAME
800 ": %s: Error: Failed to allocate RLB hash table\n",
804 _lock_rx_hashtbl(bond);
806 bond_info->rx_hashtbl = new_hashtbl;
808 bond_info->rx_hashtbl_head = RLB_NULL_INDEX;
810 for (i = 0; i < RLB_HASH_TABLE_SIZE; i++) {
811 rlb_init_table_entry(bond_info->rx_hashtbl + i);
814 _unlock_rx_hashtbl(bond);
816 /*initialize packet type*/
817 pk_type->type = __constant_htons(ETH_P_ARP);
818 pk_type->dev = bond->dev;
819 pk_type->func = rlb_arp_recv;
821 /* register to receive ARPs */
822 dev_add_pack(pk_type);
827 static void rlb_deinitialize(struct bonding *bond)
829 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
831 dev_remove_pack(&(bond_info->rlb_pkt_type));
833 _lock_rx_hashtbl(bond);
835 kfree(bond_info->rx_hashtbl);
836 bond_info->rx_hashtbl = NULL;
837 bond_info->rx_hashtbl_head = RLB_NULL_INDEX;
839 _unlock_rx_hashtbl(bond);
842 static void rlb_clear_vlan(struct bonding *bond, unsigned short vlan_id)
844 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
847 _lock_rx_hashtbl(bond);
849 curr_index = bond_info->rx_hashtbl_head;
850 while (curr_index != RLB_NULL_INDEX) {
851 struct rlb_client_info *curr = &(bond_info->rx_hashtbl[curr_index]);
852 u32 next_index = bond_info->rx_hashtbl[curr_index].next;
853 u32 prev_index = bond_info->rx_hashtbl[curr_index].prev;
855 if (curr->tag && (curr->vlan_id == vlan_id)) {
856 if (curr_index == bond_info->rx_hashtbl_head) {
857 bond_info->rx_hashtbl_head = next_index;
859 if (prev_index != RLB_NULL_INDEX) {
860 bond_info->rx_hashtbl[prev_index].next = next_index;
862 if (next_index != RLB_NULL_INDEX) {
863 bond_info->rx_hashtbl[next_index].prev = prev_index;
866 rlb_init_table_entry(curr);
869 curr_index = next_index;
872 _unlock_rx_hashtbl(bond);
875 /*********************** tlb/rlb shared functions *********************/
877 static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[])
879 struct bonding *bond = bond_get_bond_by_slave(slave);
880 struct learning_pkt pkt;
881 int size = sizeof(struct learning_pkt);
884 memset(&pkt, 0, size);
885 memcpy(pkt.mac_dst, mac_addr, ETH_ALEN);
886 memcpy(pkt.mac_src, mac_addr, ETH_ALEN);
887 pkt.type = __constant_htons(ETH_P_LOOP);
889 for (i = 0; i < MAX_LP_BURST; i++) {
893 skb = dev_alloc_skb(size);
898 data = skb_put(skb, size);
899 memcpy(data, &pkt, size);
901 skb_reset_mac_header(skb);
902 skb->network_header = skb->mac_header + ETH_HLEN;
903 skb->protocol = pkt.type;
904 skb->priority = TC_PRIO_CONTROL;
905 skb->dev = slave->dev;
907 if (!list_empty(&bond->vlan_list)) {
908 struct vlan_entry *vlan;
910 vlan = bond_next_vlan(bond,
911 bond->alb_info.current_alb_vlan);
913 bond->alb_info.current_alb_vlan = vlan;
919 skb = vlan_put_tag(skb, vlan->vlan_id);
921 printk(KERN_ERR DRV_NAME
922 ": %s: Error: failed to insert VLAN tag\n",
932 /* hw is a boolean parameter that determines whether we should try and
933 * set the hw address of the device as well as the hw address of the
936 static int alb_set_slave_mac_addr(struct slave *slave, u8 addr[], int hw)
938 struct net_device *dev = slave->dev;
939 struct sockaddr s_addr;
942 memcpy(dev->dev_addr, addr, dev->addr_len);
946 /* for rlb each slave must have a unique hw mac addresses so that */
947 /* each slave will receive packets destined to a different mac */
948 memcpy(s_addr.sa_data, addr, dev->addr_len);
949 s_addr.sa_family = dev->type;
950 if (dev_set_mac_address(dev, &s_addr)) {
951 printk(KERN_ERR DRV_NAME
952 ": %s: Error: dev_set_mac_address of dev %s failed! ALB "
953 "mode requires that the base driver support setting "
954 "the hw address also when the network device's "
955 "interface is open\n",
956 dev->master->name, dev->name);
963 * Swap MAC addresses between two slaves.
965 * Called with RTNL held, and no other locks.
969 static void alb_swap_mac_addr(struct bonding *bond, struct slave *slave1, struct slave *slave2)
971 u8 tmp_mac_addr[ETH_ALEN];
973 memcpy(tmp_mac_addr, slave1->dev->dev_addr, ETH_ALEN);
974 alb_set_slave_mac_addr(slave1, slave2->dev->dev_addr, bond->alb_info.rlb_enabled);
975 alb_set_slave_mac_addr(slave2, tmp_mac_addr, bond->alb_info.rlb_enabled);
980 * Send learning packets after MAC address swap.
982 * Called with RTNL and no other locks
984 static void alb_fasten_mac_swap(struct bonding *bond, struct slave *slave1,
985 struct slave *slave2)
987 int slaves_state_differ = (SLAVE_IS_OK(slave1) != SLAVE_IS_OK(slave2));
988 struct slave *disabled_slave = NULL;
992 /* fasten the change in the switch */
993 if (SLAVE_IS_OK(slave1)) {
994 alb_send_learning_packets(slave1, slave1->dev->dev_addr);
995 if (bond->alb_info.rlb_enabled) {
996 /* inform the clients that the mac address
999 rlb_req_update_slave_clients(bond, slave1);
1002 disabled_slave = slave1;
1005 if (SLAVE_IS_OK(slave2)) {
1006 alb_send_learning_packets(slave2, slave2->dev->dev_addr);
1007 if (bond->alb_info.rlb_enabled) {
1008 /* inform the clients that the mac address
1011 rlb_req_update_slave_clients(bond, slave2);
1014 disabled_slave = slave2;
1017 if (bond->alb_info.rlb_enabled && slaves_state_differ) {
1018 /* A disabled slave was assigned an active mac addr */
1019 rlb_teach_disabled_mac_on_primary(bond,
1020 disabled_slave->dev->dev_addr);
1025 * alb_change_hw_addr_on_detach
1026 * @bond: bonding we're working on
1027 * @slave: the slave that was just detached
1029 * We assume that @slave was already detached from the slave list.
1031 * If @slave's permanent hw address is different both from its current
1032 * address and from @bond's address, then somewhere in the bond there's
1033 * a slave that has @slave's permanet address as its current address.
1034 * We'll make sure that that slave no longer uses @slave's permanent address.
1036 * Caller must hold RTNL and no other locks
1038 static void alb_change_hw_addr_on_detach(struct bonding *bond, struct slave *slave)
1043 perm_curr_diff = memcmp(slave->perm_hwaddr,
1044 slave->dev->dev_addr,
1046 perm_bond_diff = memcmp(slave->perm_hwaddr,
1047 bond->dev->dev_addr,
1050 if (perm_curr_diff && perm_bond_diff) {
1051 struct slave *tmp_slave;
1054 bond_for_each_slave(bond, tmp_slave, i) {
1055 if (!memcmp(slave->perm_hwaddr,
1056 tmp_slave->dev->dev_addr,
1064 /* locking: needs RTNL and nothing else */
1065 alb_swap_mac_addr(bond, slave, tmp_slave);
1066 alb_fasten_mac_swap(bond, slave, tmp_slave);
1072 * alb_handle_addr_collision_on_attach
1073 * @bond: bonding we're working on
1074 * @slave: the slave that was just attached
1076 * checks uniqueness of slave's mac address and handles the case the
1077 * new slave uses the bonds mac address.
1079 * If the permanent hw address of @slave is @bond's hw address, we need to
1080 * find a different hw address to give @slave, that isn't in use by any other
1081 * slave in the bond. This address must be, of course, one of the premanent
1082 * addresses of the other slaves.
1084 * We go over the slave list, and for each slave there we compare its
1085 * permanent hw address with the current address of all the other slaves.
1086 * If no match was found, then we've found a slave with a permanent address
1087 * that isn't used by any other slave in the bond, so we can assign it to
1090 * assumption: this function is called before @slave is attached to the
1093 * caller must hold the bond lock for write since the mac addresses are compared
1094 * and may be swapped.
1096 static int alb_handle_addr_collision_on_attach(struct bonding *bond, struct slave *slave)
1098 struct slave *tmp_slave1, *tmp_slave2, *free_mac_slave;
1099 struct slave *has_bond_addr = bond->curr_active_slave;
1100 int i, j, found = 0;
1102 if (bond->slave_cnt == 0) {
1103 /* this is the first slave */
1107 /* if slave's mac address differs from bond's mac address
1108 * check uniqueness of slave's mac address against the other
1109 * slaves in the bond.
1111 if (memcmp(slave->perm_hwaddr, bond->dev->dev_addr, ETH_ALEN)) {
1112 bond_for_each_slave(bond, tmp_slave1, i) {
1113 if (!memcmp(tmp_slave1->dev->dev_addr, slave->dev->dev_addr,
1123 /* Try setting slave mac to bond address and fall-through
1124 to code handling that situation below... */
1125 alb_set_slave_mac_addr(slave, bond->dev->dev_addr,
1126 bond->alb_info.rlb_enabled);
1129 /* The slave's address is equal to the address of the bond.
1130 * Search for a spare address in the bond for this slave.
1132 free_mac_slave = NULL;
1134 bond_for_each_slave(bond, tmp_slave1, i) {
1136 bond_for_each_slave(bond, tmp_slave2, j) {
1137 if (!memcmp(tmp_slave1->perm_hwaddr,
1138 tmp_slave2->dev->dev_addr,
1146 /* no slave has tmp_slave1's perm addr
1149 free_mac_slave = tmp_slave1;
1153 if (!has_bond_addr) {
1154 if (!memcmp(tmp_slave1->dev->dev_addr,
1155 bond->dev->dev_addr,
1158 has_bond_addr = tmp_slave1;
1163 if (free_mac_slave) {
1164 alb_set_slave_mac_addr(slave, free_mac_slave->perm_hwaddr,
1165 bond->alb_info.rlb_enabled);
1167 printk(KERN_WARNING DRV_NAME
1168 ": %s: Warning: the hw address of slave %s is in use by "
1169 "the bond; giving it the hw address of %s\n",
1170 bond->dev->name, slave->dev->name, free_mac_slave->dev->name);
1172 } else if (has_bond_addr) {
1173 printk(KERN_ERR DRV_NAME
1174 ": %s: Error: the hw address of slave %s is in use by the "
1175 "bond; couldn't find a slave with a free hw address to "
1176 "give it (this should not have happened)\n",
1177 bond->dev->name, slave->dev->name);
1185 * alb_set_mac_address
1189 * In TLB mode all slaves are configured to the bond's hw address, but set
1190 * their dev_addr field to different addresses (based on their permanent hw
1193 * For each slave, this function sets the interface to the new address and then
1194 * changes its dev_addr field to its previous value.
1196 * Unwinding assumes bond's mac address has not yet changed.
1198 static int alb_set_mac_address(struct bonding *bond, void *addr)
1201 struct slave *slave, *stop_at;
1202 char tmp_addr[ETH_ALEN];
1206 if (bond->alb_info.rlb_enabled) {
1210 bond_for_each_slave(bond, slave, i) {
1211 if (slave->dev->set_mac_address == NULL) {
1216 /* save net_device's current hw address */
1217 memcpy(tmp_addr, slave->dev->dev_addr, ETH_ALEN);
1219 res = dev_set_mac_address(slave->dev, addr);
1221 /* restore net_device's hw address */
1222 memcpy(slave->dev->dev_addr, tmp_addr, ETH_ALEN);
1232 memcpy(sa.sa_data, bond->dev->dev_addr, bond->dev->addr_len);
1233 sa.sa_family = bond->dev->type;
1235 /* unwind from head to the slave that failed */
1237 bond_for_each_slave_from_to(bond, slave, i, bond->first_slave, stop_at) {
1238 memcpy(tmp_addr, slave->dev->dev_addr, ETH_ALEN);
1239 dev_set_mac_address(slave->dev, &sa);
1240 memcpy(slave->dev->dev_addr, tmp_addr, ETH_ALEN);
1246 /************************ exported alb funcions ************************/
1248 int bond_alb_initialize(struct bonding *bond, int rlb_enabled)
1252 res = tlb_initialize(bond);
1258 bond->alb_info.rlb_enabled = 1;
1259 /* initialize rlb */
1260 res = rlb_initialize(bond);
1262 tlb_deinitialize(bond);
1266 bond->alb_info.rlb_enabled = 0;
1272 void bond_alb_deinitialize(struct bonding *bond)
1274 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
1276 tlb_deinitialize(bond);
1278 if (bond_info->rlb_enabled) {
1279 rlb_deinitialize(bond);
1283 int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev)
1285 struct bonding *bond = bond_dev->priv;
1286 struct ethhdr *eth_data;
1287 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
1288 struct slave *tx_slave = NULL;
1289 static const __be32 ip_bcast = htonl(0xffffffff);
1291 int do_tx_balance = 1;
1293 const u8 *hash_start = NULL;
1295 struct ipv6hdr *ip6hdr;
1297 skb_reset_mac_header(skb);
1298 eth_data = eth_hdr(skb);
1300 /* make sure that the curr_active_slave and the slaves list do
1301 * not change during tx
1303 read_lock(&bond->lock);
1304 read_lock(&bond->curr_slave_lock);
1306 if (!BOND_IS_OK(bond)) {
1310 switch (ntohs(skb->protocol)) {
1312 const struct iphdr *iph = ip_hdr(skb);
1314 if ((memcmp(eth_data->h_dest, mac_bcast, ETH_ALEN) == 0) ||
1315 (iph->daddr == ip_bcast) ||
1316 (iph->protocol == IPPROTO_IGMP)) {
1320 hash_start = (char *)&(iph->daddr);
1321 hash_size = sizeof(iph->daddr);
1325 /* IPv6 doesn't really use broadcast mac address, but leave
1326 * that here just in case.
1328 if (memcmp(eth_data->h_dest, mac_bcast, ETH_ALEN) == 0) {
1333 /* IPv6 uses all-nodes multicast as an equivalent to
1334 * broadcasts in IPv4.
1336 if (memcmp(eth_data->h_dest, mac_v6_allmcast, ETH_ALEN) == 0) {
1341 /* Additianally, DAD probes should not be tx-balanced as that
1342 * will lead to false positives for duplicate addresses and
1343 * prevent address configuration from working.
1345 ip6hdr = ipv6_hdr(skb);
1346 if (ipv6_addr_any(&ip6hdr->saddr)) {
1351 hash_start = (char *)&(ipv6_hdr(skb)->daddr);
1352 hash_size = sizeof(ipv6_hdr(skb)->daddr);
1355 if (ipx_hdr(skb)->ipx_checksum != IPX_NO_CHECKSUM) {
1356 /* something is wrong with this packet */
1361 if (ipx_hdr(skb)->ipx_type != IPX_TYPE_NCP) {
1362 /* The only protocol worth balancing in
1363 * this family since it has an "ARP" like
1370 hash_start = (char*)eth_data->h_dest;
1371 hash_size = ETH_ALEN;
1375 if (bond_info->rlb_enabled) {
1376 tx_slave = rlb_arp_xmit(skb, bond);
1384 if (do_tx_balance) {
1385 hash_index = _simple_hash(hash_start, hash_size);
1386 tx_slave = tlb_choose_channel(bond, hash_index, skb->len);
1390 /* unbalanced or unassigned, send through primary */
1391 tx_slave = bond->curr_active_slave;
1392 bond_info->unbalanced_load += skb->len;
1395 if (tx_slave && SLAVE_IS_OK(tx_slave)) {
1396 if (tx_slave != bond->curr_active_slave) {
1397 memcpy(eth_data->h_source,
1398 tx_slave->dev->dev_addr,
1402 res = bond_dev_queue_xmit(bond, skb, tx_slave->dev);
1405 tlb_clear_slave(bond, tx_slave, 0);
1411 /* no suitable interface, frame not sent */
1414 read_unlock(&bond->curr_slave_lock);
1415 read_unlock(&bond->lock);
1419 void bond_alb_monitor(struct work_struct *work)
1421 struct bonding *bond = container_of(work, struct bonding,
1423 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
1424 struct slave *slave;
1427 read_lock(&bond->lock);
1429 if (bond->kill_timers) {
1433 if (bond->slave_cnt == 0) {
1434 bond_info->tx_rebalance_counter = 0;
1435 bond_info->lp_counter = 0;
1439 bond_info->tx_rebalance_counter++;
1440 bond_info->lp_counter++;
1442 /* send learning packets */
1443 if (bond_info->lp_counter >= BOND_ALB_LP_TICKS) {
1444 /* change of curr_active_slave involves swapping of mac addresses.
1445 * in order to avoid this swapping from happening while
1446 * sending the learning packets, the curr_slave_lock must be held for
1449 read_lock(&bond->curr_slave_lock);
1451 bond_for_each_slave(bond, slave, i) {
1452 alb_send_learning_packets(slave, slave->dev->dev_addr);
1455 read_unlock(&bond->curr_slave_lock);
1457 bond_info->lp_counter = 0;
1460 /* rebalance tx traffic */
1461 if (bond_info->tx_rebalance_counter >= BOND_TLB_REBALANCE_TICKS) {
1463 read_lock(&bond->curr_slave_lock);
1465 bond_for_each_slave(bond, slave, i) {
1466 tlb_clear_slave(bond, slave, 1);
1467 if (slave == bond->curr_active_slave) {
1468 SLAVE_TLB_INFO(slave).load =
1469 bond_info->unbalanced_load /
1470 BOND_TLB_REBALANCE_INTERVAL;
1471 bond_info->unbalanced_load = 0;
1475 read_unlock(&bond->curr_slave_lock);
1477 bond_info->tx_rebalance_counter = 0;
1480 /* handle rlb stuff */
1481 if (bond_info->rlb_enabled) {
1482 if (bond_info->primary_is_promisc &&
1483 (++bond_info->rlb_promisc_timeout_counter >= RLB_PROMISC_TIMEOUT)) {
1486 * dev_set_promiscuity requires rtnl and
1489 read_unlock(&bond->lock);
1492 bond_info->rlb_promisc_timeout_counter = 0;
1494 /* If the primary was set to promiscuous mode
1495 * because a slave was disabled then
1496 * it can now leave promiscuous mode.
1498 dev_set_promiscuity(bond->curr_active_slave->dev, -1);
1499 bond_info->primary_is_promisc = 0;
1502 read_lock(&bond->lock);
1505 if (bond_info->rlb_rebalance) {
1506 bond_info->rlb_rebalance = 0;
1507 rlb_rebalance(bond);
1510 /* check if clients need updating */
1511 if (bond_info->rx_ntt) {
1512 if (bond_info->rlb_update_delay_counter) {
1513 --bond_info->rlb_update_delay_counter;
1515 rlb_update_rx_clients(bond);
1516 if (bond_info->rlb_update_retry_counter) {
1517 --bond_info->rlb_update_retry_counter;
1519 bond_info->rx_ntt = 0;
1526 queue_delayed_work(bond->wq, &bond->alb_work, alb_delta_in_ticks);
1528 read_unlock(&bond->lock);
1531 /* assumption: called before the slave is attached to the bond
1532 * and not locked by the bond lock
1534 int bond_alb_init_slave(struct bonding *bond, struct slave *slave)
1538 res = alb_set_slave_mac_addr(slave, slave->perm_hwaddr,
1539 bond->alb_info.rlb_enabled);
1544 /* caller must hold the bond lock for write since the mac addresses
1545 * are compared and may be swapped.
1547 read_lock(&bond->lock);
1549 res = alb_handle_addr_collision_on_attach(bond, slave);
1551 read_unlock(&bond->lock);
1557 tlb_init_slave(slave);
1559 /* order a rebalance ASAP */
1560 bond->alb_info.tx_rebalance_counter = BOND_TLB_REBALANCE_TICKS;
1562 if (bond->alb_info.rlb_enabled) {
1563 bond->alb_info.rlb_rebalance = 1;
1570 * Remove slave from tlb and rlb hash tables, and fix up MAC addresses
1573 * Caller must hold RTNL and no other locks
1575 void bond_alb_deinit_slave(struct bonding *bond, struct slave *slave)
1577 if (bond->slave_cnt > 1) {
1578 alb_change_hw_addr_on_detach(bond, slave);
1581 tlb_clear_slave(bond, slave, 0);
1583 if (bond->alb_info.rlb_enabled) {
1584 bond->alb_info.next_rx_slave = NULL;
1585 rlb_clear_slave(bond, slave);
1589 /* Caller must hold bond lock for read */
1590 void bond_alb_handle_link_change(struct bonding *bond, struct slave *slave, char link)
1592 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
1594 if (link == BOND_LINK_DOWN) {
1595 tlb_clear_slave(bond, slave, 0);
1596 if (bond->alb_info.rlb_enabled) {
1597 rlb_clear_slave(bond, slave);
1599 } else if (link == BOND_LINK_UP) {
1600 /* order a rebalance ASAP */
1601 bond_info->tx_rebalance_counter = BOND_TLB_REBALANCE_TICKS;
1602 if (bond->alb_info.rlb_enabled) {
1603 bond->alb_info.rlb_rebalance = 1;
1604 /* If the updelay module parameter is smaller than the
1605 * forwarding delay of the switch the rebalance will
1606 * not work because the rebalance arp replies will
1607 * not be forwarded to the clients..
1614 * bond_alb_handle_active_change - assign new curr_active_slave
1615 * @bond: our bonding struct
1616 * @new_slave: new slave to assign
1618 * Set the bond->curr_active_slave to @new_slave and handle
1619 * mac address swapping and promiscuity changes as needed.
1621 * If new_slave is NULL, caller must hold curr_slave_lock or
1622 * bond->lock for write.
1624 * If new_slave is not NULL, caller must hold RTNL, bond->lock for
1625 * read and curr_slave_lock for write. Processing here may sleep, so
1626 * no other locks may be held.
1628 void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave)
1630 struct slave *swap_slave;
1633 if (bond->curr_active_slave == new_slave) {
1637 if (bond->curr_active_slave && bond->alb_info.primary_is_promisc) {
1638 dev_set_promiscuity(bond->curr_active_slave->dev, -1);
1639 bond->alb_info.primary_is_promisc = 0;
1640 bond->alb_info.rlb_promisc_timeout_counter = 0;
1643 swap_slave = bond->curr_active_slave;
1644 bond->curr_active_slave = new_slave;
1646 if (!new_slave || (bond->slave_cnt == 0)) {
1650 /* set the new curr_active_slave to the bonds mac address
1651 * i.e. swap mac addresses of old curr_active_slave and new curr_active_slave
1654 struct slave *tmp_slave;
1655 /* find slave that is holding the bond's mac address */
1656 bond_for_each_slave(bond, tmp_slave, i) {
1657 if (!memcmp(tmp_slave->dev->dev_addr,
1658 bond->dev->dev_addr, ETH_ALEN)) {
1659 swap_slave = tmp_slave;
1666 * Arrange for swap_slave and new_slave to temporarily be
1667 * ignored so we can mess with their MAC addresses without
1668 * fear of interference from transmit activity.
1671 tlb_clear_slave(bond, swap_slave, 1);
1673 tlb_clear_slave(bond, new_slave, 1);
1675 write_unlock_bh(&bond->curr_slave_lock);
1676 read_unlock(&bond->lock);
1680 /* curr_active_slave must be set before calling alb_swap_mac_addr */
1682 /* swap mac address */
1683 alb_swap_mac_addr(bond, swap_slave, new_slave);
1685 /* set the new_slave to the bond mac address */
1686 alb_set_slave_mac_addr(new_slave, bond->dev->dev_addr,
1687 bond->alb_info.rlb_enabled);
1691 alb_fasten_mac_swap(bond, swap_slave, new_slave);
1692 read_lock(&bond->lock);
1694 read_lock(&bond->lock);
1695 alb_send_learning_packets(new_slave, bond->dev->dev_addr);
1698 write_lock_bh(&bond->curr_slave_lock);
1704 int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr)
1706 struct bonding *bond = bond_dev->priv;
1707 struct sockaddr *sa = addr;
1708 struct slave *slave, *swap_slave;
1712 if (!is_valid_ether_addr(sa->sa_data)) {
1713 return -EADDRNOTAVAIL;
1716 res = alb_set_mac_address(bond, addr);
1721 memcpy(bond_dev->dev_addr, sa->sa_data, bond_dev->addr_len);
1723 /* If there is no curr_active_slave there is nothing else to do.
1724 * Otherwise we'll need to pass the new address to it and handle
1727 if (!bond->curr_active_slave) {
1733 bond_for_each_slave(bond, slave, i) {
1734 if (!memcmp(slave->dev->dev_addr, bond_dev->dev_addr, ETH_ALEN)) {
1740 write_unlock_bh(&bond->curr_slave_lock);
1741 read_unlock(&bond->lock);
1744 alb_swap_mac_addr(bond, swap_slave, bond->curr_active_slave);
1745 alb_fasten_mac_swap(bond, swap_slave, bond->curr_active_slave);
1747 alb_set_slave_mac_addr(bond->curr_active_slave, bond_dev->dev_addr,
1748 bond->alb_info.rlb_enabled);
1750 alb_send_learning_packets(bond->curr_active_slave, bond_dev->dev_addr);
1751 if (bond->alb_info.rlb_enabled) {
1752 /* inform clients mac address has changed */
1753 rlb_req_update_slave_clients(bond, bond->curr_active_slave);
1757 read_lock(&bond->lock);
1758 write_lock_bh(&bond->curr_slave_lock);
1763 void bond_alb_clear_vlan(struct bonding *bond, unsigned short vlan_id)
1765 if (bond->alb_info.current_alb_vlan &&
1766 (bond->alb_info.current_alb_vlan->vlan_id == vlan_id)) {
1767 bond->alb_info.current_alb_vlan = NULL;
1770 if (bond->alb_info.rlb_enabled) {
1771 rlb_clear_vlan(bond, vlan_id);