]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/mac80211/mesh.c
net: drop unused BUG_TRAP()
[linux-2.6-omap-h63xx.git] / net / mac80211 / mesh.c
index 594a3356a5082c3c33760c67254cac02133f42fb..b5933b271491551bc10edacdfda4416be6b8125d 100644 (file)
@@ -8,6 +8,7 @@
  * published by the Free Software Foundation.
  */
 
+#include <asm/unaligned.h>
 #include "ieee80211_i.h"
 #include "mesh.h"
 
@@ -167,8 +168,8 @@ int mesh_rmc_check(u8 *sa, struct ieee80211s_hdr *mesh_hdr,
        struct rmc_entry *p, *n;
 
        /* Don't care about endianness since only match matters */
-       memcpy(&seqnum, mesh_hdr->seqnum, sizeof(mesh_hdr->seqnum));
-       idx = mesh_hdr->seqnum[0] & rmc->idx_mask;
+       memcpy(&seqnum, &mesh_hdr->seqnum, sizeof(mesh_hdr->seqnum));
+       idx = le32_to_cpu(mesh_hdr->seqnum) & rmc->idx_mask;
        list_for_each_entry_safe(p, n, &rmc->bucket[idx].list, list) {
                ++entries;
                if (time_after(jiffies, p->exp_time) ||
@@ -314,6 +315,13 @@ struct mesh_table *mesh_table_alloc(int size_order)
        return newtbl;
 }
 
+static void __mesh_table_free(struct mesh_table *tbl)
+{
+       kfree(tbl->hash_buckets);
+       kfree(tbl->hashwlock);
+       kfree(tbl);
+}
+
 void mesh_table_free(struct mesh_table *tbl, bool free_leafs)
 {
        struct hlist_head *mesh_hash;
@@ -329,9 +337,7 @@ void mesh_table_free(struct mesh_table *tbl, bool free_leafs)
                }
                spin_unlock(&tbl->hashwlock[i]);
        }
-       kfree(tbl->hash_buckets);
-       kfree(tbl->hashwlock);
-       kfree(tbl);
+       __mesh_table_free(tbl);
 }
 
 static void ieee80211_mesh_path_timer(unsigned long data)
@@ -348,21 +354,16 @@ struct mesh_table *mesh_table_grow(struct mesh_table *tbl)
 {
        struct mesh_table *newtbl;
        struct hlist_head *oldhash;
-       struct hlist_node *p;
-       int err = 0;
+       struct hlist_node *p, *q;
        int i;
 
        if (atomic_read(&tbl->entries)
-                       < tbl->mean_chain_len * (tbl->hash_mask + 1)) {
-               err = -EPERM;
+                       < tbl->mean_chain_len * (tbl->hash_mask + 1))
                goto endgrow;
-       }
 
        newtbl = mesh_table_alloc(tbl->size_order + 1);
-       if (!newtbl) {
-               err = -ENOMEM;
+       if (!newtbl)
                goto endgrow;
-       }
 
        newtbl->free_node = tbl->free_node;
        newtbl->mean_chain_len = tbl->mean_chain_len;
@@ -372,13 +373,19 @@ struct mesh_table *mesh_table_grow(struct mesh_table *tbl)
        oldhash = tbl->hash_buckets;
        for (i = 0; i <= tbl->hash_mask; i++)
                hlist_for_each(p, &oldhash[i])
-                       tbl->copy_node(p, newtbl);
+                       if (tbl->copy_node(p, newtbl) < 0)
+                               goto errcopy;
 
+       return newtbl;
+
+errcopy:
+       for (i = 0; i <= newtbl->hash_mask; i++) {
+               hlist_for_each_safe(p, q, &newtbl->hash_buckets[i])
+                       tbl->free_node(p, 0);
+       }
+       __mesh_table_free(tbl);
 endgrow:
-       if (err)
-               return NULL;
-       else
-               return newtbl;
+       return NULL;
 }
 
 /**
@@ -393,18 +400,10 @@ int ieee80211_new_mesh_header(struct ieee80211s_hdr *meshhdr,
 {
        meshhdr->flags = 0;
        meshhdr->ttl = sdata->u.sta.mshcfg.dot11MeshTTL;
+       put_unaligned(cpu_to_le32(sdata->u.sta.mesh_seqnum), &meshhdr->seqnum);
+       sdata->u.sta.mesh_seqnum++;
 
-       meshhdr->seqnum[0] = sdata->u.sta.mesh_seqnum[0]++;
-       meshhdr->seqnum[1] = sdata->u.sta.mesh_seqnum[1];
-       meshhdr->seqnum[2] = sdata->u.sta.mesh_seqnum[2];
-
-       if (sdata->u.sta.mesh_seqnum[0] == 0) {
-               sdata->u.sta.mesh_seqnum[1]++;
-               if (sdata->u.sta.mesh_seqnum[1] == 0)
-                       sdata->u.sta.mesh_seqnum[2]++;
-       }
-
-       return 5;
+       return 6;
 }
 
 void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata)