Skip to contentSkip to conversation

mac80211: choosing first channel from the list

PATCH [email protected] 1 participant 2 messages Nov 17, 2020 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 28 lines · 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.

---

v2:
rebased

 net/mac80211/main.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
net/mac80211/main.c +3 -0
index b4a2efe..a4aefd6 100644
@@ -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

net/mac80211/main.c int ieee80211_register_hw(struct ieee80211_hw *hw) · line 996

Quoted 10 lines
net/mac80211/main.c +5 -1
+			 */
+			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) {

Please ignore this.

#2 lore raw
Quoted 26 lines · On 2020-11-17 14:28, [email protected] wrote:
Quoted 25 lines · 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.

---

v2:
rebased

 net/mac80211/main.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
net/mac80211/main.c +0 -0
index b4a2efe..a4aefd6 100644
@@ -982,8 +982,15 @@ int ieee80211_register_hw(struct ieee80211_hw 
 *hw)
 			continue;
 
Quoted 16 lines
Quoted 13 lines
net/mac80211/main.c +8 -1
 		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 */
Quoted 1 line

if (!local->use_chanctx && !local->_oper_chandef.chan) {

Please ignore this.

Corrected my identity