Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wirel...
[safe/jmp/linux-2.6] / net / mac80211 / mesh.c
index 9e47725..e0bd85e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008 open80211s Ltd.
+ * Copyright (c) 2008, 2009 open80211s Ltd.
  * Authors:    Luis Carlos Cobo <luisca@cozybit.com>
  *            Javier Cardona <javier@cozybit.com>
  *
 
 #define IEEE80211_MESH_PEER_INACTIVITY_LIMIT (1800 * HZ)
 #define IEEE80211_MESH_HOUSEKEEPING_INTERVAL (60 * HZ)
+#define IEEE80211_MESH_RANN_INTERVAL        (1 * HZ)
 
-#define PP_OFFSET      1               /* Path Selection Protocol */
-#define PM_OFFSET      5               /* Path Selection Metric   */
-#define CC_OFFSET      9               /* Congestion Control Mode */
-#define CAPAB_OFFSET 17
-#define ACCEPT_PLINKS 0x80
+#define MESHCONF_CAPAB_ACCEPT_PLINKS 0x01
+#define MESHCONF_CAPAB_FORWARDING    0x08
+
+#define TMR_RUNNING_HK 0
+#define TMR_RUNNING_MP 1
+#define TMR_RUNNING_MPR        2
 
 int mesh_allocated;
 static struct kmem_cache *rm_cache;
@@ -44,8 +46,14 @@ static void ieee80211_mesh_housekeeping_timer(unsigned long data)
        struct ieee80211_local *local = sdata->local;
        struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
 
-       ifmsh->housekeeping = true;
-       queue_work(local->hw.workqueue, &ifmsh->work);
+       set_bit(MESH_WORK_HOUSEKEEPING, &ifmsh->wrkq_flags);
+
+       if (local->quiescing) {
+               set_bit(TMR_RUNNING_HK, &ifmsh->timers_running);
+               return;
+       }
+
+       ieee80211_queue_work(&local->hw, &ifmsh->work);
 }
 
 /**
@@ -73,9 +81,11 @@ bool mesh_matches_local(struct ieee802_11_elems *ie, struct ieee80211_sub_if_dat
         */
        if (ifmsh->mesh_id_len == ie->mesh_id_len &&
                memcmp(ifmsh->mesh_id, ie->mesh_id, ie->mesh_id_len) == 0 &&
-               memcmp(ifmsh->mesh_pp_id, ie->mesh_config + PP_OFFSET, 4) == 0 &&
-               memcmp(ifmsh->mesh_pm_id, ie->mesh_config + PM_OFFSET, 4) == 0 &&
-               memcmp(ifmsh->mesh_cc_id, ie->mesh_config + CC_OFFSET, 4) == 0)
+               (ifmsh->mesh_pp_id == ie->mesh_config->meshconf_psel) &&
+               (ifmsh->mesh_pm_id == ie->mesh_config->meshconf_pmetric) &&
+               (ifmsh->mesh_cc_id == ie->mesh_config->meshconf_congest) &&
+               (ifmsh->mesh_sp_id == ie->mesh_config->meshconf_synch) &&
+               (ifmsh->mesh_auth_id == ie->mesh_config->meshconf_auth))
                return true;
 
        return false;
@@ -88,7 +98,8 @@ bool mesh_matches_local(struct ieee802_11_elems *ie, struct ieee80211_sub_if_dat
  */
 bool mesh_peer_accepts_plinks(struct ieee802_11_elems *ie)
 {
-       return (*(ie->mesh_config + CAPAB_OFFSET) & ACCEPT_PLINKS) != 0;
+       return (ie->mesh_config->meshconf_cap &
+           MESHCONF_CAPAB_ACCEPT_PLINKS) != 0;
 }
 
 /**
@@ -114,11 +125,11 @@ void mesh_accept_plinks_update(struct ieee80211_sub_if_data *sdata)
 
 void mesh_ids_set_default(struct ieee80211_if_mesh *sta)
 {
-       u8 def_id[4] = {0x00, 0x0F, 0xAC, 0xff};
-
-       memcpy(sta->mesh_pp_id, def_id, 4);
-       memcpy(sta->mesh_pm_id, def_id, 4);
-       memcpy(sta->mesh_cc_id, def_id, 4);
+       sta->mesh_pp_id = 0;    /* HWMP */
+       sta->mesh_pm_id = 0;    /* Airtime */
+       sta->mesh_cc_id = 0;    /* Disabled */
+       sta->mesh_sp_id = 0;    /* Neighbor Offset */
+       sta->mesh_auth_id = 0;  /* Disabled */
 }
 
 int mesh_rmc_init(struct ieee80211_sub_if_data *sdata)
@@ -184,8 +195,8 @@ int mesh_rmc_check(u8 *sa, struct ieee80211s_hdr *mesh_hdr,
                        list_del(&p->list);
                        kmem_cache_free(rm_cache, p);
                        --entries;
-               } else if ((seqnum == p->seqnum)
-                               && (memcmp(sa, p->sa, ETH_ALEN) == 0))
+               } else if ((seqnum == p->seqnum) &&
+                          (memcmp(sa, p->sa, ETH_ALEN) == 0))
                        return -1;
        }
 
@@ -207,6 +218,7 @@ void mesh_mgmt_ies_add(struct sk_buff *skb, struct ieee80211_sub_if_data *sdata)
        struct ieee80211_supported_band *sband;
        u8 *pos;
        int len, i, rate;
+       u8 neighbors;
 
        sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
        len = sband->n_bitrates;
@@ -230,39 +242,49 @@ void mesh_mgmt_ies_add(struct sk_buff *skb, struct ieee80211_sub_if_data *sdata)
                }
        }
 
+       if (sband->band == IEEE80211_BAND_2GHZ) {
+               pos = skb_put(skb, 2 + 1);
+               *pos++ = WLAN_EID_DS_PARAMS;
+               *pos++ = 1;
+               *pos++ = ieee80211_frequency_to_channel(local->hw.conf.channel->center_freq);
+       }
+
        pos = skb_put(skb, 2 + sdata->u.mesh.mesh_id_len);
        *pos++ = WLAN_EID_MESH_ID;
        *pos++ = sdata->u.mesh.mesh_id_len;
        if (sdata->u.mesh.mesh_id_len)
                memcpy(pos, sdata->u.mesh.mesh_id, sdata->u.mesh.mesh_id_len);
 
-       pos = skb_put(skb, 21);
+       pos = skb_put(skb, 2 + sizeof(struct ieee80211_meshconf_ie));
        *pos++ = WLAN_EID_MESH_CONFIG;
-       *pos++ = MESH_CFG_LEN;
-       /* Version */
-       *pos++ = 1;
+       *pos++ = sizeof(struct ieee80211_meshconf_ie);
 
        /* Active path selection protocol ID */
-       memcpy(pos, sdata->u.mesh.mesh_pp_id, 4);
-       pos += 4;
+       *pos++ = sdata->u.mesh.mesh_pp_id;
 
        /* Active path selection metric ID   */
-       memcpy(pos, sdata->u.mesh.mesh_pm_id, 4);
-       pos += 4;
+       *pos++ = sdata->u.mesh.mesh_pm_id;
 
        /* Congestion control mode identifier */
-       memcpy(pos, sdata->u.mesh.mesh_cc_id, 4);
-       pos += 4;
+       *pos++ = sdata->u.mesh.mesh_cc_id;
 
-       /* Channel precedence:
-        * Not running simple channel unification protocol
-        */
-       memset(pos, 0x00, 4);
-       pos += 4;
+       /* Synchronization protocol identifier */
+       *pos++ = sdata->u.mesh.mesh_sp_id;
+
+       /* Authentication Protocol identifier */
+       *pos++ = sdata->u.mesh.mesh_auth_id;
+
+       /* Mesh Formation Info - number of neighbors */
+       neighbors = atomic_read(&sdata->u.mesh.mshstats.estab_plinks);
+       /* Number of neighbor mesh STAs or 15 whichever is smaller */
+       neighbors = (neighbors > 15) ? 15 : neighbors;
+       *pos++ = neighbors << 1;
 
        /* Mesh capability */
        sdata->u.mesh.accepting_plinks = mesh_plink_availables(sdata);
-       *pos++ = sdata->u.mesh.accepting_plinks ? ACCEPT_PLINKS : 0x00;
+       *pos = MESHCONF_CAPAB_FORWARDING;
+       *pos++ |= sdata->u.mesh.accepting_plinks ?
+           MESHCONF_CAPAB_ACCEPT_PLINKS : 0x00;
        *pos++ = 0x00;
 
        return;
@@ -275,16 +297,6 @@ u32 mesh_table_hash(u8 *addr, struct ieee80211_sub_if_data *sdata, struct mesh_t
                & tbl->hash_mask;
 }
 
-u8 mesh_id_hash(u8 *mesh_id, int mesh_id_len)
-{
-       if (!mesh_id_len)
-               return 1;
-       else if (mesh_id_len == 1)
-               return (u8) mesh_id[0];
-       else
-               return (u8) (mesh_id[0] + 2 * mesh_id[1]);
-}
-
 struct mesh_table *mesh_table_alloc(int size_order)
 {
        int i;
@@ -321,95 +333,121 @@ 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;
-       struct hlist_node *p, *q;
-       int i;
-
-       mesh_hash = tbl->hash_buckets;
-       for (i = 0; i <= tbl->hash_mask; i++) {
-               spin_lock(&tbl->hashwlock[i]);
-               hlist_for_each_safe(p, q, &mesh_hash[i]) {
-                       tbl->free_node(p, free_leafs);
-                       atomic_dec(&tbl->entries);
-               }
-               spin_unlock(&tbl->hashwlock[i]);
-       }
-       __mesh_table_free(tbl);
-}
 
 static void ieee80211_mesh_path_timer(unsigned long data)
 {
        struct ieee80211_sub_if_data *sdata =
                (struct ieee80211_sub_if_data *) data;
        struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
-       struct ieee80211_local *local = wdev_priv(&sdata->wdev);
+       struct ieee80211_local *local = sdata->local;
 
-       queue_work(local->hw.workqueue, &ifmsh->work);
+       if (local->quiescing) {
+               set_bit(TMR_RUNNING_MP, &ifmsh->timers_running);
+               return;
+       }
+
+       ieee80211_queue_work(&local->hw, &ifmsh->work);
 }
 
-struct mesh_table *mesh_table_grow(struct mesh_table *tbl)
+static void ieee80211_mesh_path_root_timer(unsigned long data)
 {
-       struct mesh_table *newtbl;
-       struct hlist_head *oldhash;
-       struct hlist_node *p, *q;
-       int i;
+       struct ieee80211_sub_if_data *sdata =
+               (struct ieee80211_sub_if_data *) data;
+       struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
+       struct ieee80211_local *local = sdata->local;
 
-       if (atomic_read(&tbl->entries)
-                       < tbl->mean_chain_len * (tbl->hash_mask + 1))
-               goto endgrow;
+       set_bit(MESH_WORK_ROOT, &ifmsh->wrkq_flags);
 
-       newtbl = mesh_table_alloc(tbl->size_order + 1);
-       if (!newtbl)
-               goto endgrow;
-
-       newtbl->free_node = tbl->free_node;
-       newtbl->mean_chain_len = tbl->mean_chain_len;
-       newtbl->copy_node = tbl->copy_node;
-       atomic_set(&newtbl->entries, atomic_read(&tbl->entries));
+       if (local->quiescing) {
+               set_bit(TMR_RUNNING_MPR, &ifmsh->timers_running);
+               return;
+       }
 
-       oldhash = tbl->hash_buckets;
-       for (i = 0; i <= tbl->hash_mask; i++)
-               hlist_for_each(p, &oldhash[i])
-                       if (tbl->copy_node(p, newtbl) < 0)
-                               goto errcopy;
+       ieee80211_queue_work(&local->hw, &ifmsh->work);
+}
 
-       return newtbl;
+void ieee80211_mesh_root_setup(struct ieee80211_if_mesh *ifmsh)
+{
+       if (ifmsh->mshcfg.dot11MeshHWMPRootMode)
+               set_bit(MESH_WORK_ROOT, &ifmsh->wrkq_flags);
+       else {
+               clear_bit(MESH_WORK_ROOT, &ifmsh->wrkq_flags);
+               /* stop running timer */
+               del_timer_sync(&ifmsh->mesh_path_root_timer);
+       }
+}
 
-errcopy:
-       for (i = 0; i <= newtbl->hash_mask; i++) {
-               hlist_for_each_safe(p, q, &newtbl->hash_buckets[i])
-                       tbl->free_node(p, 0);
+/**
+ * ieee80211_fill_mesh_addresses - fill addresses of a locally originated mesh frame
+ * @hdr:       802.11 frame header
+ * @fc:                frame control field
+ * @meshda:    destination address in the mesh
+ * @meshsa:    source address address in the mesh.  Same as TA, as frame is
+ *              locally originated.
+ *
+ * Return the length of the 802.11 (does not include a mesh control header)
+ */
+int ieee80211_fill_mesh_addresses(struct ieee80211_hdr *hdr, __le16 *fc,
+                                 const u8 *meshda, const u8 *meshsa)
+{
+       if (is_multicast_ether_addr(meshda)) {
+               *fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS);
+               /* DA TA SA */
+               memcpy(hdr->addr1, meshda, ETH_ALEN);
+               memcpy(hdr->addr2, meshsa, ETH_ALEN);
+               memcpy(hdr->addr3, meshsa, ETH_ALEN);
+               return 24;
+       } else {
+               *fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS |
+                               IEEE80211_FCTL_TODS);
+               /* RA TA DA SA */
+               memset(hdr->addr1, 0, ETH_ALEN);   /* RA is resolved later */
+               memcpy(hdr->addr2, meshsa, ETH_ALEN);
+               memcpy(hdr->addr3, meshda, ETH_ALEN);
+               memcpy(hdr->addr4, meshsa, ETH_ALEN);
+               return 30;
        }
-       __mesh_table_free(newtbl);
-endgrow:
-       return NULL;
 }
 
 /**
  * ieee80211_new_mesh_header - create a new mesh header
  * @meshhdr:    uninitialized mesh header
  * @sdata:     mesh interface to be used
+ * @addr4:     addr4 of the mesh frame (1st in ae header)
+ *              may be NULL
+ * @addr5:     addr5 of the mesh frame (1st or 2nd in ae header)
+ *              may be NULL unless addr6 is present
+ * @addr6:     addr6 of the mesh frame (2nd or 3rd in ae header)
+ *             may be NULL unless addr5 is present
  *
  * Return the header length.
  */
 int ieee80211_new_mesh_header(struct ieee80211s_hdr *meshhdr,
-               struct ieee80211_sub_if_data *sdata)
+               struct ieee80211_sub_if_data *sdata, char *addr4,
+               char *addr5, char *addr6)
 {
-       meshhdr->flags = 0;
+       int aelen = 0;
+       memset(meshhdr, 0, sizeof(*meshhdr));
        meshhdr->ttl = sdata->u.mesh.mshcfg.dot11MeshTTL;
        put_unaligned(cpu_to_le32(sdata->u.mesh.mesh_seqnum), &meshhdr->seqnum);
        sdata->u.mesh.mesh_seqnum++;
-
-       return 6;
+       if (addr4) {
+               meshhdr->flags |= MESH_FLAGS_AE_A4;
+               aelen += ETH_ALEN;
+               memcpy(meshhdr->eaddr1, addr4, ETH_ALEN);
+       }
+       if (addr5 && addr6) {
+               meshhdr->flags |= MESH_FLAGS_AE_A5_A6;
+               aelen += 2 * ETH_ALEN;
+               if (!addr4) {
+                       memcpy(meshhdr->eaddr1, addr5, ETH_ALEN);
+                       memcpy(meshhdr->eaddr2, addr6, ETH_ALEN);
+               } else {
+                       memcpy(meshhdr->eaddr2, addr5, ETH_ALEN);
+                       memcpy(meshhdr->eaddr3, addr6, ETH_ALEN);
+               }
+       }
+       return 6 + aelen;
 }
 
 static void ieee80211_mesh_housekeeping(struct ieee80211_sub_if_data *sdata,
@@ -419,7 +457,7 @@ static void ieee80211_mesh_housekeeping(struct ieee80211_sub_if_data *sdata,
 
 #ifdef CONFIG_MAC80211_VERBOSE_DEBUG
        printk(KERN_DEBUG "%s: running mesh housekeeping\n",
-              sdata->dev->name);
+              sdata->name);
 #endif
 
        ieee80211_sta_expire(sdata, IEEE80211_MESH_PEER_INACTIVITY_LIMIT);
@@ -427,34 +465,87 @@ static void ieee80211_mesh_housekeeping(struct ieee80211_sub_if_data *sdata,
 
        free_plinks = mesh_plink_availables(sdata);
        if (free_plinks != sdata->u.mesh.accepting_plinks)
-               ieee80211_if_config(sdata, IEEE80211_IFCC_BEACON);
+               ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON);
 
-       ifmsh->housekeeping = false;
        mod_timer(&ifmsh->housekeeping_timer,
                  round_jiffies(jiffies + IEEE80211_MESH_HOUSEKEEPING_INTERVAL));
 }
 
+static void ieee80211_mesh_rootpath(struct ieee80211_sub_if_data *sdata)
+{
+       struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
+
+       mesh_path_tx_root_frame(sdata);
+       mod_timer(&ifmsh->mesh_path_root_timer,
+                 round_jiffies(jiffies + IEEE80211_MESH_RANN_INTERVAL));
+}
+
+#ifdef CONFIG_PM
+void ieee80211_mesh_quiesce(struct ieee80211_sub_if_data *sdata)
+{
+       struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
+
+       /* might restart the timer but that doesn't matter */
+       cancel_work_sync(&ifmsh->work);
+
+       /* use atomic bitops in case both timers fire at the same time */
+
+       if (del_timer_sync(&ifmsh->housekeeping_timer))
+               set_bit(TMR_RUNNING_HK, &ifmsh->timers_running);
+       if (del_timer_sync(&ifmsh->mesh_path_timer))
+               set_bit(TMR_RUNNING_MP, &ifmsh->timers_running);
+       if (del_timer_sync(&ifmsh->mesh_path_root_timer))
+               set_bit(TMR_RUNNING_MPR, &ifmsh->timers_running);
+}
+
+void ieee80211_mesh_restart(struct ieee80211_sub_if_data *sdata)
+{
+       struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
+
+       if (test_and_clear_bit(TMR_RUNNING_HK, &ifmsh->timers_running))
+               add_timer(&ifmsh->housekeeping_timer);
+       if (test_and_clear_bit(TMR_RUNNING_MP, &ifmsh->timers_running))
+               add_timer(&ifmsh->mesh_path_timer);
+       if (test_and_clear_bit(TMR_RUNNING_MPR, &ifmsh->timers_running))
+               add_timer(&ifmsh->mesh_path_root_timer);
+       ieee80211_mesh_root_setup(ifmsh);
+}
+#endif
 
 void ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata)
 {
        struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
        struct ieee80211_local *local = sdata->local;
 
-       ifmsh->housekeeping = true;
-       queue_work(local->hw.workqueue, &ifmsh->work);
-       ieee80211_if_config(sdata, IEEE80211_IFCC_BEACON);
+       set_bit(MESH_WORK_HOUSEKEEPING, &ifmsh->wrkq_flags);
+       ieee80211_mesh_root_setup(ifmsh);
+       ieee80211_queue_work(&local->hw, &ifmsh->work);
+       sdata->vif.bss_conf.beacon_int = MESH_DEFAULT_BEACON_INTERVAL;
+       ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON |
+                                               BSS_CHANGED_BEACON_ENABLED |
+                                               BSS_CHANGED_BEACON_INT);
 }
 
 void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata)
 {
        del_timer_sync(&sdata->u.mesh.housekeeping_timer);
+       del_timer_sync(&sdata->u.mesh.mesh_path_root_timer);
+       /*
+        * If the timer fired while we waited for it, it will have
+        * requeued the work. Now the work will be running again
+        * but will not rearm the timer again because it checks
+        * whether the interface is running, which, at this point,
+        * it no longer is.
+        */
+       cancel_work_sync(&sdata->u.mesh.work);
+
        /*
         * When we get here, the interface is marked down.
         * Call synchronize_rcu() to wait for the RX path
         * should it be using the interface and enqueuing
         * frames at this very time on another CPU.
         */
-       synchronize_rcu();
+       rcu_barrier(); /* Wait for RX path and call_rcu()'s */
        skb_queue_purge(&sdata->u.mesh.skb_queue);
 }
 
@@ -464,17 +555,17 @@ static void ieee80211_mesh_rx_bcn_presp(struct ieee80211_sub_if_data *sdata,
                                        size_t len,
                                        struct ieee80211_rx_status *rx_status)
 {
-       struct ieee80211_local *local= sdata->local;
+       struct ieee80211_local *local = sdata->local;
        struct ieee802_11_elems elems;
        struct ieee80211_channel *channel;
-       u64 supp_rates = 0;
+       u32 supp_rates = 0;
        size_t baselen;
        int freq;
        enum ieee80211_band band = rx_status->band;
 
        /* ignore ProbeResp to foreign address */
        if (stype == IEEE80211_STYPE_PROBE_RESP &&
-           compare_ether_addr(mgmt->da, sdata->dev->dev_addr))
+           compare_ether_addr(mgmt->da, sdata->vif.addr))
                return;
 
        baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
@@ -509,7 +600,7 @@ static void ieee80211_mesh_rx_mgmt_action(struct ieee80211_sub_if_data *sdata,
                                          struct ieee80211_rx_status *rx_status)
 {
        switch (mgmt->u.action.category) {
-       case PLINK_CATEGORY:
+       case MESH_PLINK_CATEGORY:
                mesh_rx_plink_frame(sdata, mgmt, len, rx_status);
                break;
        case MESH_PATH_SEL_CATEGORY:
@@ -528,7 +619,7 @@ static void ieee80211_mesh_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
 
        ifmsh = &sdata->u.mesh;
 
-       rx_status = (struct ieee80211_rx_status *) skb->cb;
+       rx_status = IEEE80211_SKB_RXCB(skb);
        mgmt = (struct ieee80211_mgmt *) skb->data;
        stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
 
@@ -557,7 +648,7 @@ static void ieee80211_mesh_work(struct work_struct *work)
        if (!netif_running(sdata->dev))
                return;
 
-       if (local->sta_sw_scanning || local->sta_hw_scanning)
+       if (local->scanning)
                return;
 
        while ((skb = skb_dequeue(&ifmsh->skb_queue)))
@@ -568,8 +659,17 @@ static void ieee80211_mesh_work(struct work_struct *work)
                       ifmsh->last_preq + msecs_to_jiffies(ifmsh->mshcfg.dot11MeshHWMPpreqMinInterval)))
                mesh_path_start_discovery(sdata);
 
-       if (ifmsh->housekeeping)
+       if (test_and_clear_bit(MESH_WORK_GROW_MPATH_TABLE, &ifmsh->wrkq_flags))
+               mesh_mpath_table_grow();
+
+       if (test_and_clear_bit(MESH_WORK_GROW_MPATH_TABLE, &ifmsh->wrkq_flags))
+               mesh_mpp_table_grow();
+
+       if (test_and_clear_bit(MESH_WORK_HOUSEKEEPING, &ifmsh->wrkq_flags))
                ieee80211_mesh_housekeeping(sdata, ifmsh);
+
+       if (test_and_clear_bit(MESH_WORK_ROOT, &ifmsh->wrkq_flags))
+               ieee80211_mesh_rootpath(sdata);
 }
 
 void ieee80211_mesh_notify_scan_completed(struct ieee80211_local *local)
@@ -579,7 +679,7 @@ void ieee80211_mesh_notify_scan_completed(struct ieee80211_local *local)
        rcu_read_lock();
        list_for_each_entry_rcu(sdata, &local->interfaces, list)
                if (ieee80211_vif_is_mesh(&sdata->vif))
-                       queue_work(local->hw.workqueue, &sdata->u.mesh.work);
+                       ieee80211_queue_work(&local->hw, &sdata->u.mesh.work);
        rcu_read_unlock();
 }
 
@@ -615,7 +715,7 @@ void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata)
                MESH_MIN_DISCOVERY_TIMEOUT;
        ifmsh->accepting_plinks = true;
        ifmsh->preq_id = 0;
-       ifmsh->dsn = 0;
+       ifmsh->sn = 0;
        atomic_set(&ifmsh->mpaths, 0);
        mesh_rmc_init(sdata);
        ifmsh->last_preq = jiffies;
@@ -626,13 +726,15 @@ void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata)
        setup_timer(&ifmsh->mesh_path_timer,
                    ieee80211_mesh_path_timer,
                    (unsigned long) sdata);
+       setup_timer(&ifmsh->mesh_path_root_timer,
+                   ieee80211_mesh_path_root_timer,
+                   (unsigned long) sdata);
        INIT_LIST_HEAD(&ifmsh->preq_queue.list);
        spin_lock_init(&ifmsh->mesh_preq_queue_lock);
 }
 
 ieee80211_rx_result
-ieee80211_mesh_rx_mgmt(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb,
-                      struct ieee80211_rx_status *rx_status)
+ieee80211_mesh_rx_mgmt(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb)
 {
        struct ieee80211_local *local = sdata->local;
        struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
@@ -646,12 +748,14 @@ ieee80211_mesh_rx_mgmt(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb,
        fc = le16_to_cpu(mgmt->frame_control);
 
        switch (fc & IEEE80211_FCTL_STYPE) {
+       case IEEE80211_STYPE_ACTION:
+               if (skb->len < IEEE80211_MIN_ACTION_SIZE)
+                       return RX_DROP_MONITOR;
+               /* fall through */
        case IEEE80211_STYPE_PROBE_RESP:
        case IEEE80211_STYPE_BEACON:
-       case IEEE80211_STYPE_ACTION:
-               memcpy(skb->cb, rx_status, sizeof(*rx_status));
                skb_queue_tail(&ifmsh->skb_queue, skb);
-               queue_work(local->hw.workqueue, &ifmsh->work);
+               ieee80211_queue_work(&local->hw, &ifmsh->work);
                return RX_QUEUED;
        }