diff mbox series

station: check disabled band configuration in station_init

Message ID 20231002113213.3852482-1-prestwoj@gmail.com (mailing list archive)
State Accepted, archived
Headers show
Series station: check disabled band configuration in station_init | expand

Commit Message

James Prestwood Oct. 2, 2023, 11:32 a.m. UTC
For IWD to work correctly either 2.4GHz or 5GHz bands must be enabled
(even for 6GHz to work). Check this and don't allow IWD to initialize
if both 2.4 and 5GHz is disabled.
---
 src/station.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

Comments

Denis Kenzior Oct. 3, 2023, 4:33 p.m. UTC | #1
Hi James,

On 10/2/23 06:32, James Prestwood wrote:
> For IWD to work correctly either 2.4GHz or 5GHz bands must be enabled
> (even for 6GHz to work). Check this and don't allow IWD to initialize
> if both 2.4 and 5GHz is disabled.
> ---
>   src/station.c | 20 +++++++++++++-------
>   1 file changed, 13 insertions(+), 7 deletions(-)
> 

Applied, thanks.

Regards,
-Denis
diff mbox series

Patch

diff --git a/src/station.c b/src/station.c
index a34d8ce3..f24b9aca 100644
--- a/src/station.c
+++ b/src/station.c
@@ -5203,6 +5203,19 @@  static void station_known_networks_changed(enum known_networks_event event,
 
 static int station_init(void)
 {
+	if (scan_get_band_rank_modifier(BAND_FREQ_2_4_GHZ))
+		allowed_bands |= BAND_FREQ_2_4_GHZ;
+	if (scan_get_band_rank_modifier(BAND_FREQ_5_GHZ))
+		allowed_bands |= BAND_FREQ_5_GHZ;
+	if (scan_get_band_rank_modifier(BAND_FREQ_6_GHZ))
+		allowed_bands |= BAND_FREQ_6_GHZ;
+
+	if (!(allowed_bands & (BAND_FREQ_2_4_GHZ | BAND_FREQ_5_GHZ))) {
+		l_error("At least 2.4GHz and 5GHz bands must be enabled for "
+			"IWD to start, check [Rank].BandModifier* setting");
+		return -ENOTSUP;
+	}
+
 	station_list = l_queue_new();
 	netdev_watch = netdev_watch_add(station_netdev_watch, NULL, NULL);
 	l_dbus_register_interface(dbus_get_bus(), IWD_STATION_INTERFACE,
@@ -5259,13 +5272,6 @@  static int station_init(void)
 						station_known_networks_changed,
 						NULL, NULL);
 
-	if (scan_get_band_rank_modifier(BAND_FREQ_2_4_GHZ))
-		allowed_bands |= BAND_FREQ_2_4_GHZ;
-	if (scan_get_band_rank_modifier(BAND_FREQ_5_GHZ))
-		allowed_bands |= BAND_FREQ_5_GHZ;
-	if (scan_get_band_rank_modifier(BAND_FREQ_6_GHZ))
-		allowed_bands |= BAND_FREQ_6_GHZ;
-
 	return 0;
 }