cfg80211: do not process beacon hints if one is already queued
authorLuis R. Rodriguez <mcgrof@do-not-panic.com>
Wed, 19 Dec 2012 18:53:02 +0000 (10:53 -0800)
committerJohannes Berg <johannes.berg@intel.com>
Thu, 3 Jan 2013 12:01:37 +0000 (13:01 +0100)
Regulatory beacon hints are used to help with world roaming
and as it is right now we learn from a beacon hint processed
on one wiphy to all other wiphys. The processing of beacon
hints however is scheduled and if we have a lot of interfaces
we may hit the case that we'll queue a the same beacon hint
many times until its processed.

To avoid this do a lookup on the queued up beacon hints prior
to adding a new beacon hint. If the beacon hint is removed
from the pending reg beacon hint list then it would be processed
and we'd ensure all wiphys would have learned from it, if its
on the pending reg beacon list we'd now find it prior to it
being processed.

Tested-by: Ben Greear <greearb@candelatech.com>
Reported-by: Ben Greear <greearb@candelatech.com>
Reported-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/wireless/reg.c

index fd53d975c0bc7f850dd05ce73c98bade9142d54a..2a3ae4d1001dfd7eea61ed117ad821212d63bc5a 100644 (file)
@@ -1925,11 +1925,23 @@ static bool freq_is_chan_12_13_14(u16 freq)
        return false;
 }
 
+static bool pending_reg_beacon(struct ieee80211_channel *beacon_chan)
+{
+       struct reg_beacon *pending_beacon;
+
+       list_for_each_entry(pending_beacon, &reg_pending_beacons, list)
+               if (beacon_chan->center_freq ==
+                   pending_beacon->chan.center_freq)
+                       return true;
+       return false;
+}
+
 int regulatory_hint_found_beacon(struct wiphy *wiphy,
                                 struct ieee80211_channel *beacon_chan,
                                 gfp_t gfp)
 {
        struct reg_beacon *reg_beacon;
+       bool processing;
 
        if (beacon_chan->beacon_found ||
            beacon_chan->flags & IEEE80211_CHAN_RADAR ||
@@ -1937,6 +1949,13 @@ int regulatory_hint_found_beacon(struct wiphy *wiphy,
             !freq_is_chan_12_13_14(beacon_chan->center_freq)))
                return 0;
 
+       spin_lock_bh(&reg_pending_beacons_lock);
+       processing = pending_reg_beacon(beacon_chan);
+       spin_unlock_bh(&reg_pending_beacons_lock);
+
+       if (processing)
+               return 0;
+
        reg_beacon = kzalloc(sizeof(struct reg_beacon), gfp);
        if (!reg_beacon)
                return -ENOMEM;