Merge branch 'for-next' into for-linus
[safe/jmp/linux-2.6] / net / mac80211 / mesh_plink.c
index 8a54bc8..1a29c4a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008 open80211s Ltd.
+ * Copyright (c) 2008, 2009 open80211s Ltd.
  * Author:     Luis Carlos Cobo <luisca@cozybit.com>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -102,7 +102,7 @@ static struct sta_info *mesh_plink_alloc(struct ieee80211_sub_if_data *sdata,
        if (local->num_sta >= MESH_MAX_PLINKS)
                return NULL;
 
-       sta = sta_info_alloc(sdata, hw_addr, GFP_ATOMIC);
+       sta = sta_info_alloc(sdata, hw_addr, GFP_KERNEL);
        if (!sta)
                return NULL;
 
@@ -169,7 +169,7 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
        mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
                                          IEEE80211_STYPE_ACTION);
        memcpy(mgmt->da, da, ETH_ALEN);
-       memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN);
+       memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
        /* BSSID is left zeroed, wildcard value */
        mgmt->u.action.category = MESH_PLINK_CATEGORY;
        mgmt->u.action.u.plink_action.action_code = action;
@@ -181,7 +181,8 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
                if (action == PLINK_CONFIRM) {
                        pos = skb_put(skb, 4);
                        /* two-byte status code followed by two-byte AID */
-                       memset(pos, 0, 4);
+                       memset(pos, 0, 2);
+                       memcpy(pos + 2, &plid, 2);
                }
                mesh_mgmt_ies_add(skb, sdata);
        }
@@ -221,7 +222,7 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
                memcpy(pos, &reason, 2);
        }
 
-       ieee80211_tx_skb(sdata, skb, 1);
+       ieee80211_tx_skb(sdata, skb);
        return 0;
 }
 
@@ -233,14 +234,14 @@ void mesh_neighbour_update(u8 *hw_addr, u32 rates, struct ieee80211_sub_if_data
 
        rcu_read_lock();
 
-       sta = sta_info_get(local, hw_addr);
+       sta = sta_info_get(sdata, hw_addr);
        if (!sta) {
+               rcu_read_unlock();
+
                sta = mesh_plink_alloc(sdata, hw_addr, rates);
-               if (!sta) {
-                       rcu_read_unlock();
+               if (!sta)
                        return;
-               }
-               if (sta_info_insert(sta)) {
+               if (sta_info_insert_rcu(sta)) {
                        rcu_read_unlock();
                        return;
                }
@@ -398,6 +399,17 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_m
        u8 ie_len;
        u8 *baseaddr;
        __le16 plid, llid, reason;
+#ifdef CONFIG_MAC80211_VERBOSE_MPL_DEBUG
+       static const char *mplstates[] = {
+               [PLINK_LISTEN] = "LISTEN",
+               [PLINK_OPN_SNT] = "OPN-SNT",
+               [PLINK_OPN_RCVD] = "OPN-RCVD",
+               [PLINK_CNF_RCVD] = "CNF_RCVD",
+               [PLINK_ESTAB] = "ESTAB",
+               [PLINK_HOLDING] = "HOLDING",
+               [PLINK_BLOCKED] = "BLOCKED"
+       };
+#endif
 
        /* need action_code, aux */
        if (len < IEEE80211_MIN_ACTION_SIZE + 3)
@@ -443,7 +455,7 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_m
 
        rcu_read_lock();
 
-       sta = sta_info_get(local, mgmt->sa);
+       sta = sta_info_get(sdata, mgmt->sa);
        if (!sta && ftype != PLINK_OPEN) {
                mpl_dbg("Mesh plink: cls or cnf from unknown peer\n");
                rcu_read_unlock();
@@ -473,9 +485,11 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_m
        } else if (!sta) {
                /* ftype == PLINK_OPEN */
                u32 rates;
+
+               rcu_read_unlock();
+
                if (!mesh_plink_free_count(sdata)) {
                        mpl_dbg("Mesh plink error: no more free plinks\n");
-                       rcu_read_unlock();
                        return;
                }
 
@@ -483,10 +497,9 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_m
                sta = mesh_plink_alloc(sdata, mgmt->sa, rates);
                if (!sta) {
                        mpl_dbg("Mesh plink error: plink table full\n");
-                       rcu_read_unlock();
                        return;
                }
-               if (sta_info_insert(sta)) {
+               if (sta_info_insert_rcu(sta)) {
                        rcu_read_unlock();
                        return;
                }
@@ -536,8 +549,8 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_m
                }
        }
 
-       mpl_dbg("Mesh plink (peer, state, llid, plid, event): %pM %d %d %d %d\n",
-               mgmt->sa, sta->plink_state,
+       mpl_dbg("Mesh plink (peer, state, llid, plid, event): %pM %s %d %d %d\n",
+               mgmt->sa, mplstates[sta->plink_state],
                le16_to_cpu(sta->llid), le16_to_cpu(sta->plid),
                event);
        reason = 0;
@@ -731,7 +744,7 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_m
                break;
        default:
                /* should not get here, PLINK_BLOCKED is dealt with at the
-                * beggining of the function
+                * beginning of the function
                 */
                spin_unlock_bh(&sta->lock);
                break;