linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mac80211: choosing first channel from the list
@ 2020-10-19 10:20 Karthikeyan Kathirvel
  2020-10-26  9:59 ` Johannes Berg
  0 siblings, 1 reply; 2+ messages in thread
From: Karthikeyan Kathirvel @ 2020-10-19 10:20 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, Karthikeyan Kathirvel

Though the first channel from sband channel list is invalid
or disabled still mac80211 is choosing this disabled channel
as a default channel for monitor interface. This will end-up
in choosing wrong channel.

Fixed by assigning the first available valid or enabled channel
to the respective radios.

Signed-off-by: Karthikeyan Kathirvel <kathirve@codeaurora.org>
---

v2:
	rebased

 net/mac80211/main.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index b4a2efe..a4aefd6 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -982,8 +982,15 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
 			continue;
 
 		if (!dflt_chandef.chan) {
+			/*
+			 * Assigning the first enabled channel to dflt_chandef from the
+			 * list of channels available specific to country
+			 */
+			for (i = 0; i < sband->n_channels; i++)
+				if (!(sband->channels[i].flags & IEEE80211_CHAN_DISABLED))
+					break;
 			cfg80211_chandef_create(&dflt_chandef,
-						&sband->channels[0],
+						&sband->channels[i == sband->n_channels ? 0 : i],
 						NL80211_CHAN_NO_HT);
 			/* init channel we're on */
 			if (!local->use_chanctx && !local->_oper_chandef.chan) {
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] mac80211: choosing first channel from the list
  2020-10-19 10:20 [PATCH] mac80211: choosing first channel from the list Karthikeyan Kathirvel
@ 2020-10-26  9:59 ` Johannes Berg
  0 siblings, 0 replies; 2+ messages in thread
From: Johannes Berg @ 2020-10-26  9:59 UTC (permalink / raw)
  To: Karthikeyan Kathirvel; +Cc: linux-wireless

On Mon, 2020-10-19 at 15:50 +0530, Karthikeyan Kathirvel wrote:
> Though the first channel from sband channel list is invalid
> or disabled still mac80211 is choosing this disabled channel
> as a default channel for monitor interface. This will end-up
> in choosing wrong channel.
> 
> Fixed by assigning the first available valid or enabled channel
> to the respective radios.

Please fix the subject.

johannes


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-10-26 10:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-19 10:20 [PATCH] mac80211: choosing first channel from the list Karthikeyan Kathirvel
2020-10-26  9:59 ` Johannes Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).