bridge: Forward reserved group addresses if !STP
[pandora-kernel.git] / net / mac80211 / mlme.c
index d7915ab..a3a9421 100644 (file)
@@ -115,7 +115,7 @@ static void run_again(struct ieee80211_if_managed *ifmgd,
                mod_timer(&ifmgd->timer, timeout);
 }
 
-static void mod_beacon_timer(struct ieee80211_sub_if_data *sdata)
+void ieee80211_sta_reset_beacon_monitor(struct ieee80211_sub_if_data *sdata)
 {
        if (sdata->local->hw.flags & IEEE80211_HW_BEACON_FILTER)
                return;
@@ -880,14 +880,6 @@ static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata,
        sdata->u.mgd.flags &= ~(IEEE80211_STA_CONNECTION_POLL |
                                IEEE80211_STA_BEACON_POLL);
 
-       /*
-        * Always handle WMM once after association regardless
-        * of the first value the AP uses. Setting -1 here has
-        * that effect because the AP values is an unsigned
-        * 4-bit value.
-        */
-       sdata->u.mgd.wmm_last_param_set = -1;
-
        ieee80211_led_assoc(local, 1);
 
        if (local->hw.flags & IEEE80211_HW_NEED_DTIM_PERIOD)
@@ -921,7 +913,7 @@ static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata,
 
        mutex_lock(&local->iflist_mtx);
        ieee80211_recalc_ps(local, -1);
-       ieee80211_recalc_smps(local, sdata);
+       ieee80211_recalc_smps(local);
        mutex_unlock(&local->iflist_mtx);
 
        netif_tx_start_all_queues(sdata->dev);
@@ -929,7 +921,7 @@ static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata,
 }
 
 static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
-                                  bool remove_sta)
+                                  bool remove_sta, bool tx)
 {
        struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
        struct ieee80211_local *local = sdata->local;
@@ -968,7 +960,7 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
        sta = sta_info_get(sdata, bssid);
        if (sta) {
                set_sta_flags(sta, WLAN_STA_BLOCK_BA);
-               ieee80211_sta_tear_down_BA_sessions(sta);
+               ieee80211_sta_tear_down_BA_sessions(sta, tx);
        }
        mutex_unlock(&local->sta_mtx);
 
@@ -1038,10 +1030,19 @@ static void ieee80211_mgd_probe_ap_send(struct ieee80211_sub_if_data *sdata)
 {
        struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
        const u8 *ssid;
+       u8 *dst = ifmgd->associated->bssid;
+       u8 unicast_limit = max(1, IEEE80211_MAX_PROBE_TRIES - 3);
+
+       /*
+        * Try sending broadcast probe requests for the last three
+        * probe requests after the first ones failed since some
+        * buggy APs only support broadcast probe requests.
+        */
+       if (ifmgd->probe_send_count >= unicast_limit)
+               dst = NULL;
 
        ssid = ieee80211_bss_get_ie(ifmgd->associated, WLAN_EID_SSID);
-       ieee80211_send_probe_req(sdata, ifmgd->associated->bssid,
-                                ssid + 2, ssid[1], NULL, 0);
+       ieee80211_send_probe_req(sdata, dst, ssid + 2, ssid[1], NULL, 0);
 
        ifmgd->probe_send_count++;
        ifmgd->probe_timeout = jiffies + IEEE80211_PROBE_WAIT;
@@ -1123,7 +1124,7 @@ static void __ieee80211_connection_loss(struct ieee80211_sub_if_data *sdata)
 
        printk(KERN_DEBUG "Connection to AP %pM lost.\n", bssid);
 
-       ieee80211_set_disassoc(sdata, true);
+       ieee80211_set_disassoc(sdata, true, true);
        mutex_unlock(&ifmgd->mtx);
 
        mutex_lock(&local->mtx);
@@ -1196,7 +1197,7 @@ ieee80211_rx_mgmt_deauth(struct ieee80211_sub_if_data *sdata,
        printk(KERN_DEBUG "%s: deauthenticated from %pM (Reason: %u)\n",
                        sdata->name, bssid, reason_code);
 
-       ieee80211_set_disassoc(sdata, true);
+       ieee80211_set_disassoc(sdata, true, false);
        mutex_lock(&sdata->local->mtx);
        ieee80211_recalc_idle(sdata->local);
        mutex_unlock(&sdata->local->mtx);
@@ -1228,7 +1229,7 @@ ieee80211_rx_mgmt_disassoc(struct ieee80211_sub_if_data *sdata,
        printk(KERN_DEBUG "%s: disassociated from %pM (Reason: %u)\n",
                        sdata->name, mgmt->sa, reason_code);
 
-       ieee80211_set_disassoc(sdata, true);
+       ieee80211_set_disassoc(sdata, true, false);
        mutex_lock(&sdata->local->mtx);
        ieee80211_recalc_idle(sdata->local);
        mutex_unlock(&sdata->local->mtx);
@@ -1290,7 +1291,7 @@ static bool ieee80211_assoc_success(struct ieee80211_work *wk,
 
        rates = 0;
        basic_rates = 0;
-       sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
+       sband = local->hw.wiphy->bands[wk->chan->band];
 
        for (i = 0; i < elems.supp_rates_len; i++) {
                int rate = (elems.supp_rates[i] & 0x7f) * 5;
@@ -1326,11 +1327,11 @@ static bool ieee80211_assoc_success(struct ieee80211_work *wk,
                }
        }
 
-       sta->sta.supp_rates[local->hw.conf.channel->band] = rates;
+       sta->sta.supp_rates[wk->chan->band] = rates;
        sdata->vif.bss_conf.basic_rates = basic_rates;
 
        /* cf. IEEE 802.11 9.2.12 */
-       if (local->hw.conf.channel->band == IEEE80211_BAND_2GHZ &&
+       if (wk->chan->band == IEEE80211_BAND_2GHZ &&
            have_higher_than_11mbit)
                sdata->flags |= IEEE80211_SDATA_OPERATING_GMODE;
        else
@@ -1358,6 +1359,14 @@ static bool ieee80211_assoc_success(struct ieee80211_work *wk,
                return false;
        }
 
+       /*
+        * Always handle WMM once after association regardless
+        * of the first value the AP uses. Setting -1 here has
+        * that effect because the AP values is an unsigned
+        * 4-bit value.
+        */
+       ifmgd->wmm_last_param_set = -1;
+
        if (elems.wmm_param)
                ieee80211_sta_wmm_params(local, sdata, elems.wmm_param,
                                         elems.wmm_param_len);
@@ -1390,7 +1399,7 @@ static bool ieee80211_assoc_success(struct ieee80211_work *wk,
         * Also start the timer that will detect beacon loss.
         */
        ieee80211_sta_rx_notify(sdata, (struct ieee80211_hdr *)mgmt);
-       mod_beacon_timer(sdata);
+       ieee80211_sta_reset_beacon_monitor(sdata);
 
        return true;
 }
@@ -1493,7 +1502,7 @@ static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data *sdata,
                 * we have or will be receiving any beacons or data, so let's
                 * schedule the timers again, just in case.
                 */
-               mod_beacon_timer(sdata);
+               ieee80211_sta_reset_beacon_monitor(sdata);
 
                mod_timer(&ifmgd->conn_mon_timer,
                          round_jiffies_up(jiffies +
@@ -1619,7 +1628,7 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
         * Push the beacon loss detection into the future since
         * we are processing a beacon from the AP just now.
         */
-       mod_beacon_timer(sdata);
+       ieee80211_sta_reset_beacon_monitor(sdata);
 
        ncrc = crc32_be(0, (void *)&mgmt->u.beacon.beacon_int, 4);
        ncrc = ieee802_11_parse_elems_crc(mgmt->u.beacon.variable,
@@ -1630,7 +1639,7 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
                directed_tim = ieee80211_check_tim(elems.tim, elems.tim_len,
                                                   ifmgd->aid);
 
-       if (ncrc != ifmgd->beacon_crc) {
+       if (ncrc != ifmgd->beacon_crc || !ifmgd->beacon_crc_valid) {
                ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems,
                                      true);
 
@@ -1661,9 +1670,10 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
                }
        }
 
-       if (ncrc == ifmgd->beacon_crc)
+       if (ncrc == ifmgd->beacon_crc && ifmgd->beacon_crc_valid)
                return;
        ifmgd->beacon_crc = ncrc;
+       ifmgd->beacon_crc_valid = true;
 
        if (elems.erp_info && elems.erp_info_len >= 1) {
                erp_valid = true;
@@ -1854,10 +1864,12 @@ void ieee80211_sta_work(struct ieee80211_sub_if_data *sdata)
 
                else if (ifmgd->probe_send_count < IEEE80211_MAX_PROBE_TRIES) {
 #ifdef CONFIG_MAC80211_VERBOSE_DEBUG
-                       printk(KERN_DEBUG "No probe response from AP %pM"
-                               " after %dms, try %d\n", bssid,
-                               (1000 * IEEE80211_PROBE_WAIT)/HZ,
-                               ifmgd->probe_send_count);
+                       wiphy_debug(local->hw.wiphy,
+                                   "%s: No probe response from AP %pM"
+                                   " after %dms, try %d\n",
+                                   sdata->name,
+                                   bssid, (1000 * IEEE80211_PROBE_WAIT)/HZ,
+                                   ifmgd->probe_send_count);
 #endif
                        ieee80211_mgd_probe_ap_send(sdata);
                } else {
@@ -1867,10 +1879,12 @@ void ieee80211_sta_work(struct ieee80211_sub_if_data *sdata)
                         */
                        ifmgd->flags &= ~(IEEE80211_STA_CONNECTION_POLL |
                                          IEEE80211_STA_BEACON_POLL);
-                       printk(KERN_DEBUG "No probe response from AP %pM"
-                               " after %dms, disconnecting.\n",
-                               bssid, (1000 * IEEE80211_PROBE_WAIT)/HZ);
-                       ieee80211_set_disassoc(sdata, true);
+                       wiphy_debug(local->hw.wiphy,
+                                   "%s: No probe response from AP %pM"
+                                   " after %dms, disconnecting.\n",
+                                   sdata->name,
+                                   bssid, (1000 * IEEE80211_PROBE_WAIT)/HZ);
+                       ieee80211_set_disassoc(sdata, true, true);
                        mutex_unlock(&ifmgd->mtx);
                        mutex_lock(&local->mtx);
                        ieee80211_recalc_idle(local);
@@ -2194,7 +2208,7 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
                }
 
                /* Trying to reassociate - clear previous association state */
-               ieee80211_set_disassoc(sdata, true);
+               ieee80211_set_disassoc(sdata, true, false);
        }
        mutex_unlock(&ifmgd->mtx);
 
@@ -2205,6 +2219,8 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
        ifmgd->flags &= ~IEEE80211_STA_DISABLE_11N;
        ifmgd->flags &= ~IEEE80211_STA_NULLFUNC_ACKED;
 
+       ifmgd->beacon_crc_valid = false;
+
        for (i = 0; i < req->crypto.n_ciphers_pairwise; i++)
                if (req->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_WEP40 ||
                    req->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_TKIP ||
@@ -2306,7 +2322,7 @@ int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata,
 
        memcpy(bssid, req->bss->bssid, ETH_ALEN);
        if (ifmgd->associated == req->bss) {
-               ieee80211_set_disassoc(sdata, false);
+               ieee80211_set_disassoc(sdata, false, true);
                mutex_unlock(&ifmgd->mtx);
                assoc_bss = true;
        } else {
@@ -2389,7 +2405,7 @@ int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata,
               sdata->name, req->bss->bssid, req->reason_code);
 
        memcpy(bssid, req->bss->bssid, ETH_ALEN);
-       ieee80211_set_disassoc(sdata, false);
+       ieee80211_set_disassoc(sdata, false, true);
 
        mutex_unlock(&ifmgd->mtx);