mac80211_hwsim: fix beacon timers
authorJohannes Berg <johannes.berg@intel.com>
Tue, 3 Mar 2015 21:09:05 +0000 (22:09 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 4 Mar 2015 09:34:15 +0000 (10:34 +0100)
Jouni reported that certain combinations of hwsim test cases failed,
and we found that beaconing was erroneously enabled too early on any
channel switch, which lead to the BI of 2000 TU from the first test
case to leak into the second one, which then didn't beacon properly.

To fix this, set data->beacon_int to zero when all stop beaconing so
that beaconing cannot be started (which was intended as 'restarted')
elsewhere.

Additionally, Jouni found that due to this 'restart' and the beacon
interval handling station interfaces would also have a needlessly
running beacon timer all the time, of course not doing anything.

To also fix the latter case only use the beacon interval when it's
actually needed, i.e. when beaconing gets enabled.

Reported-by: Jouni Malinen <j@w1.fi>
Tested-by: Jouni Malinen <j@w1.fi>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/mac80211_hwsim.c

index 32bd2f02c164b33732118b573b77626942523349..941925991476eefdd377e1472fd08692c225d982 100644 (file)
@@ -1595,21 +1595,16 @@ static void mac80211_hwsim_bss_info_changed(struct ieee80211_hw *hw,
                vp->aid = info->aid;
        }
 
-       if (changed & BSS_CHANGED_BEACON_INT) {
-               wiphy_debug(hw->wiphy, "  BCNINT: %d\n", info->beacon_int);
-               data->beacon_int = info->beacon_int * 1024;
-       }
-
        if (changed & BSS_CHANGED_BEACON_ENABLED) {
-               wiphy_debug(hw->wiphy, "  BCN EN: %d\n", info->enable_beacon);
+               wiphy_debug(hw->wiphy, "  BCN EN: %d (BI=%u)\n",
+                           info->enable_beacon, info->beacon_int);
                vp->bcn_en = info->enable_beacon;
                if (data->started &&
                    !hrtimer_is_queued(&data->beacon_timer.timer) &&
                    info->enable_beacon) {
                        u64 tsf, until_tbtt;
                        u32 bcn_int;
-                       if (WARN_ON(!data->beacon_int))
-                               data->beacon_int = 1000 * 1024;
+                       data->beacon_int = info->beacon_int * 1024;
                        tsf = mac80211_hwsim_get_tsf(hw, vif);
                        bcn_int = data->beacon_int;
                        until_tbtt = bcn_int - do_div(tsf, bcn_int);
@@ -1623,8 +1618,10 @@ static void mac80211_hwsim_bss_info_changed(struct ieee80211_hw *hw,
                                mac80211_hwsim_bcn_en_iter, &count);
                        wiphy_debug(hw->wiphy, "  beaconing vifs remaining: %u",
                                    count);
-                       if (count == 0)
+                       if (count == 0) {
                                tasklet_hrtimer_cancel(&data->beacon_timer);
+                               data->beacon_int = 0;
+                       }
                }
        }