mac80211: select the first available channel for 5GHz interfaces
authorDavide Fioravanti <pantanastyle@gmail.com>
Thu, 17 Sep 2020 13:40:27 +0000 (15:40 +0200)
committerDavid Bauer <mail@david-bauer.net>
Sun, 20 Sep 2020 15:52:25 +0000 (17:52 +0200)
Some 5GHz wifi interfaces, especially in Tri-band routers, can't use
channel 36. In these cases, the default configuration for 5GHz
interfaces, once enabled, doesn't work.

This patch selects the first non-disabled channel for 5GHz interfaces.

Signed-off-by: Davide Fioravanti <pantanastyle@gmail.com>
package/kernel/mac80211/files/lib/wifi/mac80211.sh

index be9c53792635e6c499615c0dc47617e0adbc61e4..c0fbfbe5a8e3437f89ed94e09dadfb02c04224f4 100644 (file)
@@ -82,9 +82,9 @@ detect_mac80211() {
 
                iw phy "$dev" info | grep -q 'Capabilities:' && htmode=HT20
 
-               iw phy "$dev" info | grep -q '5180 MHz' && {
+               iw phy "$dev" info | grep -q '\* 5... MHz \[' && {
                        mode_band="a"
-                       channel="36"
+                       channel=$(iw phy "$dev" info | grep '\* 5... MHz \[' | grep '(disabled)' -v -m 1 | sed 's/[^[]*\[\|\].*//g')
                        iw phy "$dev" info | grep -q 'VHT Capabilities' && htmode="VHT80"
                }