]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/bonding/bond_alb.c
bonding: fix panic when taking bond interface down before removing module
[linux-2.6-omap-h63xx.git] / drivers / net / bonding / bond_alb.c
index 3d39278a63e31fc9200395924cb0fa7d78301b37..87437c788476ab8a05df31a0f7fd1887ffeef497 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/in.h>
 #include <net/ipx.h>
 #include <net/arp.h>
+#include <net/ipv6.h>
 #include <asm/byteorder.h>
 #include "bonding.h"
 #include "bond_alb.h"
@@ -81,6 +82,7 @@
 #define RLB_PROMISC_TIMEOUT    10*ALB_TIMER_TICKS_PER_SEC
 
 static const u8 mac_bcast[ETH_ALEN] = {0xff,0xff,0xff,0xff,0xff,0xff};
+static const u8 mac_v6_allmcast[ETH_ALEN] = {0x33,0x33,0x00,0x00,0x00,0x01};
 static const int alb_delta_in_ticks = HZ / ALB_TIMER_TICKS_PER_SEC;
 
 #pragma pack(1)
@@ -167,11 +169,14 @@ static void tlb_clear_slave(struct bonding *bond, struct slave *slave, int save_
        /* clear slave from tx_hashtbl */
        tx_hash_table = BOND_ALB_INFO(bond).tx_hashtbl;
 
-       index = SLAVE_TLB_INFO(slave).head;
-       while (index != TLB_NULL_INDEX) {
-               u32 next_index = tx_hash_table[index].next;
-               tlb_init_table_entry(&tx_hash_table[index], save_load);
-               index = next_index;
+       /* skip this if we've already freed the tx hash table */
+       if (tx_hash_table) {
+               index = SLAVE_TLB_INFO(slave).head;
+               while (index != TLB_NULL_INDEX) {
+                       u32 next_index = tx_hash_table[index].next;
+                       tlb_init_table_entry(&tx_hash_table[index], save_load);
+                       index = next_index;
+               }
        }
 
        tlb_init_slave(slave);
@@ -1290,6 +1295,7 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev)
        u32 hash_index = 0;
        const u8 *hash_start = NULL;
        int res = 1;
+       struct ipv6hdr *ip6hdr;
 
        skb_reset_mac_header(skb);
        eth_data = eth_hdr(skb);
@@ -1319,11 +1325,32 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev)
        }
                break;
        case ETH_P_IPV6:
+               /* IPv6 doesn't really use broadcast mac address, but leave
+                * that here just in case.
+                */
                if (memcmp(eth_data->h_dest, mac_bcast, ETH_ALEN) == 0) {
                        do_tx_balance = 0;
                        break;
                }
 
+               /* IPv6 uses all-nodes multicast as an equivalent to
+                * broadcasts in IPv4.
+                */
+               if (memcmp(eth_data->h_dest, mac_v6_allmcast, ETH_ALEN) == 0) {
+                       do_tx_balance = 0;
+                       break;
+               }
+
+               /* Additianally, DAD probes should not be tx-balanced as that
+                * will lead to false positives for duplicate addresses and
+                * prevent address configuration from working.
+                */
+               ip6hdr = ipv6_hdr(skb);
+               if (ipv6_addr_any(&ip6hdr->saddr)) {
+                       do_tx_balance = 0;
+                       break;
+               }
+
                hash_start = (char *)&(ipv6_hdr(skb)->daddr);
                hash_size = sizeof(ipv6_hdr(skb)->daddr);
                break;