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>
41 #include <asm/byteorder.h>
46 #define ALB_TIMER_TICKS_PER_SEC 10 /* should be a divisor of HZ */
47 #define BOND_TLB_REBALANCE_INTERVAL 10 /* In seconds, periodic re-balancing.
48 * Used for division - never set
51 #define BOND_ALB_LP_INTERVAL 1 /* In seconds, periodic send of
52 * learning packets to the switch
55 #define BOND_TLB_REBALANCE_TICKS (BOND_TLB_REBALANCE_INTERVAL \
56 * ALB_TIMER_TICKS_PER_SEC)
58 #define BOND_ALB_LP_TICKS (BOND_ALB_LP_INTERVAL \
59 * ALB_TIMER_TICKS_PER_SEC)
61 #define TLB_HASH_TABLE_SIZE 256 /* The size of the clients hash table.
62 * Note that this value MUST NOT be smaller
63 * because the key hash table is BYTE wide !
67 #define TLB_NULL_INDEX 0xffffffff
68 #define MAX_LP_BURST 3
71 #define RLB_HASH_TABLE_SIZE 256
72 #define RLB_NULL_INDEX 0xffffffff
73 #define RLB_UPDATE_DELAY 2*ALB_TIMER_TICKS_PER_SEC /* 2 seconds */
74 #define RLB_ARP_BURST_SIZE 2
75 #define RLB_UPDATE_RETRY 3 /* 3-ticks - must be smaller than the rlb
76 * rebalance interval (5 min).
78 /* RLB_PROMISC_TIMEOUT = 10 sec equals the time that the current slave is
79 * promiscuous after failover
81 #define RLB_PROMISC_TIMEOUT 10*ALB_TIMER_TICKS_PER_SEC
83 static const u8 mac_bcast[ETH_ALEN] = {0xff,0xff,0xff,0xff,0xff,0xff};
84 static const int alb_delta_in_ticks = HZ / ALB_TIMER_TICKS_PER_SEC;
91 u8 padding[ETH_ZLEN - ETH_HLEN];
96 __be16 prot_addr_space;
100 u8 mac_src[ETH_ALEN]; /* sender hardware address */
101 __be32 ip_src; /* sender IP address */
102 u8 mac_dst[ETH_ALEN]; /* target hardware address */
103 __be32 ip_dst; /* target IP address */
107 static inline struct arp_pkt *arp_pkt(const struct sk_buff *skb)
109 return (struct arp_pkt *)skb_network_header(skb);
112 /* Forward declaration */
113 static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[]);
115 static inline u8 _simple_hash(const u8 *hash_start, int hash_size)
120 for (i = 0; i < hash_size; i++) {
121 hash ^= hash_start[i];
127 /*********************** tlb specific functions ***************************/
129 static inline void _lock_tx_hashtbl(struct bonding *bond)
131 spin_lock_bh(&(BOND_ALB_INFO(bond).tx_hashtbl_lock));
134 static inline void _unlock_tx_hashtbl(struct bonding *bond)
136 spin_unlock_bh(&(BOND_ALB_INFO(bond).tx_hashtbl_lock));
139 /* Caller must hold tx_hashtbl lock */
140 static inline void tlb_init_table_entry(struct tlb_client_info *entry, int save_load)
143 entry->load_history = 1 + entry->tx_bytes /
144 BOND_TLB_REBALANCE_INTERVAL;
148 entry->tx_slave = NULL;
149 entry->next = TLB_NULL_INDEX;
150 entry->prev = TLB_NULL_INDEX;
153 static inline void tlb_init_slave(struct slave *slave)
155 SLAVE_TLB_INFO(slave).load = 0;
156 SLAVE_TLB_INFO(slave).head = TLB_NULL_INDEX;
159 /* Caller must hold bond lock for read */
160 static void tlb_clear_slave(struct bonding *bond, struct slave *slave, int save_load)
162 struct tlb_client_info *tx_hash_table;
165 _lock_tx_hashtbl(bond);
167 /* clear slave from tx_hashtbl */
168 tx_hash_table = BOND_ALB_INFO(bond).tx_hashtbl;
170 /* skip this if we've already freed the tx hash table */
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);
180 tlb_init_slave(slave);
182 _unlock_tx_hashtbl(bond);
185 /* Must be called before starting the monitor timer */
186 static int tlb_initialize(struct bonding *bond)
188 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
189 int size = TLB_HASH_TABLE_SIZE * sizeof(struct tlb_client_info);
190 struct tlb_client_info *new_hashtbl;
193 spin_lock_init(&(bond_info->tx_hashtbl_lock));
195 new_hashtbl = kzalloc(size, GFP_KERNEL);
197 printk(KERN_ERR DRV_NAME
198 ": %s: Error: Failed to allocate TLB hash table\n",
202 _lock_tx_hashtbl(bond);
204 bond_info->tx_hashtbl = new_hashtbl;
206 for (i = 0; i < TLB_HASH_TABLE_SIZE; i++) {
207 tlb_init_table_entry(&bond_info->tx_hashtbl[i], 1);
210 _unlock_tx_hashtbl(bond);
215 /* Must be called only after all slaves have been released */
216 static void tlb_deinitialize(struct bonding *bond)
218 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
220 _lock_tx_hashtbl(bond);
222 kfree(bond_info->tx_hashtbl);
223 bond_info->tx_hashtbl = NULL;
225 _unlock_tx_hashtbl(bond);
228 /* Caller must hold bond lock for read */
229 static struct slave *tlb_get_least_loaded_slave(struct bonding *bond)
231 struct slave *slave, *least_loaded;
235 /* Find the first enabled slave */
236 bond_for_each_slave(bond, slave, i) {
237 if (SLAVE_IS_OK(slave)) {
247 least_loaded = slave;
248 max_gap = (s64)(slave->speed << 20) - /* Convert to Megabit per sec */
249 (s64)(SLAVE_TLB_INFO(slave).load << 3); /* Bytes to bits */
251 /* Find the slave with the largest gap */
252 bond_for_each_slave_from(bond, slave, i, least_loaded) {
253 if (SLAVE_IS_OK(slave)) {
254 s64 gap = (s64)(slave->speed << 20) -
255 (s64)(SLAVE_TLB_INFO(slave).load << 3);
257 least_loaded = slave;
266 /* Caller must hold bond lock for read */
267 static struct slave *tlb_choose_channel(struct bonding *bond, u32 hash_index, u32 skb_len)
269 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
270 struct tlb_client_info *hash_table;
271 struct slave *assigned_slave;
273 _lock_tx_hashtbl(bond);
275 hash_table = bond_info->tx_hashtbl;
276 assigned_slave = hash_table[hash_index].tx_slave;
277 if (!assigned_slave) {
278 assigned_slave = tlb_get_least_loaded_slave(bond);
280 if (assigned_slave) {
281 struct tlb_slave_info *slave_info =
282 &(SLAVE_TLB_INFO(assigned_slave));
283 u32 next_index = slave_info->head;
285 hash_table[hash_index].tx_slave = assigned_slave;
286 hash_table[hash_index].next = next_index;
287 hash_table[hash_index].prev = TLB_NULL_INDEX;
289 if (next_index != TLB_NULL_INDEX) {
290 hash_table[next_index].prev = hash_index;
293 slave_info->head = hash_index;
295 hash_table[hash_index].load_history;
299 if (assigned_slave) {
300 hash_table[hash_index].tx_bytes += skb_len;
303 _unlock_tx_hashtbl(bond);
305 return assigned_slave;
308 /*********************** rlb specific functions ***************************/
309 static inline void _lock_rx_hashtbl(struct bonding *bond)
311 spin_lock_bh(&(BOND_ALB_INFO(bond).rx_hashtbl_lock));
314 static inline void _unlock_rx_hashtbl(struct bonding *bond)
316 spin_unlock_bh(&(BOND_ALB_INFO(bond).rx_hashtbl_lock));
319 /* when an ARP REPLY is received from a client update its info
322 static void rlb_update_entry_from_arp(struct bonding *bond, struct arp_pkt *arp)
324 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
325 struct rlb_client_info *client_info;
328 _lock_rx_hashtbl(bond);
330 hash_index = _simple_hash((u8*)&(arp->ip_src), sizeof(arp->ip_src));
331 client_info = &(bond_info->rx_hashtbl[hash_index]);
333 if ((client_info->assigned) &&
334 (client_info->ip_src == arp->ip_dst) &&
335 (client_info->ip_dst == arp->ip_src)) {
336 /* update the clients MAC address */
337 memcpy(client_info->mac_dst, arp->mac_src, ETH_ALEN);
338 client_info->ntt = 1;
339 bond_info->rx_ntt = 1;
342 _unlock_rx_hashtbl(bond);
345 static int rlb_arp_recv(struct sk_buff *skb, struct net_device *bond_dev, struct packet_type *ptype, struct net_device *orig_dev)
347 struct bonding *bond = bond_dev->priv;
348 struct arp_pkt *arp = (struct arp_pkt *)skb->data;
349 int res = NET_RX_DROP;
351 if (dev_net(bond_dev) != &init_net)
354 if (!(bond_dev->flags & IFF_MASTER))
358 dprintk("Packet has no ARP data\n");
362 if (skb->len < sizeof(struct arp_pkt)) {
363 dprintk("Packet is too small to be an ARP\n");
367 if (arp->op_code == htons(ARPOP_REPLY)) {
368 /* update rx hash table for this ARP */
369 rlb_update_entry_from_arp(bond, arp);
370 dprintk("Server received an ARP Reply from client\n");
373 res = NET_RX_SUCCESS;
381 /* Caller must hold bond lock for read */
382 static struct slave *rlb_next_rx_slave(struct bonding *bond)
384 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
385 struct slave *rx_slave, *slave, *start_at;
388 if (bond_info->next_rx_slave) {
389 start_at = bond_info->next_rx_slave;
391 start_at = bond->first_slave;
396 bond_for_each_slave_from(bond, slave, i, start_at) {
397 if (SLAVE_IS_OK(slave)) {
400 } else if (slave->speed > rx_slave->speed) {
407 bond_info->next_rx_slave = rx_slave->next;
413 /* teach the switch the mac of a disabled slave
414 * on the primary for fault tolerance
416 * Caller must hold bond->curr_slave_lock for write or bond lock for write
418 static void rlb_teach_disabled_mac_on_primary(struct bonding *bond, u8 addr[])
420 if (!bond->curr_active_slave) {
424 if (!bond->alb_info.primary_is_promisc) {
425 if (!dev_set_promiscuity(bond->curr_active_slave->dev, 1))
426 bond->alb_info.primary_is_promisc = 1;
428 bond->alb_info.primary_is_promisc = 0;
431 bond->alb_info.rlb_promisc_timeout_counter = 0;
433 alb_send_learning_packets(bond->curr_active_slave, addr);
436 /* slave being removed should not be active at this point
438 * Caller must hold bond lock for read
440 static void rlb_clear_slave(struct bonding *bond, struct slave *slave)
442 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
443 struct rlb_client_info *rx_hash_table;
444 u32 index, next_index;
446 /* clear slave from rx_hashtbl */
447 _lock_rx_hashtbl(bond);
449 rx_hash_table = bond_info->rx_hashtbl;
450 index = bond_info->rx_hashtbl_head;
451 for (; index != RLB_NULL_INDEX; index = next_index) {
452 next_index = rx_hash_table[index].next;
453 if (rx_hash_table[index].slave == slave) {
454 struct slave *assigned_slave = rlb_next_rx_slave(bond);
456 if (assigned_slave) {
457 rx_hash_table[index].slave = assigned_slave;
458 if (memcmp(rx_hash_table[index].mac_dst,
459 mac_bcast, ETH_ALEN)) {
460 bond_info->rx_hashtbl[index].ntt = 1;
461 bond_info->rx_ntt = 1;
462 /* A slave has been removed from the
463 * table because it is either disabled
464 * or being released. We must retry the
465 * update to avoid clients from not
466 * being updated & disconnecting when
469 bond_info->rlb_update_retry_counter =
472 } else { /* there is no active slave */
473 rx_hash_table[index].slave = NULL;
478 _unlock_rx_hashtbl(bond);
480 write_lock_bh(&bond->curr_slave_lock);
482 if (slave != bond->curr_active_slave) {
483 rlb_teach_disabled_mac_on_primary(bond, slave->dev->dev_addr);
486 write_unlock_bh(&bond->curr_slave_lock);
489 static void rlb_update_client(struct rlb_client_info *client_info)
493 if (!client_info->slave) {
497 for (i = 0; i < RLB_ARP_BURST_SIZE; i++) {
500 skb = arp_create(ARPOP_REPLY, ETH_P_ARP,
502 client_info->slave->dev,
504 client_info->mac_dst,
505 client_info->slave->dev->dev_addr,
506 client_info->mac_dst);
508 printk(KERN_ERR DRV_NAME
509 ": %s: Error: failed to create an ARP packet\n",
510 client_info->slave->dev->master->name);
514 skb->dev = client_info->slave->dev;
516 if (client_info->tag) {
517 skb = vlan_put_tag(skb, client_info->vlan_id);
519 printk(KERN_ERR DRV_NAME
520 ": %s: Error: failed to insert VLAN tag\n",
521 client_info->slave->dev->master->name);
530 /* sends ARP REPLIES that update the clients that need updating */
531 static void rlb_update_rx_clients(struct bonding *bond)
533 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
534 struct rlb_client_info *client_info;
537 _lock_rx_hashtbl(bond);
539 hash_index = bond_info->rx_hashtbl_head;
540 for (; hash_index != RLB_NULL_INDEX; hash_index = client_info->next) {
541 client_info = &(bond_info->rx_hashtbl[hash_index]);
542 if (client_info->ntt) {
543 rlb_update_client(client_info);
544 if (bond_info->rlb_update_retry_counter == 0) {
545 client_info->ntt = 0;
550 /* do not update the entries again untill this counter is zero so that
551 * not to confuse the clients.
553 bond_info->rlb_update_delay_counter = RLB_UPDATE_DELAY;
555 _unlock_rx_hashtbl(bond);
558 /* The slave was assigned a new mac address - update the clients */
559 static void rlb_req_update_slave_clients(struct bonding *bond, struct slave *slave)
561 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
562 struct rlb_client_info *client_info;
566 _lock_rx_hashtbl(bond);
568 hash_index = bond_info->rx_hashtbl_head;
569 for (; hash_index != RLB_NULL_INDEX; hash_index = client_info->next) {
570 client_info = &(bond_info->rx_hashtbl[hash_index]);
572 if ((client_info->slave == slave) &&
573 memcmp(client_info->mac_dst, mac_bcast, ETH_ALEN)) {
574 client_info->ntt = 1;
579 // update the team's flag only after the whole iteration
581 bond_info->rx_ntt = 1;
583 bond_info->rlb_update_retry_counter = RLB_UPDATE_RETRY;
586 _unlock_rx_hashtbl(bond);
589 /* mark all clients using src_ip to be updated */
590 static void rlb_req_update_subnet_clients(struct bonding *bond, __be32 src_ip)
592 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
593 struct rlb_client_info *client_info;
596 _lock_rx_hashtbl(bond);
598 hash_index = bond_info->rx_hashtbl_head;
599 for (; hash_index != RLB_NULL_INDEX; hash_index = client_info->next) {
600 client_info = &(bond_info->rx_hashtbl[hash_index]);
602 if (!client_info->slave) {
603 printk(KERN_ERR DRV_NAME
604 ": %s: Error: found a client with no channel in "
605 "the client's hash table\n",
609 /*update all clients using this src_ip, that are not assigned
610 * to the team's address (curr_active_slave) and have a known
611 * unicast mac address.
613 if ((client_info->ip_src == src_ip) &&
614 memcmp(client_info->slave->dev->dev_addr,
615 bond->dev->dev_addr, ETH_ALEN) &&
616 memcmp(client_info->mac_dst, mac_bcast, ETH_ALEN)) {
617 client_info->ntt = 1;
618 bond_info->rx_ntt = 1;
622 _unlock_rx_hashtbl(bond);
625 /* Caller must hold both bond and ptr locks for read */
626 static struct slave *rlb_choose_channel(struct sk_buff *skb, struct bonding *bond)
628 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
629 struct arp_pkt *arp = arp_pkt(skb);
630 struct slave *assigned_slave;
631 struct rlb_client_info *client_info;
634 _lock_rx_hashtbl(bond);
636 hash_index = _simple_hash((u8 *)&arp->ip_dst, sizeof(arp->ip_src));
637 client_info = &(bond_info->rx_hashtbl[hash_index]);
639 if (client_info->assigned) {
640 if ((client_info->ip_src == arp->ip_src) &&
641 (client_info->ip_dst == arp->ip_dst)) {
642 /* the entry is already assigned to this client */
643 if (memcmp(arp->mac_dst, mac_bcast, ETH_ALEN)) {
644 /* update mac address from arp */
645 memcpy(client_info->mac_dst, arp->mac_dst, ETH_ALEN);
648 assigned_slave = client_info->slave;
649 if (assigned_slave) {
650 _unlock_rx_hashtbl(bond);
651 return assigned_slave;
654 /* the entry is already assigned to some other client,
655 * move the old client to primary (curr_active_slave) so
656 * that the new client can be assigned to this entry.
658 if (bond->curr_active_slave &&
659 client_info->slave != bond->curr_active_slave) {
660 client_info->slave = bond->curr_active_slave;
661 rlb_update_client(client_info);
665 /* assign a new slave */
666 assigned_slave = rlb_next_rx_slave(bond);
668 if (assigned_slave) {
669 client_info->ip_src = arp->ip_src;
670 client_info->ip_dst = arp->ip_dst;
671 /* arp->mac_dst is broadcast for arp reqeusts.
672 * will be updated with clients actual unicast mac address
673 * upon receiving an arp reply.
675 memcpy(client_info->mac_dst, arp->mac_dst, ETH_ALEN);
676 client_info->slave = assigned_slave;
678 if (memcmp(client_info->mac_dst, mac_bcast, ETH_ALEN)) {
679 client_info->ntt = 1;
680 bond->alb_info.rx_ntt = 1;
682 client_info->ntt = 0;
685 if (!list_empty(&bond->vlan_list)) {
686 if (!vlan_get_tag(skb, &client_info->vlan_id))
687 client_info->tag = 1;
690 if (!client_info->assigned) {
691 u32 prev_tbl_head = bond_info->rx_hashtbl_head;
692 bond_info->rx_hashtbl_head = hash_index;
693 client_info->next = prev_tbl_head;
694 if (prev_tbl_head != RLB_NULL_INDEX) {
695 bond_info->rx_hashtbl[prev_tbl_head].prev =
698 client_info->assigned = 1;
702 _unlock_rx_hashtbl(bond);
704 return assigned_slave;
707 /* chooses (and returns) transmit channel for arp reply
708 * does not choose channel for other arp types since they are
709 * sent on the curr_active_slave
711 static struct slave *rlb_arp_xmit(struct sk_buff *skb, struct bonding *bond)
713 struct arp_pkt *arp = arp_pkt(skb);
714 struct slave *tx_slave = NULL;
716 if (arp->op_code == __constant_htons(ARPOP_REPLY)) {
717 /* the arp must be sent on the selected
720 tx_slave = rlb_choose_channel(skb, bond);
722 memcpy(arp->mac_src,tx_slave->dev->dev_addr, ETH_ALEN);
724 dprintk("Server sent ARP Reply packet\n");
725 } else if (arp->op_code == __constant_htons(ARPOP_REQUEST)) {
726 /* Create an entry in the rx_hashtbl for this client as a
728 * When the arp reply is received the entry will be updated
729 * with the correct unicast address of the client.
731 rlb_choose_channel(skb, bond);
733 /* The ARP relpy packets must be delayed so that
734 * they can cancel out the influence of the ARP request.
736 bond->alb_info.rlb_update_delay_counter = RLB_UPDATE_DELAY;
738 /* arp requests are broadcast and are sent on the primary
739 * the arp request will collapse all clients on the subnet to
740 * the primary slave. We must register these clients to be
741 * updated with their assigned mac.
743 rlb_req_update_subnet_clients(bond, arp->ip_src);
744 dprintk("Server sent ARP Request packet\n");
750 /* Caller must hold bond lock for read */
751 static void rlb_rebalance(struct bonding *bond)
753 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
754 struct slave *assigned_slave;
755 struct rlb_client_info *client_info;
759 _lock_rx_hashtbl(bond);
762 hash_index = bond_info->rx_hashtbl_head;
763 for (; hash_index != RLB_NULL_INDEX; hash_index = client_info->next) {
764 client_info = &(bond_info->rx_hashtbl[hash_index]);
765 assigned_slave = rlb_next_rx_slave(bond);
766 if (assigned_slave && (client_info->slave != assigned_slave)) {
767 client_info->slave = assigned_slave;
768 client_info->ntt = 1;
773 /* update the team's flag only after the whole iteration */
775 bond_info->rx_ntt = 1;
777 _unlock_rx_hashtbl(bond);
780 /* Caller must hold rx_hashtbl lock */
781 static void rlb_init_table_entry(struct rlb_client_info *entry)
783 memset(entry, 0, sizeof(struct rlb_client_info));
784 entry->next = RLB_NULL_INDEX;
785 entry->prev = RLB_NULL_INDEX;
788 static int rlb_initialize(struct bonding *bond)
790 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
791 struct packet_type *pk_type = &(BOND_ALB_INFO(bond).rlb_pkt_type);
792 struct rlb_client_info *new_hashtbl;
793 int size = RLB_HASH_TABLE_SIZE * sizeof(struct rlb_client_info);
796 spin_lock_init(&(bond_info->rx_hashtbl_lock));
798 new_hashtbl = kmalloc(size, GFP_KERNEL);
800 printk(KERN_ERR DRV_NAME
801 ": %s: Error: Failed to allocate RLB hash table\n",
805 _lock_rx_hashtbl(bond);
807 bond_info->rx_hashtbl = new_hashtbl;
809 bond_info->rx_hashtbl_head = RLB_NULL_INDEX;
811 for (i = 0; i < RLB_HASH_TABLE_SIZE; i++) {
812 rlb_init_table_entry(bond_info->rx_hashtbl + i);
815 _unlock_rx_hashtbl(bond);
817 /*initialize packet type*/
818 pk_type->type = __constant_htons(ETH_P_ARP);
819 pk_type->dev = bond->dev;
820 pk_type->func = rlb_arp_recv;
822 /* register to receive ARPs */
823 dev_add_pack(pk_type);
828 static void rlb_deinitialize(struct bonding *bond)
830 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
832 dev_remove_pack(&(bond_info->rlb_pkt_type));
834 _lock_rx_hashtbl(bond);
836 kfree(bond_info->rx_hashtbl);
837 bond_info->rx_hashtbl = NULL;
838 bond_info->rx_hashtbl_head = RLB_NULL_INDEX;
840 _unlock_rx_hashtbl(bond);
843 static void rlb_clear_vlan(struct bonding *bond, unsigned short vlan_id)
845 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
848 _lock_rx_hashtbl(bond);
850 curr_index = bond_info->rx_hashtbl_head;
851 while (curr_index != RLB_NULL_INDEX) {
852 struct rlb_client_info *curr = &(bond_info->rx_hashtbl[curr_index]);
853 u32 next_index = bond_info->rx_hashtbl[curr_index].next;
854 u32 prev_index = bond_info->rx_hashtbl[curr_index].prev;
856 if (curr->tag && (curr->vlan_id == vlan_id)) {
857 if (curr_index == bond_info->rx_hashtbl_head) {
858 bond_info->rx_hashtbl_head = next_index;
860 if (prev_index != RLB_NULL_INDEX) {
861 bond_info->rx_hashtbl[prev_index].next = next_index;
863 if (next_index != RLB_NULL_INDEX) {
864 bond_info->rx_hashtbl[next_index].prev = prev_index;
867 rlb_init_table_entry(curr);
870 curr_index = next_index;
873 _unlock_rx_hashtbl(bond);
876 /*********************** tlb/rlb shared functions *********************/
878 static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[])
880 struct bonding *bond = bond_get_bond_by_slave(slave);
881 struct learning_pkt pkt;
882 int size = sizeof(struct learning_pkt);
885 memset(&pkt, 0, size);
886 memcpy(pkt.mac_dst, mac_addr, ETH_ALEN);
887 memcpy(pkt.mac_src, mac_addr, ETH_ALEN);
888 pkt.type = __constant_htons(ETH_P_LOOP);
890 for (i = 0; i < MAX_LP_BURST; i++) {
894 skb = dev_alloc_skb(size);
899 data = skb_put(skb, size);
900 memcpy(data, &pkt, size);
902 skb_reset_mac_header(skb);
903 skb->network_header = skb->mac_header + ETH_HLEN;
904 skb->protocol = pkt.type;
905 skb->priority = TC_PRIO_CONTROL;
906 skb->dev = slave->dev;
908 if (!list_empty(&bond->vlan_list)) {
909 struct vlan_entry *vlan;
911 vlan = bond_next_vlan(bond,
912 bond->alb_info.current_alb_vlan);
914 bond->alb_info.current_alb_vlan = vlan;
920 skb = vlan_put_tag(skb, vlan->vlan_id);
922 printk(KERN_ERR DRV_NAME
923 ": %s: Error: failed to insert VLAN tag\n",
933 /* hw is a boolean parameter that determines whether we should try and
934 * set the hw address of the device as well as the hw address of the
937 static int alb_set_slave_mac_addr(struct slave *slave, u8 addr[], int hw)
939 struct net_device *dev = slave->dev;
940 struct sockaddr s_addr;
943 memcpy(dev->dev_addr, addr, dev->addr_len);
947 /* for rlb each slave must have a unique hw mac addresses so that */
948 /* each slave will receive packets destined to a different mac */
949 memcpy(s_addr.sa_data, addr, dev->addr_len);
950 s_addr.sa_family = dev->type;
951 if (dev_set_mac_address(dev, &s_addr)) {
952 printk(KERN_ERR DRV_NAME
953 ": %s: Error: dev_set_mac_address of dev %s failed! ALB "
954 "mode requires that the base driver support setting "
955 "the hw address also when the network device's "
956 "interface is open\n",
957 dev->master->name, dev->name);
964 * Swap MAC addresses between two slaves.
966 * Called with RTNL held, and no other locks.
970 static void alb_swap_mac_addr(struct bonding *bond, struct slave *slave1, struct slave *slave2)
972 u8 tmp_mac_addr[ETH_ALEN];
974 memcpy(tmp_mac_addr, slave1->dev->dev_addr, ETH_ALEN);
975 alb_set_slave_mac_addr(slave1, slave2->dev->dev_addr, bond->alb_info.rlb_enabled);
976 alb_set_slave_mac_addr(slave2, tmp_mac_addr, bond->alb_info.rlb_enabled);
981 * Send learning packets after MAC address swap.
983 * Called with RTNL and no other locks
985 static void alb_fasten_mac_swap(struct bonding *bond, struct slave *slave1,
986 struct slave *slave2)
988 int slaves_state_differ = (SLAVE_IS_OK(slave1) != SLAVE_IS_OK(slave2));
989 struct slave *disabled_slave = NULL;
993 /* fasten the change in the switch */
994 if (SLAVE_IS_OK(slave1)) {
995 alb_send_learning_packets(slave1, slave1->dev->dev_addr);
996 if (bond->alb_info.rlb_enabled) {
997 /* inform the clients that the mac address
1000 rlb_req_update_slave_clients(bond, slave1);
1003 disabled_slave = slave1;
1006 if (SLAVE_IS_OK(slave2)) {
1007 alb_send_learning_packets(slave2, slave2->dev->dev_addr);
1008 if (bond->alb_info.rlb_enabled) {
1009 /* inform the clients that the mac address
1012 rlb_req_update_slave_clients(bond, slave2);
1015 disabled_slave = slave2;
1018 if (bond->alb_info.rlb_enabled && slaves_state_differ) {
1019 /* A disabled slave was assigned an active mac addr */
1020 rlb_teach_disabled_mac_on_primary(bond,
1021 disabled_slave->dev->dev_addr);
1026 * alb_change_hw_addr_on_detach
1027 * @bond: bonding we're working on
1028 * @slave: the slave that was just detached
1030 * We assume that @slave was already detached from the slave list.
1032 * If @slave's permanent hw address is different both from its current
1033 * address and from @bond's address, then somewhere in the bond there's
1034 * a slave that has @slave's permanet address as its current address.
1035 * We'll make sure that that slave no longer uses @slave's permanent address.
1037 * Caller must hold RTNL and no other locks
1039 static void alb_change_hw_addr_on_detach(struct bonding *bond, struct slave *slave)
1044 perm_curr_diff = memcmp(slave->perm_hwaddr,
1045 slave->dev->dev_addr,
1047 perm_bond_diff = memcmp(slave->perm_hwaddr,
1048 bond->dev->dev_addr,
1051 if (perm_curr_diff && perm_bond_diff) {
1052 struct slave *tmp_slave;
1055 bond_for_each_slave(bond, tmp_slave, i) {
1056 if (!memcmp(slave->perm_hwaddr,
1057 tmp_slave->dev->dev_addr,
1065 /* locking: needs RTNL and nothing else */
1066 alb_swap_mac_addr(bond, slave, tmp_slave);
1067 alb_fasten_mac_swap(bond, slave, tmp_slave);
1073 * alb_handle_addr_collision_on_attach
1074 * @bond: bonding we're working on
1075 * @slave: the slave that was just attached
1077 * checks uniqueness of slave's mac address and handles the case the
1078 * new slave uses the bonds mac address.
1080 * If the permanent hw address of @slave is @bond's hw address, we need to
1081 * find a different hw address to give @slave, that isn't in use by any other
1082 * slave in the bond. This address must be, of course, one of the premanent
1083 * addresses of the other slaves.
1085 * We go over the slave list, and for each slave there we compare its
1086 * permanent hw address with the current address of all the other slaves.
1087 * If no match was found, then we've found a slave with a permanent address
1088 * that isn't used by any other slave in the bond, so we can assign it to
1091 * assumption: this function is called before @slave is attached to the
1094 * caller must hold the bond lock for write since the mac addresses are compared
1095 * and may be swapped.
1097 static int alb_handle_addr_collision_on_attach(struct bonding *bond, struct slave *slave)
1099 struct slave *tmp_slave1, *tmp_slave2, *free_mac_slave;
1100 struct slave *has_bond_addr = bond->curr_active_slave;
1101 int i, j, found = 0;
1103 if (bond->slave_cnt == 0) {
1104 /* this is the first slave */
1108 /* if slave's mac address differs from bond's mac address
1109 * check uniqueness of slave's mac address against the other
1110 * slaves in the bond.
1112 if (memcmp(slave->perm_hwaddr, bond->dev->dev_addr, ETH_ALEN)) {
1113 bond_for_each_slave(bond, tmp_slave1, i) {
1114 if (!memcmp(tmp_slave1->dev->dev_addr, slave->dev->dev_addr,
1124 /* Try setting slave mac to bond address and fall-through
1125 to code handling that situation below... */
1126 alb_set_slave_mac_addr(slave, bond->dev->dev_addr,
1127 bond->alb_info.rlb_enabled);
1130 /* The slave's address is equal to the address of the bond.
1131 * Search for a spare address in the bond for this slave.
1133 free_mac_slave = NULL;
1135 bond_for_each_slave(bond, tmp_slave1, i) {
1137 bond_for_each_slave(bond, tmp_slave2, j) {
1138 if (!memcmp(tmp_slave1->perm_hwaddr,
1139 tmp_slave2->dev->dev_addr,
1147 /* no slave has tmp_slave1's perm addr
1150 free_mac_slave = tmp_slave1;
1154 if (!has_bond_addr) {
1155 if (!memcmp(tmp_slave1->dev->dev_addr,
1156 bond->dev->dev_addr,
1159 has_bond_addr = tmp_slave1;
1164 if (free_mac_slave) {
1165 alb_set_slave_mac_addr(slave, free_mac_slave->perm_hwaddr,
1166 bond->alb_info.rlb_enabled);
1168 printk(KERN_WARNING DRV_NAME
1169 ": %s: Warning: the hw address of slave %s is in use by "
1170 "the bond; giving it the hw address of %s\n",
1171 bond->dev->name, slave->dev->name, free_mac_slave->dev->name);
1173 } else if (has_bond_addr) {
1174 printk(KERN_ERR DRV_NAME
1175 ": %s: Error: the hw address of slave %s is in use by the "
1176 "bond; couldn't find a slave with a free hw address to "
1177 "give it (this should not have happened)\n",
1178 bond->dev->name, slave->dev->name);
1186 * alb_set_mac_address
1190 * In TLB mode all slaves are configured to the bond's hw address, but set
1191 * their dev_addr field to different addresses (based on their permanent hw
1194 * For each slave, this function sets the interface to the new address and then
1195 * changes its dev_addr field to its previous value.
1197 * Unwinding assumes bond's mac address has not yet changed.
1199 static int alb_set_mac_address(struct bonding *bond, void *addr)
1202 struct slave *slave, *stop_at;
1203 char tmp_addr[ETH_ALEN];
1207 if (bond->alb_info.rlb_enabled) {
1211 bond_for_each_slave(bond, slave, i) {
1212 if (slave->dev->set_mac_address == NULL) {
1217 /* save net_device's current hw address */
1218 memcpy(tmp_addr, slave->dev->dev_addr, ETH_ALEN);
1220 res = dev_set_mac_address(slave->dev, addr);
1222 /* restore net_device's hw address */
1223 memcpy(slave->dev->dev_addr, tmp_addr, ETH_ALEN);
1233 memcpy(sa.sa_data, bond->dev->dev_addr, bond->dev->addr_len);
1234 sa.sa_family = bond->dev->type;
1236 /* unwind from head to the slave that failed */
1238 bond_for_each_slave_from_to(bond, slave, i, bond->first_slave, stop_at) {
1239 memcpy(tmp_addr, slave->dev->dev_addr, ETH_ALEN);
1240 dev_set_mac_address(slave->dev, &sa);
1241 memcpy(slave->dev->dev_addr, tmp_addr, ETH_ALEN);
1247 /************************ exported alb funcions ************************/
1249 int bond_alb_initialize(struct bonding *bond, int rlb_enabled)
1253 res = tlb_initialize(bond);
1259 bond->alb_info.rlb_enabled = 1;
1260 /* initialize rlb */
1261 res = rlb_initialize(bond);
1263 tlb_deinitialize(bond);
1267 bond->alb_info.rlb_enabled = 0;
1273 void bond_alb_deinitialize(struct bonding *bond)
1275 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
1277 tlb_deinitialize(bond);
1279 if (bond_info->rlb_enabled) {
1280 rlb_deinitialize(bond);
1284 int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev)
1286 struct bonding *bond = bond_dev->priv;
1287 struct ethhdr *eth_data;
1288 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
1289 struct slave *tx_slave = NULL;
1290 static const __be32 ip_bcast = htonl(0xffffffff);
1292 int do_tx_balance = 1;
1294 const u8 *hash_start = NULL;
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 if (memcmp(eth_data->h_dest, mac_bcast, ETH_ALEN) == 0) {
1330 hash_start = (char *)&(ipv6_hdr(skb)->daddr);
1331 hash_size = sizeof(ipv6_hdr(skb)->daddr);
1334 if (ipx_hdr(skb)->ipx_checksum != IPX_NO_CHECKSUM) {
1335 /* something is wrong with this packet */
1340 if (ipx_hdr(skb)->ipx_type != IPX_TYPE_NCP) {
1341 /* The only protocol worth balancing in
1342 * this family since it has an "ARP" like
1349 hash_start = (char*)eth_data->h_dest;
1350 hash_size = ETH_ALEN;
1354 if (bond_info->rlb_enabled) {
1355 tx_slave = rlb_arp_xmit(skb, bond);
1363 if (do_tx_balance) {
1364 hash_index = _simple_hash(hash_start, hash_size);
1365 tx_slave = tlb_choose_channel(bond, hash_index, skb->len);
1369 /* unbalanced or unassigned, send through primary */
1370 tx_slave = bond->curr_active_slave;
1371 bond_info->unbalanced_load += skb->len;
1374 if (tx_slave && SLAVE_IS_OK(tx_slave)) {
1375 if (tx_slave != bond->curr_active_slave) {
1376 memcpy(eth_data->h_source,
1377 tx_slave->dev->dev_addr,
1381 res = bond_dev_queue_xmit(bond, skb, tx_slave->dev);
1384 tlb_clear_slave(bond, tx_slave, 0);
1390 /* no suitable interface, frame not sent */
1393 read_unlock(&bond->curr_slave_lock);
1394 read_unlock(&bond->lock);
1398 void bond_alb_monitor(struct work_struct *work)
1400 struct bonding *bond = container_of(work, struct bonding,
1402 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
1403 struct slave *slave;
1406 read_lock(&bond->lock);
1408 if (bond->kill_timers) {
1412 if (bond->slave_cnt == 0) {
1413 bond_info->tx_rebalance_counter = 0;
1414 bond_info->lp_counter = 0;
1418 bond_info->tx_rebalance_counter++;
1419 bond_info->lp_counter++;
1421 /* send learning packets */
1422 if (bond_info->lp_counter >= BOND_ALB_LP_TICKS) {
1423 /* change of curr_active_slave involves swapping of mac addresses.
1424 * in order to avoid this swapping from happening while
1425 * sending the learning packets, the curr_slave_lock must be held for
1428 read_lock(&bond->curr_slave_lock);
1430 bond_for_each_slave(bond, slave, i) {
1431 alb_send_learning_packets(slave, slave->dev->dev_addr);
1434 read_unlock(&bond->curr_slave_lock);
1436 bond_info->lp_counter = 0;
1439 /* rebalance tx traffic */
1440 if (bond_info->tx_rebalance_counter >= BOND_TLB_REBALANCE_TICKS) {
1442 read_lock(&bond->curr_slave_lock);
1444 bond_for_each_slave(bond, slave, i) {
1445 tlb_clear_slave(bond, slave, 1);
1446 if (slave == bond->curr_active_slave) {
1447 SLAVE_TLB_INFO(slave).load =
1448 bond_info->unbalanced_load /
1449 BOND_TLB_REBALANCE_INTERVAL;
1450 bond_info->unbalanced_load = 0;
1454 read_unlock(&bond->curr_slave_lock);
1456 bond_info->tx_rebalance_counter = 0;
1459 /* handle rlb stuff */
1460 if (bond_info->rlb_enabled) {
1461 if (bond_info->primary_is_promisc &&
1462 (++bond_info->rlb_promisc_timeout_counter >= RLB_PROMISC_TIMEOUT)) {
1465 * dev_set_promiscuity requires rtnl and
1468 read_unlock(&bond->lock);
1471 bond_info->rlb_promisc_timeout_counter = 0;
1473 /* If the primary was set to promiscuous mode
1474 * because a slave was disabled then
1475 * it can now leave promiscuous mode.
1477 dev_set_promiscuity(bond->curr_active_slave->dev, -1);
1478 bond_info->primary_is_promisc = 0;
1481 read_lock(&bond->lock);
1484 if (bond_info->rlb_rebalance) {
1485 bond_info->rlb_rebalance = 0;
1486 rlb_rebalance(bond);
1489 /* check if clients need updating */
1490 if (bond_info->rx_ntt) {
1491 if (bond_info->rlb_update_delay_counter) {
1492 --bond_info->rlb_update_delay_counter;
1494 rlb_update_rx_clients(bond);
1495 if (bond_info->rlb_update_retry_counter) {
1496 --bond_info->rlb_update_retry_counter;
1498 bond_info->rx_ntt = 0;
1505 queue_delayed_work(bond->wq, &bond->alb_work, alb_delta_in_ticks);
1507 read_unlock(&bond->lock);
1510 /* assumption: called before the slave is attached to the bond
1511 * and not locked by the bond lock
1513 int bond_alb_init_slave(struct bonding *bond, struct slave *slave)
1517 res = alb_set_slave_mac_addr(slave, slave->perm_hwaddr,
1518 bond->alb_info.rlb_enabled);
1523 /* caller must hold the bond lock for write since the mac addresses
1524 * are compared and may be swapped.
1526 read_lock(&bond->lock);
1528 res = alb_handle_addr_collision_on_attach(bond, slave);
1530 read_unlock(&bond->lock);
1536 tlb_init_slave(slave);
1538 /* order a rebalance ASAP */
1539 bond->alb_info.tx_rebalance_counter = BOND_TLB_REBALANCE_TICKS;
1541 if (bond->alb_info.rlb_enabled) {
1542 bond->alb_info.rlb_rebalance = 1;
1549 * Remove slave from tlb and rlb hash tables, and fix up MAC addresses
1552 * Caller must hold RTNL and no other locks
1554 void bond_alb_deinit_slave(struct bonding *bond, struct slave *slave)
1556 if (bond->slave_cnt > 1) {
1557 alb_change_hw_addr_on_detach(bond, slave);
1560 tlb_clear_slave(bond, slave, 0);
1562 if (bond->alb_info.rlb_enabled) {
1563 bond->alb_info.next_rx_slave = NULL;
1564 rlb_clear_slave(bond, slave);
1568 /* Caller must hold bond lock for read */
1569 void bond_alb_handle_link_change(struct bonding *bond, struct slave *slave, char link)
1571 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
1573 if (link == BOND_LINK_DOWN) {
1574 tlb_clear_slave(bond, slave, 0);
1575 if (bond->alb_info.rlb_enabled) {
1576 rlb_clear_slave(bond, slave);
1578 } else if (link == BOND_LINK_UP) {
1579 /* order a rebalance ASAP */
1580 bond_info->tx_rebalance_counter = BOND_TLB_REBALANCE_TICKS;
1581 if (bond->alb_info.rlb_enabled) {
1582 bond->alb_info.rlb_rebalance = 1;
1583 /* If the updelay module parameter is smaller than the
1584 * forwarding delay of the switch the rebalance will
1585 * not work because the rebalance arp replies will
1586 * not be forwarded to the clients..
1593 * bond_alb_handle_active_change - assign new curr_active_slave
1594 * @bond: our bonding struct
1595 * @new_slave: new slave to assign
1597 * Set the bond->curr_active_slave to @new_slave and handle
1598 * mac address swapping and promiscuity changes as needed.
1600 * If new_slave is NULL, caller must hold curr_slave_lock or
1601 * bond->lock for write.
1603 * If new_slave is not NULL, caller must hold RTNL, bond->lock for
1604 * read and curr_slave_lock for write. Processing here may sleep, so
1605 * no other locks may be held.
1607 void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave)
1609 struct slave *swap_slave;
1612 if (bond->curr_active_slave == new_slave) {
1616 if (bond->curr_active_slave && bond->alb_info.primary_is_promisc) {
1617 dev_set_promiscuity(bond->curr_active_slave->dev, -1);
1618 bond->alb_info.primary_is_promisc = 0;
1619 bond->alb_info.rlb_promisc_timeout_counter = 0;
1622 swap_slave = bond->curr_active_slave;
1623 bond->curr_active_slave = new_slave;
1625 if (!new_slave || (bond->slave_cnt == 0)) {
1629 /* set the new curr_active_slave to the bonds mac address
1630 * i.e. swap mac addresses of old curr_active_slave and new curr_active_slave
1633 struct slave *tmp_slave;
1634 /* find slave that is holding the bond's mac address */
1635 bond_for_each_slave(bond, tmp_slave, i) {
1636 if (!memcmp(tmp_slave->dev->dev_addr,
1637 bond->dev->dev_addr, ETH_ALEN)) {
1638 swap_slave = tmp_slave;
1645 * Arrange for swap_slave and new_slave to temporarily be
1646 * ignored so we can mess with their MAC addresses without
1647 * fear of interference from transmit activity.
1650 tlb_clear_slave(bond, swap_slave, 1);
1652 tlb_clear_slave(bond, new_slave, 1);
1654 write_unlock_bh(&bond->curr_slave_lock);
1655 read_unlock(&bond->lock);
1659 /* curr_active_slave must be set before calling alb_swap_mac_addr */
1661 /* swap mac address */
1662 alb_swap_mac_addr(bond, swap_slave, new_slave);
1664 /* set the new_slave to the bond mac address */
1665 alb_set_slave_mac_addr(new_slave, bond->dev->dev_addr,
1666 bond->alb_info.rlb_enabled);
1670 alb_fasten_mac_swap(bond, swap_slave, new_slave);
1671 read_lock(&bond->lock);
1673 read_lock(&bond->lock);
1674 alb_send_learning_packets(new_slave, bond->dev->dev_addr);
1677 write_lock_bh(&bond->curr_slave_lock);
1683 int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr)
1685 struct bonding *bond = bond_dev->priv;
1686 struct sockaddr *sa = addr;
1687 struct slave *slave, *swap_slave;
1691 if (!is_valid_ether_addr(sa->sa_data)) {
1692 return -EADDRNOTAVAIL;
1695 res = alb_set_mac_address(bond, addr);
1700 memcpy(bond_dev->dev_addr, sa->sa_data, bond_dev->addr_len);
1702 /* If there is no curr_active_slave there is nothing else to do.
1703 * Otherwise we'll need to pass the new address to it and handle
1706 if (!bond->curr_active_slave) {
1712 bond_for_each_slave(bond, slave, i) {
1713 if (!memcmp(slave->dev->dev_addr, bond_dev->dev_addr, ETH_ALEN)) {
1720 alb_swap_mac_addr(bond, swap_slave, bond->curr_active_slave);
1721 alb_fasten_mac_swap(bond, swap_slave, bond->curr_active_slave);
1723 alb_set_slave_mac_addr(bond->curr_active_slave, bond_dev->dev_addr,
1724 bond->alb_info.rlb_enabled);
1726 read_lock(&bond->lock);
1727 alb_send_learning_packets(bond->curr_active_slave, bond_dev->dev_addr);
1728 if (bond->alb_info.rlb_enabled) {
1729 /* inform clients mac address has changed */
1730 rlb_req_update_slave_clients(bond, bond->curr_active_slave);
1732 read_unlock(&bond->lock);
1738 void bond_alb_clear_vlan(struct bonding *bond, unsigned short vlan_id)
1740 if (bond->alb_info.current_alb_vlan &&
1741 (bond->alb_info.current_alb_vlan->vlan_id == vlan_id)) {
1742 bond->alb_info.current_alb_vlan = NULL;
1745 if (bond->alb_info.rlb_enabled) {
1746 rlb_clear_vlan(bond, vlan_id);