Skip to content

Commit a69b40a

Browse files
Michal Kaziorjmberg-intel
authored andcommitted
cfg80211: set initial monitor channel
Implements behaviour seen in mac80211. A running monitor always has a channel - even before .set_channel. This way we won't break current behaviour. Signed-off-by: Michal Kazior <michal.kazior@tieto.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent b78e8ce commit a69b40a

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

‎net/wireless/core.c‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,35 @@ static struct device_type wiphy_type = {
717717
.name = "wlan",
718718
};
719719

720+
static struct ieee80211_channel *
721+
cfg80211_get_any_chan(struct cfg80211_registered_device *rdev)
722+
{
723+
struct ieee80211_supported_band *sband;
724+
int i;
725+
726+
for (i = 0; i < IEEE80211_NUM_BANDS; i++) {
727+
sband = rdev->wiphy.bands[i];
728+
if (sband && sband->n_channels > 0)
729+
return &sband->channels[0];
730+
}
731+
732+
return NULL;
733+
}
734+
735+
static void cfg80211_init_mon_chan(struct cfg80211_registered_device *rdev)
736+
{
737+
struct ieee80211_channel *chan;
738+
739+
chan = cfg80211_get_any_chan(rdev);
740+
if (WARN_ON(!chan))
741+
return;
742+
743+
mutex_lock(&rdev->devlist_mtx);
744+
WARN_ON(cfg80211_set_monitor_channel(rdev, chan->center_freq,
745+
NL80211_CHAN_NO_HT));
746+
mutex_unlock(&rdev->devlist_mtx);
747+
}
748+
720749
void cfg80211_update_iface_num(struct cfg80211_registered_device *rdev,
721750
enum nl80211_iftype iftype, int num)
722751
{
@@ -737,6 +766,8 @@ void cfg80211_update_iface_num(struct cfg80211_registered_device *rdev,
737766
if (!has_monitors_only_new) {
738767
rdev->monitor_channel = NULL;
739768
rdev->monitor_channel_type = NL80211_CHAN_NO_HT;
769+
} else {
770+
cfg80211_init_mon_chan(rdev);
740771
}
741772
}
742773
}

0 commit comments

Comments
 (0)