Skip to contentSkip to conversation

mac80211: scan on IBSS mode like on STA mode

PATCH In review Tomas Winkler 3 participants 10 messages Sep 8, 2008 – Sep 10, 2008 mac80211

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mac80211: scan on IBSS mode like on STA mode

From: Ester Kummer <[email protected]>

This patch handle scanning on IBSS mode like on STA mode. When queuing the scan work we don't refer to the return value of ieee80211_sta_start_scan so if we are in the last scan period, we will return 0 to ieee80211_ioctl_siwscan and not -EAGAIN, and then iwlist will call ieee80211_ioctl_giwscan to get the scan results and will not fail.

---
 net/mac80211/mlme.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
net/mac80211/mlme.c +2 -1
index 2564553..72d5fe2 100644
@@ -4090,7 +4090,8 @@ int ieee80211_sta_req_scan(struct ieee80211_sub_if_data *sdata, u8 *ssid, size_t
 	struct ieee80211_if_sta *ifsta = &sdata->u.sta;
 	struct ieee80211_local *local = sdata->local;
 
-	if (sdata->vif.type != IEEE80211_IF_TYPE_STA)
+	if (sdata->vif.type != IEEE80211_IF_TYPE_STA ||
+	    sdata->vif.type != IEEE80211_IF_TYPE_IBSS)
 		return ieee80211_sta_start_scan(sdata, ssid, ssid_len);
 
 	if (local->sta_sw_scanning || local->sta_hw_scanning) {
Signature · 9 lines
1.5.4.1

---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
maintainer
#1 lore raw
Quoted 7 lines · Tomas Winkler

From: Ester Kummer <[email protected]>

This patch handle scanning on IBSS mode like on STA mode. When queuing the scan work we don't refer to the return value of ieee80211_sta_start_scan so if we are in the last scan period, we will return 0 to ieee80211_ioctl_siwscan and not -EAGAIN, and then iwlist will call ieee80211_ioctl_giwscan to get the scan results and will not fail.

Can you explain why? Or can anybody else explain why we do this difference at all? And how should mesh behave?

Quoted 11 lines
---
 net/mac80211/mlme.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
net/mac80211/mlme.c +0 -0
index 2564553..72d5fe2 100644

net/mac80211/mlme.c int ieee80211_sta_req_scan(struct ieee80211_sub_if_data *sdata, u8 *ssid, size_t · line 4095

Quoted 7 lines
net/mac80211/mlme.c +2 -1
@@ -4090,7 +4090,8 @@ int ieee80211_sta_req_scan(struct ieee80211_sub_if_data *sdata, u8 *ssid, size_t
 	struct ieee80211_if_sta *ifsta = &sdata->u.sta;
 	struct ieee80211_local *local = sdata->local;
 
-	if (sdata->vif.type != IEEE80211_IF_TYPE_STA)
+	if (sdata->vif.type != IEEE80211_IF_TYPE_STA ||
+	    sdata->vif.type != IEEE80211_IF_TYPE_IBSS)
 		return ieee80211_sta_start_scan(sdata, ssid, ssid_len);

This is wrong.

a != 1 || a != 2

has to be true at all times, I think you mean &&.

johannes

maintainer
#2 lore raw
Quoted 10 lines · Johannes Berg
Quoted 7 lines · Tomas Winkler

From: Ester Kummer <[email protected]>

This patch handle scanning on IBSS mode like on STA mode. When queuing the scan work we don't refer to the return value of ieee80211_sta_start_scan so if we are in the last scan period, we will return 0 to ieee80211_ioctl_siwscan and not -EAGAIN, and then iwlist will call ieee80211_ioctl_giwscan to get the scan results and will not fail.

Quoted 2 lines

Can you explain why? Or can anybody else explain why we do this difference at all? And how should mesh behave?

Actually, I do understand the difference now (explanation added below) and if I'm guessing the problem you're having correctly your patch is wrong. I think you want something like the patch below (never mind the fact that it's against scan.c, I'm shuffling code)

johannes

net/mac80211/scan.c +18 -10
@@ -674,24 +674,32 @@ int ieee80211_sta_start_scan(struct ieee
 
 int ieee80211_sta_req_scan(struct ieee80211_sub_if_data *sdata, u8 *ssid, size_t ssid_len)
 {
-	struct ieee80211_if_sta *ifsta = &sdata->u.sta;
 	struct ieee80211_local *local = sdata->local;
 
-	if (sdata->vif.type != IEEE80211_IF_TYPE_STA)
-		return ieee80211_sta_start_scan(sdata, ssid, ssid_len);
-
 	if (local->sta_sw_scanning || local->sta_hw_scanning) {
 		if (local->scan_sdata == sdata)
 			return 0;
 		return -EBUSY;
 	}
 
-	ifsta->scan_ssid_len = ssid_len;
-	if (ssid_len)
-		memcpy(ifsta->scan_ssid, ssid, ssid_len);
-	set_bit(IEEE80211_STA_REQ_SCAN, &ifsta->request);
-	queue_work(local->hw.workqueue, &ifsta->work);
-	return 0;
+	/*
+	 * STA has a state machine that might need to defer scanning
+	 * while it's trying to associate/authenticate, therefore we
+	 * queue it up to the state machine in that case.
+	 */
+	if (sdata->vif.type == IEEE80211_IF_TYPE_STA) {
+		struct ieee80211_if_sta *ifsta = &sdata->u.sta;
+
+		ifsta->scan_ssid_len = ssid_len;
+		if (ssid_len)
+			memcpy(ifsta->scan_ssid, ssid, ssid_len);
+		set_bit(IEEE80211_STA_REQ_SCAN, &ifsta->request);
+		queue_work(local->hw.workqueue, &ifsta->work);
+
+		return 0;
+	}
+
+	return ieee80211_sta_start_scan(sdata, ssid, ssid_len);
 }
 
 
maintainer
#3 lore raw

net/mac80211/scan.c int ieee80211_sta_start_scan(struct ieee · line 683

Quoted 13 lines · Johannes Berg
Quoted 2 lines

Can you explain why? Or can anybody else explain why we do this difference at all? And how should mesh behave?

Actually, I do understand the difference now (explanation added below) and if I'm guessing the problem you're having correctly your patch is wrong. I think you want something like the patch below (never mind the fact that it's against scan.c, I'm shuffling code)

net/mac80211/scan.c +0 -0
 	if (local->sta_sw_scanning || local->sta_hw_scanning) {
 		if (local->scan_sdata == sdata)
 			return 0;
 		return -EBUSY;
 	}

Then again, ieee80211_sta_start_scan does that check as well, so now I'm confused.

johannes

#9 lore raw
In reply to Johannes Berg
Quoted 34 lines · Johannes Berg
Quoted 7 lines · Tomas Winkler

From: Ester Kummer <[email protected]>

This patch handle scanning on IBSS mode like on STA mode. When queuing the scan work we don't refer to the return value of ieee80211_sta_start_scan so if we are in the last scan period, we will return 0 to ieee80211_ioctl_siwscan and not -EAGAIN, and then iwlist will call ieee80211_ioctl_giwscan to get the scan results and will not fail.

Can you explain why? Or can anybody else explain why we do this difference at all? And how should mesh behave?

Quoted 11 lines
---
 net/mac80211/mlme.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
net/mac80211/mlme.c +0 -0
index 2564553..72d5fe2 100644

net/mac80211/mlme.c int ieee80211_sta_req_scan(struct ieee80211_sub_if_data *sdata, u8 *ssid, size_t · line 4095

Quoted 7 lines
net/mac80211/mlme.c +2 -1
@@ -4090,7 +4090,8 @@ int ieee80211_sta_req_scan(struct ieee80211_sub_if_data *sdata, u8 *ssid, size_t
      struct ieee80211_if_sta *ifsta = &sdata->u.sta;
      struct ieee80211_local *local = sdata->local;
 
-     if (sdata->vif.type != IEEE80211_IF_TYPE_STA)
+     if (sdata->vif.type != IEEE80211_IF_TYPE_STA ||
+         sdata->vif.type != IEEE80211_IF_TYPE_IBSS)
              return ieee80211_sta_start_scan(sdata, ssid, ssid_len);

This is wrong.

Quoted 3 lines

a != 1 || a != 2

has to be true at all times, I think you mean &&.

It definitely should be &&. Copied it wrongly from the original patch. Tomas

#4 lore raw
In reply to Johannes Berg
Quoted 10 lines · Johannes Berg
Quoted 7 lines · Johannes Berg
Quoted 2 lines

Can you explain why? Or can anybody else explain why we do this difference at all? And how should mesh behave?

Actually, I do understand the difference now (explanation added below) and if I'm guessing the problem you're having correctly your patch is wrong. I think you want something like the patch below (never mind the fact that it's against scan.c, I'm shuffling code)

Quoted 8 lines
Quoted 5 lines
      if (local->sta_sw_scanning || local->sta_hw_scanning) {
              if (local->scan_sdata == sdata)
                      return 0;
              return -EBUSY;
      }

Then again, ieee80211_sta_start_scan does that check as well, so now I'm confused.

The bug is that scan can be triggered in STA and IBSS internally. If you request scan from the application (iwlist) while internally scan is running application won't fetch scan results because the -EBUSY is returned on scan request.
Tomas

Quoted 1 line
maintainer
#5 lore raw
Quoted 4 lines · Tomas Winkler

The bug is that scan can be triggered in STA and IBSS internally. If you request scan from the application (iwlist) while internally scan is running application won't fetch scan results because the -EBUSY is returned on scan request.

But -EBUSY won't be returned if that same interface is already scanning, then 0 will be returned, so I don't understand?

johannes

#6 lore raw
Quoted 9 lines · Johannes Berg
Quoted 4 lines · Tomas Winkler

The bug is that scan can be triggered in STA and IBSS internally. If you request scan from the application (iwlist) while internally scan is running application won't fetch scan results because the -EBUSY is returned on scan request.

But -EBUSY won't be returned if that same interface is already scanning, then 0 will be returned, so I don't understand?

Me either, but empirically the fix from Esti cured the problem. The problem is seen only in IBSS. Will dig into this tomorrow. Thanks
Tomas

#7 lore raw
Quoted 8 lines · Tomas Winkler
Quoted 7 lines · Johannes Berg
Quoted 4 lines · Tomas Winkler

The bug is that scan can be triggered in STA and IBSS internally. If you request scan from the application (iwlist) while internally scan is running application won't fetch scan results because the -EBUSY is returned on scan request.

Quoted 5 lines
Quoted 2 lines

But -EBUSY won't be returned if that same interface is already scanning, then 0 will be returned, so I don't understand?

Me either, but empirically the fix from Esti cured the problem. The problem is seen only in IBSS. Will dig into this tomorrow.

Okay so here is the scenario. Iwlwifi reject scan that is triggered withing fixed period after
association to leave time to finish EAPOL exchange.
We never hit the problem in STA mode because of this code

if (sdata->vif.type != IEEE80211_IF_TYPE_STA)

		return ieee80211_sta_start_scan(dev, ssid, ssid_len);

which makes it go through the work queue, just pure timing luck. I will remove this delay for IBSS, there is no association and no 1X is going on.

For BSS I suggest to enforce similar delay already mac80211, iwlwifi I just return empty scan completion and buffered results will be returned.

Tomas

maintainer
#8 lore raw
Quoted 3 lines · Tomas Winkler

Okay so here is the scenario. Iwlwifi reject scan that is triggered withing fixed period after
association to leave time to finish EAPOL exchange.

Why is iwlwifi thinking it's associating in an IBSS?

Quoted 6 lines

We never hit the problem in STA mode because of this code

if (sdata->vif.type != IEEE80211_IF_TYPE_STA)

		return ieee80211_sta_start_scan(dev, ssid, ssid_len);

which makes it go through the work queue, just pure timing luck.

Well the remainder of the code makes it go through, but yeah.

Quoted 2 lines

I will remove this delay for IBSS, there is no association and no 1X is going on.

Ok, makes sense.

Quoted 3 lines

For BSS I suggest to enforce similar delay already mac80211, iwlwifi I just return empty scan completion and buffered results will be returned.

We might want to enforce a similar delay like that in mac80211 instead of iwlwifi, yeah.

johannes