mac80211: improve IBSS scanning
Johannes Berg
maintainerPATCH 1/1 mac80211: improve IBSS scanning
When IBSS is fixed to a frequency, it can still scan to try to find the right BSSID. This makes sense if the BSSID isn't also fixed, but it need not scan all channels -- just one is sufficient. Make it do that by moving the scan setup code to ieee80211_request_internal_scan() and include a channel variable setting.
Note that this can be further improved to start the IBSS right away if both frequency and BSSID are fixed.
--- net/mac80211/ibss.c | 9 ++++++--- net/mac80211/ieee80211_i.h | 3 ++- net/mac80211/main.c | 17 +---------------- net/mac80211/scan.c | 28 +++++++++++++++++++++++++++- 4 files changed, 36 insertions(+), 21 deletions(-)
net/mac80211/main.c +1 -16
@@ -439,7 +439,7 @@ int ieee80211_register_hw(struct ieee802struct ieee80211_local *local =hw_to_local (hw);int result;enum ieee80211_band band; -int channels, i, j, max_bitrates; +int channels, max_bitrates;bool supp_ht;static const u32 cipher_suites[] = {WLAN_CIPHER_SUITE_WEP40 ,
@@ -605,21 +605,6 @@ int ieee80211_register_hw(struct ieee802ieee80211_led_init (local); -/* alloc internal scan request */ - i =0 ; - local->int_scan_req->ssids = &local->scan_ssid; - local->int_scan_req->n_ssids =1 ; -for (band =0 ; band <IEEE80211_NUM_BANDS ; band++) { -if (!hw->wiphy->bands[band]) -continue ; -for (j =0 ; j < hw->wiphy->bands[band]->n_channels; j++) { - local->int_scan_req->channels[i] = - &hw->wiphy->bands[band]->channels[j]; - i++; - } - } - local->int_scan_req->n_channels = i; - local->network_latency_notifier.notifier_call = ieee80211_max_network_latency; result = pm_qos_add_notifier(PM_QOS_NETWORK_LATENCY,
net/mac80211/scan.c +27 -1
@@ -729,10 +729,12 @@ int ieee80211_request_scan(struct ieee80 }int ieee80211_request_internal_scan (struct ieee80211_sub_if_data *sdata, -const u8 *ssid,u8 ssid_len) +const u8 *ssid,u8 ssid_len, +struct ieee80211_channel *chan) {struct ieee80211_local *local = sdata->local;int ret = -EBUSY ; +enum nl80211_band band;mutex_lock (&local->scan_mtx);
@@ -740,6 +742,30 @@ int ieee80211_request_internal_scan(struif (local->scan_req) goto unlock; +/* fill internal scan request */ +if (!chan) { +int i, nchan =0 ; + +for (band =0 ; band <IEEE80211_NUM_BANDS ; band++) { +if (!local->hw.wiphy->bands[band]) +continue ; +for (i =0 ; + i < local->hw.wiphy->bands[band]->n_channels; + i++) { + local->int_scan_req->channels[nchan] = + &local->hw.wiphy->bands[band]->channels[i]; + nchan++; + } + } + + local->int_scan_req->n_channels = nchan; + }else { + local->int_scan_req->channels[0 ] = chan; + local->int_scan_req->n_channels =1 ; + } + + local->int_scan_req->ssids = &local->scan_ssid; + local->int_scan_req->n_ssids =1 ;memcpy (local->int_scan_req->ssids[0 ].ssid, ssid,IEEE80211_MAX_SSID_LEN ); local->int_scan_req->ssids[0 ].ssid_len = ssid_len;
net/mac80211/ibss.c +6 -3
@@ -489,7 +489,9 @@ static void ieee80211_sta_merge_ibss(strprintk (KERN_DEBUG "%s: No active IBSS STAs - trying to scan for other " "IBSS networks with same SSID (merge)\n" , sdata->name); -ieee80211_request_internal_scan (sdata, ifibss->ssid, ifibss->ssid_len); +ieee80211_request_internal_scan (sdata, + ifibss->ssid, ifibss->ssid_len, + ifibss->fixed_channel ? ifibss->channel :NULL ); }static void ieee80211_sta_create_ibss (struct ieee80211_sub_if_data *sdata)
@@ -596,8 +598,9 @@ static void ieee80211_sta_find_ibss(struprintk (KERN_DEBUG "%s: Trigger new scan to find an IBSS to " "join\n" , sdata->name); -ieee80211_request_internal_scan (sdata, ifibss->ssid, - ifibss->ssid_len); +ieee80211_request_internal_scan (sdata, + ifibss->ssid, ifibss->ssid_len, + ifibss->fixed_channel ? ifibss->channel :NULL ); }else {int interval =IEEE80211_SCAN_INTERVAL ;
net/mac80211/ieee80211_i.h +2 -1
@@ -1020,7 +1020,8 @@ void ieee80211_ibss_restart(struct ieee8/* scan/BSS handling */ void ieee80211_scan_work (struct work_struct *work);int ieee80211_request_internal_scan (struct ieee80211_sub_if_data *sdata, -const u8 *ssid,u8 ssid_len); +const u8 *ssid,u8 ssid_len, +struct ieee80211_channel *chan);int ieee80211_request_scan (struct ieee80211_sub_if_data *sdata,struct cfg80211_scan_request *req);void ieee80211_scan_cancel (struct ieee80211_local *local);
Quoted 3 lines · Johannes Berg
Note that this can be further improved to start
the IBSS right away if both frequency and BSSID
are fixed.
Doing this and switching off beaconing would be the same as the infamous AH-Demo mode supported by Madwifi and creeping into the current kernel, no?
see http://madwifi-project.org/wiki/UserDocs/AhdemoInterface
and HTC_M_AHDEMO in enum htc_opmode.
For me, AH-Demo is required to ditch Madwifi, so are you still opposed to its integration? It seems that the pieces of the puzzle are almost there now.
Regards
Joerg
Johannes Berg
maintainerQuoted 8 lines · Joerg Pommnitz
Quoted 3 lines · Johannes Berg
Note that this can be further improved to start
the IBSS right away if both frequency and BSSID
are fixed.Doing this and switching off beaconing would be the same as the infamous AH-Demo mode supported by Madwifi and creeping into the current kernel, no?
and switching of beaconing. Don't think we want that.
Quoted 6 lines
see http://madwifi-project.org/wiki/UserDocs/AhdemoInterface
andHTC_M_AHDEMOin enumhtc_opmode.For me, AH-Demo is required to ditch Madwifi, so are you still opposed to its integration? It seems that the pieces of the puzzle are almost there now.
WHY is it required for you? And yeah, I _am_ still opposed to that.
johannes
Quoted 2 lines
WHY is it required for you? And yeah, I _am_ still opposed to that.
Please don't laugh! Really, don't!
We have an embedded system that normally uses an IBSS network as a delivery system (can be deployed for field measurements). Some customers were unhappy that the networks could be detected on WLAN snoopers like Netstumbler. The quick and dirty solution to make the networks invisible was using the AH-demo mode.
Now "invisible on Netstumbler" is an advertised feature that must be maintained for ever after (the GUI has a checkbox "hide from Netstumbler").
Regards
Joerg
Johannes Berg
maintainerQuoted 11 lines · Joerg Pommnitz
Quoted 2 lines
WHY is it required for you? And yeah, I _am_ still opposed to that.
Please don't laugh! Really, don't!
We have an embedded system that normally uses an IBSS network as a delivery system (can be deployed for field measurements). Some customers were unhappy that the networks could be detected on WLAN snoopers like Netstumbler. The quick and dirty solution to make the networks invisible was using the AH-demo mode.
Quoted 3 lines
Now "invisible on Netstumbler" is an advertised feature that must be maintained for ever after (the GUI has a checkbox "hide from Netstumbler").
Ok ... I'll go improve netstumbler instead of laughing ... if there's any traffic it can trivially be detected anyway, so what's the point? Hidden SSID is a hack (which doesn't work with IBSS obviously), but this kinda seems worse.
Seriously though, why should the upstream kernel support such bad design decisions...? :)
johannes
Quoted 2 lines · Johannes Berg
Hidden SSID is a hack (which doesn't work with IBSS obviously), but this kinda seems worse.
Actually, it does. And because I thought what you think I have the radiotap traces to prove it. :-)
Quoted 2 lines
Seriously though, why should the upstream kernel support such bad design decisions...? :)
Well, because this topic comes up every few months. It seems there are other people who are attached to AH-demo for their very own reasons.
Regards
Joerg
Quoted 2 lines · Johannes Berg
Hidden SSID is a hack (which doesn't work with IBSS obviously), but this kinda seems worse.
Actually, it does (work on IBSS, that is). And because I thought what you think I have the
radiotap traces to prove it.
Johannes Berg
maintainerQuoted 7 lines · Joerg Pommnitz
Quoted 2 lines · Johannes Berg
Hidden SSID is a hack (which doesn't work with IBSS obviously), but this kinda seems worse.
Actually, it does (work on IBSS, that is). And because I thought what you think I have the
radiotap traces to prove it.
Interesting. I guess we never rejected it although it's invalid according to the standard. Yuck. I think I would like to make nl80211 reject it, but maybe I'll forget about it and let you use it ;)
johannes
Quoted 4 lines · Johannes Berg
Interesting. I guess we never rejected it although it's invalid according to the standard. Yuck. I think I would like to make nl80211 reject it, but maybe I'll forget about it and let you use it ;)
Sorry, I don't know about mac80211. This was more a general point. I thought this woudn't work at all but a co-worker was adamant that it works fine with Madwifi. So I sat down and observed it with a monitoring interface and lo and behold: The beacons really contained the broadcast SSID.
Johannes Berg
maintainerQuoted 11 lines · Joerg Pommnitz
Quoted 4 lines · Johannes Berg
Interesting. I guess we never rejected it although it's invalid according to the standard. Yuck. I think I would like to make nl80211 reject it, but maybe I'll forget about it and let you use it ;)
Sorry, I don't know about mac80211. This was more a general point. I thought this woudn't work at all but a co-worker was adamant that it works fine with Madwifi. So I sat down and observed it with a monitoring interface and lo and behold: The beacons really contained the broadcast SSID.
Oh ok. I didn't see anything in cfg80211 but will check and post a patch :)
johannes
Quoted 13 lines · Johannes Berg
Quoted 11 lines · Joerg Pommnitz
Quoted 4 lines · Johannes Berg
Interesting. I guess we never rejected it although it's invalid according to the standard. Yuck. I think I would like to make nl80211 reject it, but maybe I'll forget about it and let you use it ;)
Sorry, I don't know about mac80211. This was more a general point. I thought this woudn't work at all but a co-worker was adamant that it works fine with Madwifi. So I sat down and observed it with a monitoring interface and lo and behold: The beacons really contained the broadcast SSID.
Quoted 4 lines
Oh ok. I didn't see anything in cfg80211 but will check and post a patch :)
johannes
Sorry to reply late, but in IBSS, beacons are really critical for synchronization (including BSSID & TSF). As such, they cannot be removed.
AFAIK, adhoc DEMO is just like adhoc, but without beacons. As such, there is no synchronization and every node use the BSSID 00:00:00:00:00:00, preventing from having several "networks" on the same frequency (since there is no SSID to distinguish them).
What you said is that you are using the broadcast SSID instead? And a fixed BSSID? I would indeed appreciate the capture file :-)
Regards,
Benoit
Johannes Berg
maintainerPATCH v2 1/1 mac80211: improve IBSS scanning
In reply to Johannes BergWhen IBSS is fixed to a frequency, it can still scan to try to find the right BSSID. This makes sense if the BSSID isn't also fixed, but it need not scan all channels -- just one is sufficient. Make it do that by moving the scan setup code to ieee80211_request_internal_scan() and include a channel variable setting.
Note that this can be further improved to start the IBSS right away if both frequency and BSSID are fixed.
---
Argh, forgot a quilt refresh :(
net/mac80211/ibss.c | 15 ++++++++++++--- net/mac80211/ieee80211_i.h | 3 ++- net/mac80211/main.c | 17 +---------------- net/mac80211/scan.c | 28 +++++++++++++++++++++++++++- 4 files changed, 42 insertions(+), 21 deletions(-)
net/mac80211/main.c +1 -16
@@ -439,7 +439,7 @@ int ieee80211_register_hw(struct ieee802struct ieee80211_local *local =hw_to_local (hw);int result;enum ieee80211_band band; -int channels, i, j, max_bitrates; +int channels, max_bitrates;bool supp_ht;static const u32 cipher_suites[] = {WLAN_CIPHER_SUITE_WEP40 ,
@@ -605,21 +605,6 @@ int ieee80211_register_hw(struct ieee802ieee80211_led_init (local); -/* alloc internal scan request */ - i =0 ; - local->int_scan_req->ssids = &local->scan_ssid; - local->int_scan_req->n_ssids =1 ; -for (band =0 ; band <IEEE80211_NUM_BANDS ; band++) { -if (!hw->wiphy->bands[band]) -continue ; -for (j =0 ; j < hw->wiphy->bands[band]->n_channels; j++) { - local->int_scan_req->channels[i] = - &hw->wiphy->bands[band]->channels[j]; - i++; - } - } - local->int_scan_req->n_channels = i; - local->network_latency_notifier.notifier_call = ieee80211_max_network_latency; result = pm_qos_add_notifier(PM_QOS_NETWORK_LATENCY,
net/mac80211/scan.c +27 -1
@@ -729,10 +729,12 @@ int ieee80211_request_scan(struct ieee80 }int ieee80211_request_internal_scan (struct ieee80211_sub_if_data *sdata, -const u8 *ssid,u8 ssid_len) +const u8 *ssid,u8 ssid_len, +struct ieee80211_channel *chan) {struct ieee80211_local *local = sdata->local;int ret = -EBUSY ; +enum nl80211_band band;mutex_lock (&local->scan_mtx);
@@ -740,6 +742,30 @@ int ieee80211_request_internal_scan(struif (local->scan_req) goto unlock; +/* fill internal scan request */ +if (!chan) { +int i, nchan =0 ; + +for (band =0 ; band <IEEE80211_NUM_BANDS ; band++) { +if (!local->hw.wiphy->bands[band]) +continue ; +for (i =0 ; + i < local->hw.wiphy->bands[band]->n_channels; + i++) { + local->int_scan_req->channels[nchan] = + &local->hw.wiphy->bands[band]->channels[i]; + nchan++; + } + } + + local->int_scan_req->n_channels = nchan; + }else { + local->int_scan_req->channels[0 ] = chan; + local->int_scan_req->n_channels =1 ; + } + + local->int_scan_req->ssids = &local->scan_ssid; + local->int_scan_req->n_ssids =1 ;memcpy (local->int_scan_req->ssids[0 ].ssid, ssid,IEEE80211_MAX_SSID_LEN ); local->int_scan_req->ssids[0 ].ssid_len = ssid_len;
net/mac80211/ibss.c +12 -3
@@ -489,7 +489,9 @@ static void ieee80211_sta_merge_ibss(strprintk (KERN_DEBUG "%s: No active IBSS STAs - trying to scan for other " "IBSS networks with same SSID (merge)\n" , sdata->name); -ieee80211_request_internal_scan (sdata, ifibss->ssid, ifibss->ssid_len); +ieee80211_request_internal_scan (sdata, + ifibss->ssid, ifibss->ssid_len, + ifibss->fixed_channel ? ifibss->channel :NULL ); }static void ieee80211_sta_create_ibss (struct ieee80211_sub_if_data *sdata)
@@ -596,8 +598,9 @@ static void ieee80211_sta_find_ibss(struprintk (KERN_DEBUG "%s: Trigger new scan to find an IBSS to " "join\n" , sdata->name); -ieee80211_request_internal_scan (sdata, ifibss->ssid, - ifibss->ssid_len); +ieee80211_request_internal_scan (sdata, + ifibss->ssid, ifibss->ssid_len, + ifibss->fixed_channel ? ifibss->channel :NULL ); }else {int interval =IEEE80211_SCAN_INTERVAL ;
@@ -905,6 +908,12 @@ int ieee80211_ibss_join(struct ieee80211 sdata->u.ibss.channel = params->channel; sdata->u.ibss.fixed_channel = params->channel_fixed; +/* fix ourselves to that channel now already */ +if (params->channel_fixed) { + sdata->local->oper_channel = params->channel; + sdata->local->oper_channel_type =NL80211_CHAN_NO_HT ; + } +if (params->ie) { sdata->u.ibss.ie =kmemdup (params->ie, params->ie_len,GFP_KERNEL );
net/mac80211/ieee80211_i.h +2 -1
@@ -1020,7 +1020,8 @@ void ieee80211_ibss_restart(struct ieee8/* scan/BSS handling */ void ieee80211_scan_work (struct work_struct *work);int ieee80211_request_internal_scan (struct ieee80211_sub_if_data *sdata, -const u8 *ssid,u8 ssid_len); +const u8 *ssid,u8 ssid_len, +struct ieee80211_channel *chan);int ieee80211_request_scan (struct ieee80211_sub_if_data *sdata,struct cfg80211_scan_request *req);void ieee80211_scan_cancel (struct ieee80211_local *local);