Skip to contentSkip to conversation

Fix inability to configure adhoc in 3.4.x

PATCH In review Paul Gortmaker 4 participants 11 messages Aug 1, 2012 – Aug 13, 2012 802.11 (including cfg80211/NL80211)

lore
Share & tools
lore
#1 lore raw

PATCH 1/1 cfg80211: fix combination check for ADHOC

In reply to Paul Gortmaker

From: Liang Li <[email protected]>

As part of commit 463454b5dbd8 ("cfg80211: fix interface combinations check"), this extra check was introduced:

       if ((all_iftypes & used_iftypes) != used_iftypes)
               goto cont;

However, most wireless NIC drivers did not advertise ADHOC in wiphy.iface_combinations[i].limits[] hence we'll get -EBUSY when we bring up a ADHOC wlan by commands similar to:

 # iwconfig wlan0 mode ad-hoc && ifconfig wlan0 up

In commit 8e8b41f9d8c8e ("cfg80211: enforce lack of interface combinations"), the change below happens to fix the issue:

       if (total == 1)
               return 0;

But it also introduces other dependencies, at least for stable. For example, a full cherry pick of 8e8b41f9d8c8e would introduce additional regressions unless we also start cherry picking driver specific fixes like the following:

9b4760e  ath5k: add possible wiphy interface combinations
1ae2fc2  mac80211_hwsim: advertise interface combinations
20c8e8d  ath9k: add possible wiphy interface combinations

It seems like we should add an exception for NL80211_IFTYPE_ADHOC, since it is a kind of 'basic' mode, being supported by almost all wifi cards but currently most drivers don't advertise it at all. So making the NL80211_IFTYPE_ADHOC a part of all_iftypes seems reasonable.

Doing so also gives stable kernels a way to fix the change introduced by 463454b5dbd8, without having to make cherry picks specific to various NIC drivers.

---
 net/wireless/util.c | 2 ++
 1 file changed, 2 insertions(+)
net/wireless/util.c +2 -0
index 26f8cd3..4a4749c 100644
@@ -1129,6 +1129,8 @@ int cfg80211_can_use_iftype_chan(struct cfg80211_registered_device *rdev,
 			}
 		}
 
+		all_iftypes |= BIT(NL80211_IFTYPE_ADHOC);
+
 		/*
 		 * Finally check that all iftypes that we're currently
 		 * using are actually part of this combination. If they
Signature · 1 line
1.7.11.1
#0 lore raw

cover Fix inability to configure adhoc in 3.4.x

Normally a single patch doesn't warrant a 0/1, but Liang did some digging on this problem and came up with important background, and several possible solutions, so I wanted to capture what he'd learned.

The issues with creating an ad-hoc network started in 3.4.3 with the cherry pick of 463454b5dbd ("cfg80211: fix interface combinations check") on intel hardware (iwl-mac80211.c) that doesn't support multi-function or virtual interfaces. Specifically, it adds this:

+ if ((all_iftypes & used_iftypes) != used_iftypes)
+ goto cont;

and we have the case for Intel cards that all_iftypes equal to 0b1100 but used_iftypes equal to 0b0010 hence we hit 'goto cont' to miss the 'return 0' and now get EBUSY.

Liang identified f8cdddb8d61d ("cfg80211: check iface combinations only when iface is running") as part of the fix (now in 3.4.6)

However, things still weren't right unless he also cherry picked the 8e8b41f9d8c8e6 ("cfg80211: enforce lack of interface combinations") to get the later mentioned "total == 1" check within, so that we avoid the EBUSY above. But this commit causes other regressions (as described in the commit log of the attached patch) so we didn't think it best to go that route for 3.4.x.

So, the options we considered (to fix 3.4.x stable) were:

1) cherry pick 8e8b41f9d, and all the driver specific changes it requires

2) make a sub-commit for stable that just takes the total==1 from #1.

3) patch iwlwifi/iwl-mac80211.c and add ".types = BIT(NL80211_IFTYPE_ADHOC)"

4) treat ADHOC as a universal feature that everyone has.

The following patch does #4, and in theory it could be used in mainline and then cherry picked back to stable. But we weren't 100% sure if that was the best solution, since neither of us are really wireless people, hence all the detail here.

Thanks,
Paul.
---

Liang Li (1):
cfg80211: fix combination check for ADHOC

 net/wireless/util.c | 2 ++
 1 file changed, 2 insertions(+)
Signature · 1 line
1.7.11.1
maintainer
#2 lore raw

On Wed, 2012-08-01 at 12:14 -0400, Paul Gortmaker wrote:

[...]

Quoted 13 lines

However, things still weren't right unless he also cherry picked the 8e8b41f9d8c8e6 ("cfg80211: enforce lack of interface combinations") to get the later mentioned "total == 1" check within, so that we avoid the EBUSY above. But this commit causes other regressions (as described in the commit log of the attached patch) so we didn't think it best to go that route for 3.4.x.

So, the options we considered (to fix 3.4.x stable) were:

1) cherry pick 8e8b41f9d, and all the driver specific changes it requires

2) make a sub-commit for stable that just takes the total==1 from #1.

Quoted 8 lines

3) patch iwlwifi/iwl-mac80211.c and add ".types = BIT(NL80211_IFTYPE_ADHOC)"

4) treat ADHOC as a universal feature that everyone has.

The following patch does #4, and in theory it could be used in mainline and then cherry picked back to stable. But we weren't 100% sure if that was the best solution, since neither of us are really wireless people, hence all the detail here.

Thanks for the detailed analysis. Given 8e8b41f9d, I don't think any mainline changes are actually needed?

I don't think #4 is right, not all drivers do in fact support IBSS. Making them advertise it will just cause issues.

I think #2 would be the best option.

johannes

#3 lore raw
Quoted 21 lines · [Re: [RFC/PATCH 0/1] Fix inability to configure adhoc in 3.4.x] On 01/08/2012…

On Wed, 2012-08-01 at 12:14 -0400, Paul Gortmaker wrote:

[...]

Quoted 17 lines

However, things still weren't right unless he also cherry picked the 8e8b41f9d8c8e6 ("cfg80211: enforce lack of interface combinations") to get the later mentioned "total == 1" check within, so that we avoid the EBUSY above. But this commit causes other regressions (as described in the commit log of the attached patch) so we didn't think it best to go that route for 3.4.x.

So, the options we considered (to fix 3.4.x stable) were:

1) cherry pick 8e8b41f9d, and all the driver specific changes it requires

2) make a sub-commit for stable that just takes the total==1 from #1.

3) patch iwlwifi/iwl-mac80211.c and add ".types = BIT(NL80211_IFTYPE_ADHOC)"

4) treat ADHOC as a universal feature that everyone has.

Quoted 7 lines
Quoted 4 lines

The following patch does #4, and in theory it could be used in mainline and then cherry picked back to stable. But we weren't 100% sure if that was the best solution, since neither of us are really wireless people, hence all the detail here.

Thanks for the detailed analysis. Given 8e8b41f9d, I don't think any mainline changes are actually needed?

Perhaps not. I know Liang was looking at the ath5k and ath9k changes:

9b4760e ath5k: add possible wiphy interface combinations 20c8e8d ath9k: add possible wiphy interface combinations

and thinking that the above commits plus the "total==1" change wouldn't fix any ATH multifunction cards (if they exist) in the ad-hoc use case - but we didn't have such hardware to test with.

And from what you say below, maybe they should not be, if there are cards which don't support it.

Quoted 5 lines

I don't think #4 is right, not all drivers do in fact support IBSS. Making them advertise it will just cause issues.

I think #2 would be the best option.

OK, no problem. We can do that and resend. I'll give Liang a chance to catch up on the reading (different time zone) and confirm I've captured all his descriptions properly before resending.

Thanks,
Paul.

Quoted 3 lines

johannes

maintainer
#4 lore raw
Quoted 16 lines · Paul Gortmaker
Quoted 8 lines
Quoted 8 lines

1) cherry pick 8e8b41f9d, and all the driver specific changes it requires

2) make a sub-commit for stable that just takes the total==1 from #1.

3) patch iwlwifi/iwl-mac80211.c and add ".types = BIT(NL80211_IFTYPE_ADHOC)"

4) treat ADHOC as a universal feature that everyone has.

Quoted 7 lines
Quoted 4 lines

The following patch does #4, and in theory it could be used in mainline and then cherry picked back to stable. But we weren't 100% sure if that was the best solution, since neither of us are really wireless people, hence all the detail here.

Thanks for the detailed analysis. Given 8e8b41f9d, I don't think any mainline changes are actually needed?

Quoted 8 lines

Perhaps not. I know Liang was looking at the ath5k and ath9k changes:

9b4760e ath5k: add possible wiphy interface combinations 20c8e8d ath9k: add possible wiphy interface combinations

and thinking that the above commits plus the "total==1" change wouldn't fix any ATH multifunction cards (if they exist) in the ad-hoc use case - but we didn't have such hardware to test with.

I'm not sure what you mean by "wouldn't fix" here -- the way the devices advertise their multi-virtual-interface support is that they do not support IBSS (ad-hoc) in combination with any other interface. Therefore, pure IBSS should be covered by the total==1 case?

johannes

#5 lore raw
Quoted 23 lines · [Re: [RFC/PATCH 0/1] Fix inability to configure adhoc in 3.4.x] On 01/08/2012…
Quoted 21 lines · Paul Gortmaker
Quoted 8 lines
Quoted 8 lines

1) cherry pick 8e8b41f9d, and all the driver specific changes it requires

2) make a sub-commit for stable that just takes the total==1 from #1.

3) patch iwlwifi/iwl-mac80211.c and add ".types = BIT(NL80211_IFTYPE_ADHOC)"

4) treat ADHOC as a universal feature that everyone has.

Quoted 7 lines
Quoted 4 lines

The following patch does #4, and in theory it could be used in mainline and then cherry picked back to stable. But we weren't 100% sure if that was the best solution, since neither of us are really wireless people, hence all the detail here.

Thanks for the detailed analysis. Given 8e8b41f9d, I don't think any mainline changes are actually needed?

Perhaps not. I know Liang was looking at the ath5k and ath9k changes:

9b4760e ath5k: add possible wiphy interface combinations 20c8e8d ath9k: add possible wiphy interface combinations

Quoted 8 lines
Quoted 3 lines

and thinking that the above commits plus the "total==1" change wouldn't fix any ATH multifunction cards (if they exist) in the ad-hoc use case - but we didn't have such hardware to test with.

I'm not sure what you mean by "wouldn't fix" here -- the way the devices advertise their multi-virtual-interface support is that they do not support IBSS (ad-hoc) in combination with any other interface. Therefore, pure IBSS should be covered by the total==1 case?

OK, it sounds like I/we were simply just misunderstanding the code, due to lack of wireless knowledge, and that the exclusion was intentional. We'll get the total==1 subpatch posted here tomorrow.

Thanks again for the input.
Paul.
--

Quoted 3 lines

johannes

#10 lore raw
In reply to Paul Gortmaker
Quoted 12 lines · Paul Gortmaker

Normally a single patch doesn't warrant a 0/1, but Liang did some digging on this problem and came up with important background, and several possible solutions, so I wanted to capture what he'd learned.

The issues with creating an ad-hoc network started in 3.4.3 with the cherry pick of 463454b5dbd ("cfg80211: fix interface combinations check") on intel hardware (iwl-mac80211.c) that doesn't support multi-function or virtual interfaces. Specifically, it adds this:

(quoted diff) +2 -0
+               if ((all_iftypes & used_iftypes) != used_iftypes)
+                       goto cont;
Quoted 6 lines

and we have the case for Intel cards that all_iftypes equal to 0b1100 but used_iftypes equal to 0b0010 hence we hit 'goto cont' to miss the 'return 0' and now get EBUSY.

Liang identified f8cdddb8d61d ("cfg80211: check iface combinations only when iface is running") as part of the fix (now in 3.4.6)

3.2.y also has the above two changes, so presumably also has this regression.

Ben.

Quoted 32 lines

However, things still weren't right unless he also cherry picked the 8e8b41f9d8c8e6 ("cfg80211: enforce lack of interface combinations") to get the later mentioned "total == 1" check within, so that we avoid the EBUSY above. But this commit causes other regressions (as described in the commit log of the attached patch) so we didn't think it best to go that route for 3.4.x.

So, the options we considered (to fix 3.4.x stable) were:

1) cherry pick 8e8b41f9d, and all the driver specific changes it requires

2) make a sub-commit for stable that just takes the total==1 from #1.

3) patch iwlwifi/iwl-mac80211.c and add ".types = BIT(NL80211_IFTYPE_ADHOC)"

4) treat ADHOC as a universal feature that everyone has.

The following patch does #4, and in theory it could be used in mainline and then cherry picked back to stable. But we weren't 100% sure if that was the best solution, since neither of us are really wireless people, hence all the detail here.

Thanks,
Paul.
---

Liang Li (1):
cfg80211: fix combination check for ADHOC

 net/wireless/util.c | 2 ++
 1 file changed, 2 insertions(+)
Signature · 3 lines
Ben Hutchings
Experience is directly proportional to the value of equipment destroyed.
                                                         - Carolyn Scheppner
#6 lore raw

PATCH 1/1 cfg80211: fix interface combinations check for ADHOC(IBSS)

In reply to Paul Gortmaker

From: Liang Li <[email protected]>

partial of commit 8e8b41f9d8c8e63fc92f899ace8da91a490ac573 upstream.

As part of commit 463454b5dbd8 ("cfg80211: fix interface combinations check"), this extra check was introduced:

       if ((all_iftypes & used_iftypes) != used_iftypes)
               goto cont;

However, most wireless NIC drivers did not advertise ADHOC in wiphy.iface_combinations[i].limits[] and hence we'll get -EBUSY when we bring up a ADHOC wlan with commands similar to:

 # iwconfig wlan0 mode ad-hoc && ifconfig wlan0 up

In commit 8e8b41f9d8c8e ("cfg80211: enforce lack of interface combinations"), the change below fixes the issue:

       if (total == 1)
               return 0;

But it also introduces other dependencies for stable. For example, a full cherry pick of 8e8b41f9d8c8e would introduce additional regressions unless we also start cherry picking driver specific fixes like the following:

  9b4760e  ath5k: add possible wiphy interface combinations
  1ae2fc2  mac80211_hwsim: advertise interface combinations
  20c8e8d  ath9k: add possible wiphy interface combinations

And the purpose of the 'if (total == 1)' is to cover the specific use case (IBSS, adhoc) that was mentioned above. So we just pick the specific part out from 8e8b41f9d8c8e here.

Doing so gives stable kernels a way to fix the change introduced by 463454b5dbd8, without having to make cherry picks specific to various NIC drivers.

---

3.0.35, 3.2.21 and 3.4.3 have CP of 463454b5dbd8 in them.

 net/wireless/util.c | 3 +++
 1 file changed, 3 insertions(+)
net/wireless/util.c +3 -0
index b5b6890..88bd89e 100644
@@ -974,6 +974,9 @@ int cfg80211_can_change_interface(struct cfg80211_registered_device *rdev,
 	}
 	mutex_unlock(&rdev->devlist_mtx);
 
+	if (total == 1)
+		return 0;
+
 	for (i = 0; i < rdev->wiphy.n_iface_combinations; i++) {
 		const struct ieee80211_iface_combination *c;
 		struct ieee80211_iface_limit *limits;
Signature · 1 line
1.7.12.rc1.1.gbce1580
#7 lore raw

Re: [PATCH stable] cfg80211: fix interface combinations check for ADHOC(IBSS)

Quoted 3 lines · Paul Gortmaker

From: Liang Li <[email protected]>

partial of commit 8e8b41f9d8c8e63fc92f899ace8da91a490ac573 upstream.

Added to the queue for 3.2, thanks.

Ben.

Quoted 59 lines

As part of commit 463454b5dbd8 ("cfg80211: fix interface combinations check"), this extra check was introduced:

       if ((all_iftypes & used_iftypes) != used_iftypes)
               goto cont;

However, most wireless NIC drivers did not advertise ADHOC in wiphy.iface_combinations[i].limits[] and hence we'll get -EBUSY when we bring up a ADHOC wlan with commands similar to:

 # iwconfig wlan0 mode ad-hoc && ifconfig wlan0 up

In commit 8e8b41f9d8c8e ("cfg80211: enforce lack of interface combinations"), the change below fixes the issue:

       if (total == 1)
               return 0;

But it also introduces other dependencies for stable. For example, a full cherry pick of 8e8b41f9d8c8e would introduce additional regressions unless we also start cherry picking driver specific fixes like the following:

  9b4760e  ath5k: add possible wiphy interface combinations
  1ae2fc2  mac80211_hwsim: advertise interface combinations
  20c8e8d  ath9k: add possible wiphy interface combinations

And the purpose of the 'if (total == 1)' is to cover the specific use case (IBSS, adhoc) that was mentioned above. So we just pick the specific part out from 8e8b41f9d8c8e here.

Doing so gives stable kernels a way to fix the change introduced by 463454b5dbd8, without having to make cherry picks specific to various NIC drivers.

---

3.0.35, 3.2.21 and 3.4.3 have CP of 463454b5dbd8 in them.

 net/wireless/util.c | 3 +++
 1 file changed, 3 insertions(+)
net/wireless/util.c +3 -0
index b5b6890..88bd89e 100644
@@ -974,6 +974,9 @@ int cfg80211_can_change_interface(struct cfg80211_registered_device *rdev,
 	}
 	mutex_unlock(&rdev->devlist_mtx);
 
+	if (total == 1)
+		return 0;
+
 	for (i = 0; i < rdev->wiphy.n_iface_combinations; i++) {
 		const struct ieee80211_iface_combination *c;
 		struct ieee80211_iface_limit *limits;
Signature · 3 lines
Ben Hutchings
Theory and practice are closer in theory than in practice.
                                - John Levine, moderator of comp.compilers
#8 lore raw

Patch "cfg80211: fix interface combinations check for ADHOC(IBSS)" has been added to the 3.4-stable tree

In reply to Paul Gortmaker

This is a note to let you know that I've just added the patch titled

cfg80211: fix interface combinations check for ADHOC(IBSS)

to the 3.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
cfg80211-fix-interface-combinations-check-for-adhoc-ibss.patch
and it can be found in the queue-3.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From [email protected] Mon Aug 13 11:39:55 2012

From: Paul Gortmaker <[email protected]>
Date: Thu, 2 Aug 2012 18:55:41 -0400
Subject: cfg80211: fix interface combinations check for ADHOC(IBSS)
To: Johannes Berg <[email protected]>
Cc: <[email protected]>, <[email protected]>, Liang Li <[email protected]>, <[email protected]>, Paul Gortmaker <[email protected]>
Message-ID: <[email protected]>

From: Liang Li <[email protected]>

partial of commit 8e8b41f9d8c8e63fc92f899ace8da91a490ac573 upstream.

As part of commit 463454b5dbd8 ("cfg80211: fix interface combinations check"), this extra check was introduced:

       if ((all_iftypes & used_iftypes) != used_iftypes)
               goto cont;

However, most wireless NIC drivers did not advertise ADHOC in wiphy.iface_combinations[i].limits[] and hence we'll get -EBUSY when we bring up a ADHOC wlan with commands similar to:

 # iwconfig wlan0 mode ad-hoc && ifconfig wlan0 up

In commit 8e8b41f9d8c8e ("cfg80211: enforce lack of interface combinations"), the change below fixes the issue:

       if (total == 1)
               return 0;

But it also introduces other dependencies for stable. For example, a full cherry pick of 8e8b41f9d8c8e would introduce additional regressions unless we also start cherry picking driver specific fixes like the following:

  9b4760e  ath5k: add possible wiphy interface combinations
  1ae2fc2  mac80211_hwsim: advertise interface combinations
  20c8e8d  ath9k: add possible wiphy interface combinations

And the purpose of the 'if (total == 1)' is to cover the specific use case (IBSS, adhoc) that was mentioned above. So we just pick the specific part out from 8e8b41f9d8c8e here.

Doing so gives stable kernels a way to fix the change introduced by 463454b5dbd8, without having to make cherry picks specific to various NIC drivers.

---
 net/wireless/util.c |    3 +++
 1 file changed, 3 insertions(+)
net/wireless/util.c +3 -0
@@ -974,6 +974,9 @@ int cfg80211_can_change_interface(struct
 	}
 	mutex_unlock(&rdev->devlist_mtx);
 
+	if (total == 1)
+		return 0;
+
 	for (i = 0; i < rdev->wiphy.n_iface_combinations; i++) {
 		const struct ieee80211_iface_combination *c;
 		struct ieee80211_iface_limit *limits;

Patches currently in stable-queue which might be from [email protected] are

queue-3.4/mm-mmu_notifier-fix-freed-page-still-mapped-in-secondary-mmu.patch queue-3.4/cfg80211-fix-interface-combinations-check-for-adhoc-ibss.patch

#9 lore raw

Patch "cfg80211: fix interface combinations check for ADHOC(IBSS)" has been added to the 3.0-stable tree

In reply to Paul Gortmaker

This is a note to let you know that I've just added the patch titled

cfg80211: fix interface combinations check for ADHOC(IBSS)

to the 3.0-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
cfg80211-fix-interface-combinations-check-for-adhoc-ibss.patch
and it can be found in the queue-3.0 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From [email protected] Mon Aug 13 11:39:55 2012

From: Paul Gortmaker <[email protected]>
Date: Thu, 2 Aug 2012 18:55:41 -0400
Subject: cfg80211: fix interface combinations check for ADHOC(IBSS)
To: Johannes Berg <[email protected]>
Cc: <[email protected]>, <[email protected]>, Liang Li <[email protected]>, <[email protected]>, Paul Gortmaker <[email protected]>
Message-ID: <[email protected]>

From: Liang Li <[email protected]>

partial of commit 8e8b41f9d8c8e63fc92f899ace8da91a490ac573 upstream.

As part of commit 463454b5dbd8 ("cfg80211: fix interface combinations check"), this extra check was introduced:

       if ((all_iftypes & used_iftypes) != used_iftypes)
               goto cont;

However, most wireless NIC drivers did not advertise ADHOC in wiphy.iface_combinations[i].limits[] and hence we'll get -EBUSY when we bring up a ADHOC wlan with commands similar to:

 # iwconfig wlan0 mode ad-hoc && ifconfig wlan0 up

In commit 8e8b41f9d8c8e ("cfg80211: enforce lack of interface combinations"), the change below fixes the issue:

       if (total == 1)
               return 0;

But it also introduces other dependencies for stable. For example, a full cherry pick of 8e8b41f9d8c8e would introduce additional regressions unless we also start cherry picking driver specific fixes like the following:

  9b4760e  ath5k: add possible wiphy interface combinations
  1ae2fc2  mac80211_hwsim: advertise interface combinations
  20c8e8d  ath9k: add possible wiphy interface combinations

And the purpose of the 'if (total == 1)' is to cover the specific use case (IBSS, adhoc) that was mentioned above. So we just pick the specific part out from 8e8b41f9d8c8e here.

Doing so gives stable kernels a way to fix the change introduced by 463454b5dbd8, without having to make cherry picks specific to various NIC drivers.

---
 net/wireless/util.c |    3 +++
 1 file changed, 3 insertions(+)
net/wireless/util.c +3 -0
@@ -975,6 +975,9 @@ int cfg80211_can_change_interface(struct
 	}
 	mutex_unlock(&rdev->devlist_mtx);
 
+	if (total == 1)
+		return 0;
+
 	for (i = 0; i < rdev->wiphy.n_iface_combinations; i++) {
 		const struct ieee80211_iface_combination *c;
 		struct ieee80211_iface_limit *limits;

Patches currently in stable-queue which might be from [email protected] are

queue-3.0/mm-mmu_notifier-fix-freed-page-still-mapped-in-secondary-mmu.patch queue-3.0/cfg80211-fix-interface-combinations-check-for-adhoc-ibss.patch