2010-05-03 06:49:53

by Johannes Berg

[permalink] [raw]
Subject: [PATCH] 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.

Signed-off-by: Johannes Berg <[email protected]>
---
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(-)

--- wireless-testing.orig/net/mac80211/main.c 2010-05-02 17:36:04.000000000 +0200
+++ wireless-testing/net/mac80211/main.c 2010-05-02 17:39:00.000000000 +0200
@@ -439,7 +439,7 @@ int ieee80211_register_hw(struct ieee802
struct 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 ieee802

ieee80211_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,
--- wireless-testing.orig/net/mac80211/scan.c 2010-05-02 17:34:53.000000000 +0200
+++ wireless-testing/net/mac80211/scan.c 2010-05-02 17:41:49.000000000 +0200
@@ -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(stru
if (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;

--- wireless-testing.orig/net/mac80211/ibss.c 2010-05-02 17:34:41.000000000 +0200
+++ wireless-testing/net/mac80211/ibss.c 2010-05-02 17:43:34.000000000 +0200
@@ -489,7 +489,9 @@ static void ieee80211_sta_merge_ibss(str
printk(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(stru
printk(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;

--- wireless-testing.orig/net/mac80211/ieee80211_i.h 2010-05-02 17:39:13.000000000 +0200
+++ wireless-testing/net/mac80211/ieee80211_i.h 2010-05-02 17:39:38.000000000 +0200
@@ -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);




2010-05-03 13:24:46

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH] mac80211: improve IBSS scanning

On Mon, 2010-05-03 at 06:20 -0700, Joerg Pommnitz wrote:
> > 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").

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


2010-05-03 14:08:23

by Joerg

[permalink] [raw]
Subject: Re: [PATCH] mac80211: improve IBSS scanning

Johannes Berg <johannes@...> writes:
>
> 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.


2010-05-05 13:33:58

by Johannes Berg

[permalink] [raw]
Subject: [PATCH v2] 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.

Signed-off-by: Johannes Berg <[email protected]>
---
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(-)

--- wireless-testing.orig/net/mac80211/main.c 2010-05-02 17:47:28.000000000 +0200
+++ wireless-testing/net/mac80211/main.c 2010-05-05 15:32:16.000000000 +0200
@@ -439,7 +439,7 @@ int ieee80211_register_hw(struct ieee802
struct 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 ieee802

ieee80211_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,
--- wireless-testing.orig/net/mac80211/scan.c 2010-05-02 17:47:28.000000000 +0200
+++ wireless-testing/net/mac80211/scan.c 2010-05-02 17:47:50.000000000 +0200
@@ -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(stru
if (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;

--- wireless-testing.orig/net/mac80211/ibss.c 2010-05-02 17:47:28.000000000 +0200
+++ wireless-testing/net/mac80211/ibss.c 2010-05-05 15:32:16.000000000 +0200
@@ -489,7 +489,9 @@ static void ieee80211_sta_merge_ibss(str
printk(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(stru
printk(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);
--- wireless-testing.orig/net/mac80211/ieee80211_i.h 2010-05-02 17:47:47.000000000 +0200
+++ wireless-testing/net/mac80211/ieee80211_i.h 2010-05-05 15:32:18.000000000 +0200
@@ -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);



2010-05-03 13:21:00

by Joerg

[permalink] [raw]
Subject: Re: [PATCH] mac80211: improve IBSS scanning

> 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



2010-05-03 14:13:08

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH] mac80211: improve IBSS scanning

On Mon, 2010-05-03 at 14:08 +0000, Joerg Pommnitz wrote:
> Johannes Berg <johannes@...> writes:
> >
> > 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


2010-05-04 05:52:11

by Benoit Papillault

[permalink] [raw]
Subject: Re: [PATCH] mac80211: improve IBSS scanning

Le 03/05/2010 16:13, Johannes Berg a écrit :
> On Mon, 2010-05-03 at 14:08 +0000, Joerg Pommnitz wrote:
>> Johannes Berg<johannes@...> writes:
>>>
>>> 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

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

2010-05-03 13:12:05

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH] mac80211: improve IBSS scanning

On Mon, 2010-05-03 at 13:10 +0000, Joerg Pommnitz wrote:
> Johannes Berg <johannes@...> writes:
> > 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.

> 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.

WHY is it required for you? And yeah, I _am_ still opposed to that.

johannes


2010-05-03 13:10:29

by Joerg

[permalink] [raw]
Subject: Re: [PATCH] mac80211: improve IBSS scanning

Johannes Berg <johannes@...> writes:
> 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