]> err.no Git - linux-2.6/blobdiff - net/mac80211/ieee80211_sta.c
the scheduled ieee80211 softmac removal
[linux-2.6] / net / mac80211 / ieee80211_sta.c
index d2dedcb5a954c64fa62a273124452cdc79c42286..8b991ebcbb4ed7b682fd1dbad4663d3a6ca3c466 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/wireless.h>
 #include <linux/random.h>
 #include <linux/etherdevice.h>
+#include <linux/rtnetlink.h>
 #include <net/iw_handler.h>
 #include <asm/types.h>
 
@@ -31,9 +32,7 @@
 #include "ieee80211_i.h"
 #include "ieee80211_rate.h"
 #include "ieee80211_led.h"
-#ifdef CONFIG_MAC80211_MESH
 #include "mesh.h"
-#endif
 
 #define IEEE80211_AUTH_TIMEOUT (HZ / 5)
 #define IEEE80211_AUTH_MAX_TRIES 3
@@ -847,6 +846,8 @@ static void ieee80211_associated(struct net_device *dev,
 
        ifsta->state = IEEE80211_ASSOCIATED;
 
+       rcu_read_lock();
+
        sta = sta_info_get(local, ifsta->bssid);
        if (!sta) {
                printk(KERN_DEBUG "%s: No STA entry for own AP %s\n",
@@ -862,7 +863,7 @@ static void ieee80211_associated(struct net_device *dev,
                                       "range\n",
                                       dev->name, print_mac(mac, ifsta->bssid));
                                disassoc = 1;
-                               sta_info_free(sta);
+                               sta_info_unlink(&sta);
                        } else
                                ieee80211_send_probe_req(dev, ifsta->bssid,
                                                         local->scan_ssid,
@@ -878,8 +879,17 @@ static void ieee80211_associated(struct net_device *dev,
                                                         ifsta->ssid_len);
                        }
                }
-               sta_info_put(sta);
        }
+
+       rcu_read_unlock();
+
+       if (disassoc && sta) {
+               synchronize_rcu();
+               rtnl_lock();
+               sta_info_destroy(sta);
+               rtnl_unlock();
+       }
+
        if (disassoc) {
                ifsta->state = IEEE80211_DISABLED;
                ieee80211_set_associated(dev, ifsta, 0);
@@ -1105,9 +1115,13 @@ static void ieee80211_sta_process_addba_request(struct net_device *dev,
        int ret = -EOPNOTSUPP;
        DECLARE_MAC_BUF(mac);
 
+       rcu_read_lock();
+
        sta = sta_info_get(local, mgmt->sa);
-       if (!sta)
+       if (!sta) {
+               rcu_read_unlock();
                return;
+       }
 
        /* extract session parameters from addba request frame */
        dialog_token = mgmt->u.action.u.addba_req.dialog_token;
@@ -1199,9 +1213,9 @@ end:
        spin_unlock_bh(&sta->ampdu_mlme.ampdu_rx);
 
 end_no_lock:
-       ieee80211_send_addba_resp(sta->dev, sta->addr, tid, dialog_token,
-                               status, 1, buf_size, timeout);
-       sta_info_put(sta);
+       ieee80211_send_addba_resp(sta->sdata->dev, sta->addr, tid,
+                                 dialog_token, status, 1, buf_size, timeout);
+       rcu_read_unlock();
 }
 
 static void ieee80211_sta_process_addba_resp(struct net_device *dev,
@@ -1215,9 +1229,13 @@ static void ieee80211_sta_process_addba_resp(struct net_device *dev,
        u16 tid;
        u8 *state;
 
+       rcu_read_lock();
+
        sta = sta_info_get(local, mgmt->sa);
-       if (!sta)
+       if (!sta) {
+               rcu_read_unlock();
                return;
+       }
 
        capab = le16_to_cpu(mgmt->u.action.u.addba_resp.capab);
        tid = (capab & IEEE80211_ADDBA_PARAM_TID_MASK) >> 2;
@@ -1232,7 +1250,7 @@ static void ieee80211_sta_process_addba_resp(struct net_device *dev,
 #ifdef CONFIG_MAC80211_HT_DEBUG
                printk(KERN_DEBUG "wrong addBA response token, tid %d\n", tid);
 #endif /* CONFIG_MAC80211_HT_DEBUG */
-               sta_info_put(sta);
+               rcu_read_unlock();
                return;
        }
 
@@ -1246,7 +1264,7 @@ static void ieee80211_sta_process_addba_resp(struct net_device *dev,
                        spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx);
                        printk(KERN_DEBUG "state not HT_ADDBA_REQUESTED_MSK:"
                                "%d\n", *state);
-                       sta_info_put(sta);
+                       rcu_read_unlock();
                        return;
                }
 
@@ -1273,7 +1291,7 @@ static void ieee80211_sta_process_addba_resp(struct net_device *dev,
                ieee80211_stop_tx_ba_session(hw, sta->addr, tid,
                                             WLAN_BACK_INITIATOR);
        }
-       sta_info_put(sta);
+       rcu_read_unlock();
 }
 
 void ieee80211_send_delba(struct net_device *dev, const u8 *da, u16 tid,
@@ -1328,16 +1346,20 @@ void ieee80211_sta_stop_rx_ba_session(struct net_device *dev, u8 *ra, u16 tid,
        struct sta_info *sta;
        int ret, i;
 
+       rcu_read_lock();
+
        sta = sta_info_get(local, ra);
-       if (!sta)
+       if (!sta) {
+               rcu_read_unlock();
                return;
+       }
 
        /* check if TID is in operational state */
        spin_lock_bh(&sta->ampdu_mlme.ampdu_rx);
        if (sta->ampdu_mlme.tid_rx[tid].state
                                != HT_AGG_STATE_OPERATIONAL) {
                spin_unlock_bh(&sta->ampdu_mlme.ampdu_rx);
-               sta_info_put(sta);
+               rcu_read_unlock();
                return;
        }
        sta->ampdu_mlme.tid_rx[tid].state =
@@ -1376,7 +1398,7 @@ void ieee80211_sta_stop_rx_ba_session(struct net_device *dev, u8 *ra, u16 tid,
        kfree(sta->ampdu_mlme.tid_rx[tid].reorder_buf);
 
        sta->ampdu_mlme.tid_rx[tid].state = HT_AGG_STATE_IDLE;
-       sta_info_put(sta);
+       rcu_read_unlock();
 }
 
 
@@ -1389,9 +1411,13 @@ static void ieee80211_sta_process_delba(struct net_device *dev,
        u16 initiator;
        DECLARE_MAC_BUF(mac);
 
+       rcu_read_lock();
+
        sta = sta_info_get(local, mgmt->sa);
-       if (!sta)
+       if (!sta) {
+               rcu_read_unlock();
                return;
+       }
 
        params = le16_to_cpu(mgmt->u.action.u.delba.params);
        tid = (params & IEEE80211_DELBA_PARAM_TID_MASK) >> 12;
@@ -1416,7 +1442,7 @@ static void ieee80211_sta_process_delba(struct net_device *dev,
                ieee80211_stop_tx_ba_session(&local->hw, sta->addr, tid,
                                             WLAN_BACK_RECIPIENT);
        }
-       sta_info_put(sta);
+       rcu_read_unlock();
 }
 
 /*
@@ -1428,7 +1454,7 @@ void sta_addba_resp_timer_expired(unsigned long data)
 {
        /* not an elegant detour, but there is no choice as the timer passes
         * only one argument, and both sta_info and TID are needed, so init
-        * flow in sta_info_add gives the TID as data, while the timer_to_id
+        * flow in sta_info_create gives the TID as data, while the timer_to_id
         * array gives the sta through container_of */
        u16 tid = *(int *)data;
        struct sta_info *temp_sta = container_of((void *)data,
@@ -1439,9 +1465,13 @@ void sta_addba_resp_timer_expired(unsigned long data)
        struct sta_info *sta;
        u8 *state;
 
+       rcu_read_lock();
+
        sta = sta_info_get(local, temp_sta->addr);
-       if (!sta)
+       if (!sta) {
+               rcu_read_unlock();
                return;
+       }
 
        state = &sta->ampdu_mlme.tid_tx[tid].state;
        /* check if the TID waits for addBA response */
@@ -1463,7 +1493,7 @@ void sta_addba_resp_timer_expired(unsigned long data)
                                     WLAN_BACK_INITIATOR);
 
 timer_expired_exit:
-       sta_info_put(sta);
+       rcu_read_unlock();
 }
 
 /*
@@ -1475,7 +1505,7 @@ void sta_rx_agg_session_timer_expired(unsigned long data)
 {
        /* not an elegant detour, but there is no choice as the timer passes
         * only one argument, and verious sta_info are needed here, so init
-        * flow in sta_info_add gives the TID as data, while the timer_to_id
+        * flow in sta_info_create gives the TID as data, while the timer_to_id
         * array gives the sta through container_of */
        u8 *ptid = (u8 *)data;
        u8 *timer_to_id = ptid - *ptid;
@@ -1483,8 +1513,8 @@ void sta_rx_agg_session_timer_expired(unsigned long data)
                                         timer_to_tid[0]);
 
        printk(KERN_DEBUG "rx session timer expired on tid %d\n", (u16)*ptid);
-       ieee80211_sta_stop_rx_ba_session(sta->dev, sta->addr, (u16)*ptid,
-                                        WLAN_BACK_TIMER,
+       ieee80211_sta_stop_rx_ba_session(sta->sdata->dev, sta->addr,
+                                        (u16)*ptid, WLAN_BACK_TIMER,
                                         WLAN_REASON_QSTA_TIMEOUT);
 }
 
@@ -1793,14 +1823,19 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
        if (ifsta->assocresp_ies)
                memcpy(ifsta->assocresp_ies, pos, ifsta->assocresp_ies_len);
 
+       rcu_read_lock();
+
        /* Add STA entry for the AP */
        sta = sta_info_get(local, ifsta->bssid);
        if (!sta) {
                struct ieee80211_sta_bss *bss;
-               sta = sta_info_add(local, dev, ifsta->bssid, GFP_KERNEL);
-               if (IS_ERR(sta)) {
-                       printk(KERN_DEBUG "%s: failed to add STA entry for the"
-                              " AP (error %ld)\n", dev->name, PTR_ERR(sta));
+               int err;
+
+               sta = sta_info_alloc(sdata, ifsta->bssid, GFP_ATOMIC);
+               if (!sta) {
+                       printk(KERN_DEBUG "%s: failed to alloc STA entry for"
+                              " the AP\n", dev->name);
+                       rcu_read_unlock();
                        return;
                }
                bss = ieee80211_rx_bss_get(dev, ifsta->bssid,
@@ -1812,9 +1847,27 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
                        sta->last_noise = bss->noise;
                        ieee80211_rx_bss_put(dev, bss);
                }
+
+               err = sta_info_insert(sta);
+               if (err) {
+                       printk(KERN_DEBUG "%s: failed to insert STA entry for"
+                              " the AP (error %d)\n", dev->name, err);
+                       sta_info_destroy(sta);
+                       rcu_read_unlock();
+                       return;
+               }
        }
 
-       sta->dev = dev;
+       /*
+        * FIXME: Do we really need to update the sta_info's information here?
+        *        We already know about the AP (we found it in our list) so it
+        *        should already be filled with the right info, no?
+        *        As is stands, all this is racy because typically we assume
+        *        the information that is filled in here (except flags) doesn't
+        *        change while a STA structure is alive. As such, it should move
+        *        to between the sta_info_alloc() and sta_info_insert() above.
+        */
+
        sta->flags |= WLAN_STA_AUTH | WLAN_STA_ASSOC | WLAN_STA_ASSOC_AP |
                      WLAN_STA_AUTHORIZED;
 
@@ -1877,16 +1930,16 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
 
        if (elems.wmm_param && (ifsta->flags & IEEE80211_STA_WMM_ENABLED)) {
                sta->flags |= WLAN_STA_WME;
+               rcu_read_unlock();
                ieee80211_sta_wmm_params(dev, ifsta, elems.wmm_param,
                                         elems.wmm_param_len);
-       }
+       } else
+               rcu_read_unlock();
 
        /* set AID, ieee80211_set_associated() will tell the driver */
        bss_conf->aid = aid;
        ieee80211_set_associated(dev, ifsta, 1);
 
-       sta_info_put(sta);
-
        ieee80211_associated(dev, ifsta);
 }
 
@@ -1897,12 +1950,13 @@ static void __ieee80211_rx_bss_hash_add(struct net_device *dev,
 {
        struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
        u8 hash_idx;
-#ifdef CONFIG_MAC80211_MESH
-       if (bss->mesh_cfg)
-               hash_idx = mesh_id_hash(bss->mesh_id, bss->mesh_id_len);
+
+       if (bss_mesh_cfg(bss))
+               hash_idx = mesh_id_hash(bss_mesh_id(bss),
+                                       bss_mesh_id_len(bss));
        else
-#endif
                hash_idx = STA_HASH(bss->bssid);
+
        bss->hnext = local->sta_bss_hash[hash_idx];
        local->sta_bss_hash[hash_idx] = bss;
 }
@@ -1967,7 +2021,8 @@ ieee80211_rx_bss_get(struct net_device *dev, u8 *bssid, int freq,
        spin_lock_bh(&local->sta_bss_lock);
        bss = local->sta_bss_hash[STA_HASH(bssid)];
        while (bss) {
-               if (!bss->mesh_cfg && !memcmp(bss->bssid, bssid, ETH_ALEN) &&
+               if (!bss_mesh_cfg(bss) &&
+                   !memcmp(bss->bssid, bssid, ETH_ALEN) &&
                    bss->freq == freq &&
                    bss->ssid_len == ssid_len &&
                    (ssid_len == 0 || !memcmp(bss->ssid, ssid, ssid_len))) {
@@ -1991,8 +2046,8 @@ ieee80211_rx_mesh_bss_get(struct net_device *dev, u8 *mesh_id, int mesh_id_len,
        spin_lock_bh(&local->sta_bss_lock);
        bss = local->sta_bss_hash[mesh_id_hash(mesh_id, mesh_id_len)];
        while (bss) {
-               if (bss->mesh_cfg &&
-                   !memcmp(bss->mesh_cfg, mesh_cfg, MESH_CFG_CMP_LEN) &&
+               if (bss_mesh_cfg(bss) &&
+                   !memcmp(bss_mesh_cfg(bss), mesh_cfg, MESH_CFG_CMP_LEN) &&
                    bss->freq == freq &&
                    mesh_id_len == bss->mesh_id_len &&
                    (mesh_id_len == 0 || !memcmp(bss->mesh_id, mesh_id,
@@ -2053,10 +2108,8 @@ static void ieee80211_rx_bss_free(struct ieee80211_sta_bss *bss)
        kfree(bss->rsn_ie);
        kfree(bss->wmm_ie);
        kfree(bss->ht_ie);
-#ifdef CONFIG_MAC80211_MESH
-       kfree(bss->mesh_id);
-       kfree(bss->mesh_cfg);
-#endif
+       kfree(bss_mesh_id(bss));
+       kfree(bss_mesh_cfg(bss));
        kfree(bss);
 }
 
@@ -2322,16 +2375,16 @@ static void ieee80211_rx_bss_info(struct net_device *dev,
        beacon_timestamp = le64_to_cpu(mgmt->u.beacon.timestamp);
        ieee802_11_parse_elems(mgmt->u.beacon.variable, len - baselen, &elems);
 
-#ifdef CONFIG_MAC80211_MESH
-       if (sdata->vif.type == IEEE80211_IF_TYPE_MESH_POINT && elems.mesh_id
-                       && elems.mesh_config)
-               if (mesh_matches_local(&elems, dev)) {
-                       u64 rates = ieee80211_sta_get_rates(local, &elems,
-                                                       rx_status->band);
-                       mesh_neighbour_update(mgmt->sa, rates, dev,
-                               mesh_peer_accepts_plinks(&elems, dev));
-               }
-#endif
+       if (ieee80211_vif_is_mesh(&sdata->vif) && elems.mesh_id &&
+           elems.mesh_config && mesh_matches_local(&elems, dev)) {
+               u64 rates = ieee80211_sta_get_rates(local, &elems,
+                                               rx_status->band);
+
+               mesh_neighbour_update(mgmt->sa, rates, dev,
+                                     mesh_peer_accepts_plinks(&elems, dev));
+       }
+
+       rcu_read_lock();
 
        if (sdata->vif.type == IEEE80211_IF_TYPE_IBSS && elems.supp_rates &&
            memcmp(mgmt->bssid, sdata->u.sta.bssid, ETH_ALEN) == 0 &&
@@ -2358,9 +2411,10 @@ static void ieee80211_rx_bss_info(struct net_device *dev,
                               (unsigned long long) supp_rates,
                               (unsigned long long) sta->supp_rates[rx_status->band]);
                }
-               sta_info_put(sta);
        }
 
+       rcu_read_unlock();
+
        if (elems.ds_params && elems.ds_params_len == 1)
                freq = ieee80211_channel_to_frequency(elems.ds_params[0]);
        else
@@ -2712,9 +2766,7 @@ static void ieee80211_rx_mgmt_action(struct net_device *dev,
                                     size_t len,
                                     struct ieee80211_rx_status *rx_status)
 {
-#ifdef CONFIG_MAC80211_MESH
        struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
-#endif
 
        if (len < IEEE80211_MIN_ACTION_SIZE)
                return;
@@ -2747,17 +2799,14 @@ static void ieee80211_rx_mgmt_action(struct net_device *dev,
                        break;
                }
                break;
-#ifdef CONFIG_MAC80211_MESH
        case PLINK_CATEGORY:
-               if (sdata->vif.type == IEEE80211_IF_TYPE_MESH_POINT)
+               if (ieee80211_vif_is_mesh(&sdata->vif))
                        mesh_rx_plink_frame(dev, mgmt, len, rx_status);
                break;
-
        case MESH_PATH_SEL_CATEGORY:
-               if (sdata->vif.type == IEEE80211_IF_TYPE_MESH_POINT)
+               if (ieee80211_vif_is_mesh(&sdata->vif))
                        mesh_rx_path_sel_frame(dev, mgmt, len);
                break;
-#endif
        default:
                if (net_ratelimit())
                        printk(KERN_DEBUG "%s: Rx unknown action frame - "
@@ -2902,17 +2951,20 @@ static int ieee80211_sta_active_ibss(struct net_device *dev)
        struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
        int active = 0;
        struct sta_info *sta;
+       struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+
+       rcu_read_lock();
 
-       read_lock_bh(&local->sta_lock);
-       list_for_each_entry(sta, &local->sta_list, list) {
-               if (sta->dev == dev &&
+       list_for_each_entry_rcu(sta, &local->sta_list, list) {
+               if (sta->sdata == sdata &&
                    time_after(sta->last_rx + IEEE80211_IBSS_MERGE_INTERVAL,
                               jiffies)) {
                        active++;
                        break;
                }
        }
-       read_unlock_bh(&local->sta_lock);
+
+       rcu_read_unlock();
 
        return active;
 }
@@ -2924,22 +2976,25 @@ static void ieee80211_sta_expire(struct net_device *dev, unsigned long exp_time)
        struct sta_info *sta, *tmp;
        LIST_HEAD(tmp_list);
        DECLARE_MAC_BUF(mac);
+       unsigned long flags;
 
-       write_lock_bh(&local->sta_lock);
+       spin_lock_irqsave(&local->sta_lock, flags);
        list_for_each_entry_safe(sta, tmp, &local->sta_list, list)
                if (time_after(jiffies, sta->last_rx + exp_time)) {
                        printk(KERN_DEBUG "%s: expiring inactive STA %s\n",
                               dev->name, print_mac(mac, sta->addr));
-                       __sta_info_get(sta);
-                       sta_info_remove(sta);
-                       list_add(&sta->list, &tmp_list);
+                       sta_info_unlink(&sta);
+                       if (sta)
+                               list_add(&sta->list, &tmp_list);
                }
-       write_unlock_bh(&local->sta_lock);
+       spin_unlock_irqrestore(&local->sta_lock, flags);
 
-       list_for_each_entry_safe(sta, tmp, &tmp_list, list) {
-               sta_info_free(sta);
-               sta_info_put(sta);
-       }
+       synchronize_rcu();
+
+       rtnl_lock();
+       list_for_each_entry_safe(sta, tmp, &tmp_list, list)
+               sta_info_destroy(sta);
+       rtnl_unlock();
 }
 
 
@@ -3027,8 +3082,9 @@ void ieee80211_sta_work(struct work_struct *work)
                ieee80211_sta_rx_queued_mgmt(dev, skb);
 
 #ifdef CONFIG_MAC80211_MESH
-       if (ifsta->preq_queue_len && time_after(jiffies, ifsta->last_preq +
-               msecs_to_jiffies(ifsta->mshcfg.dot11MeshHWMPpreqMinInterval)))
+       if (ifsta->preq_queue_len &&
+           time_after(jiffies,
+                      ifsta->last_preq + msecs_to_jiffies(ifsta->mshcfg.dot11MeshHWMPpreqMinInterval)))
                mesh_path_start_discovery(dev);
 #endif
 
@@ -3520,6 +3576,13 @@ static void ieee80211_send_nullfunc(struct ieee80211_local *local,
 }
 
 
+static void ieee80211_restart_sta_timer(struct ieee80211_sub_if_data *sdata)
+{
+       if (sdata->vif.type == IEEE80211_IF_TYPE_STA ||
+           ieee80211_vif_is_mesh(&sdata->vif))
+               ieee80211_sta_timer((unsigned long)sdata);
+}
+
 void ieee80211_scan_completed(struct ieee80211_hw *hw)
 {
        struct ieee80211_local *local = hw_to_local(hw);
@@ -3533,6 +3596,12 @@ void ieee80211_scan_completed(struct ieee80211_hw *hw)
 
        if (local->sta_hw_scanning) {
                local->sta_hw_scanning = 0;
+               /* Restart STA timer for HW scan case */
+               rcu_read_lock();
+               list_for_each_entry_rcu(sdata, &local->interfaces, list)
+                       ieee80211_restart_sta_timer(sdata);
+               rcu_read_unlock();
+
                goto done;
        }
 
@@ -3559,14 +3628,12 @@ void ieee80211_scan_completed(struct ieee80211_hw *hw)
                if (sdata->dev == local->mdev)
                        continue;
 
-               if (sdata->vif.type == IEEE80211_IF_TYPE_STA) {
-                       if (sdata->u.sta.flags & IEEE80211_STA_ASSOCIATED)
-                               ieee80211_send_nullfunc(local, sdata, 0);
-                       ieee80211_sta_timer((unsigned long)sdata);
-               }
+               /* Tell AP we're back */
+               if (sdata->vif.type == IEEE80211_IF_TYPE_STA &&
+                   sdata->u.sta.flags & IEEE80211_STA_ASSOCIATED)
+                       ieee80211_send_nullfunc(local, sdata, 0);
 
-               if (sdata->vif.type == IEEE80211_IF_TYPE_MESH_POINT)
-                       ieee80211_sta_timer((unsigned long)sdata);
+               ieee80211_restart_sta_timer(sdata);
 
                netif_wake_queue(sdata->dev);
        }
@@ -3810,13 +3877,11 @@ ieee80211_sta_scan_result(struct net_device *dev,
 
        memset(&iwe, 0, sizeof(iwe));
        iwe.cmd = SIOCGIWESSID;
-       if (bss->mesh_cfg) {
-#ifdef CONFIG_MAC80211_MESH
-               iwe.u.data.length = bss->mesh_id_len;
+       if (bss_mesh_cfg(bss)) {
+               iwe.u.data.length = bss_mesh_id_len(bss);
                iwe.u.data.flags = 1;
                current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe,
-                                                 bss->mesh_id);
-#endif
+                                                 bss_mesh_id(bss));
        } else {
                iwe.u.data.length = bss->ssid_len;
                iwe.u.data.flags = 1;
@@ -3824,11 +3889,11 @@ ieee80211_sta_scan_result(struct net_device *dev,
                                                  bss->ssid);
        }
 
-       if (bss->capability & (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS
-           || bss->mesh_cfg)) {
+       if (bss->capability & (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS)
+           || bss_mesh_cfg(bss)) {
                memset(&iwe, 0, sizeof(iwe));
                iwe.cmd = SIOCGIWMODE;
-               if (bss->mesh_cfg)
+               if (bss_mesh_cfg(bss))
                        iwe.u.mode = IW_MODE_MESH;
                else if (bss->capability & WLAN_CAPABILITY_ESS)
                        iwe.u.mode = IW_MODE_MASTER;
@@ -3919,21 +3984,38 @@ ieee80211_sta_scan_result(struct net_device *dev,
                }
        }
 
-       if (bss->mesh_cfg) {
+       if (bss_mesh_cfg(bss)) {
                char *buf;
-               u8 *cfg = bss->mesh_cfg;
-               buf = kmalloc(200, GFP_ATOMIC);
+               u8 *cfg = bss_mesh_cfg(bss);
+               buf = kmalloc(50, GFP_ATOMIC);
                if (buf) {
                        memset(&iwe, 0, sizeof(iwe));
                        iwe.cmd = IWEVCUSTOM;
-                       sprintf(buf, "Mesh network (version %d)\n"
-                       "\t\t\tPath Selection Protocol ID: 0x%02X%02X%02X%02X\n"
-                       "\t\t\tPath Selection Metric ID: 0x%02X%02X%02X%02X\n"
-                       "\t\t\tCongestion Control Mode ID: 0x%02X%02X%02X%02X\n"
-                       "\t\t\tChannel Precedence: 0x%02X%02X%02X%02X",
-                       cfg[0], cfg[1], cfg[2], cfg[3], cfg[4], cfg[5], cfg[6],
-                       cfg[7], cfg[8], cfg[9], cfg[10], cfg[11], cfg[12],
-                       cfg[13], cfg[14], cfg[15], cfg[16]);
+                       sprintf(buf, "Mesh network (version %d)", cfg[0]);
+                       iwe.u.data.length = strlen(buf);
+                       current_ev = iwe_stream_add_point(current_ev, end_buf,
+                                                         &iwe, buf);
+                       sprintf(buf, "Path Selection Protocol ID: "
+                               "0x%02X%02X%02X%02X", cfg[1], cfg[2], cfg[3],
+                                                       cfg[4]);
+                       iwe.u.data.length = strlen(buf);
+                       current_ev = iwe_stream_add_point(current_ev, end_buf,
+                                                         &iwe, buf);
+                       sprintf(buf, "Path Selection Metric ID: "
+                               "0x%02X%02X%02X%02X", cfg[5], cfg[6], cfg[7],
+                                                       cfg[8]);
+                       iwe.u.data.length = strlen(buf);
+                       current_ev = iwe_stream_add_point(current_ev, end_buf,
+                                                         &iwe, buf);
+                       sprintf(buf, "Congestion Control Mode ID: "
+                               "0x%02X%02X%02X%02X", cfg[9], cfg[10],
+                                                       cfg[11], cfg[12]);
+                       iwe.u.data.length = strlen(buf);
+                       current_ev = iwe_stream_add_point(current_ev, end_buf,
+                                                         &iwe, buf);
+                       sprintf(buf, "Channel Precedence: "
+                               "0x%02X%02X%02X%02X", cfg[13], cfg[14],
+                                                       cfg[15], cfg[16]);
                        iwe.u.data.length = strlen(buf);
                        current_ev = iwe_stream_add_point(current_ev, end_buf,
                                                          &iwe, buf);
@@ -4009,8 +4091,8 @@ struct sta_info * ieee80211_ibss_add_sta(struct net_device *dev,
        printk(KERN_DEBUG "%s: Adding new IBSS station %s (dev=%s)\n",
               wiphy_name(local->hw.wiphy), print_mac(mac, addr), dev->name);
 
-       sta = sta_info_add(local, dev, addr, GFP_ATOMIC);
-       if (IS_ERR(sta))
+       sta = sta_info_alloc(sdata, addr, GFP_ATOMIC);
+       if (!sta)
                return NULL;
 
        sta->flags |= WLAN_STA_AUTHORIZED;
@@ -4020,7 +4102,12 @@ struct sta_info * ieee80211_ibss_add_sta(struct net_device *dev,
 
        rate_control_rate_init(sta, local);
 
-       return sta; /* caller will call sta_info_put() */
+       if (sta_info_insert(sta)) {
+               sta_info_destroy(sta);
+               return NULL;
+       }
+
+       return sta;
 }