[PATCH 2/4] ACS: Fix ACS not selecting the best channel in the segment

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch fixes the following bugs about selecting the best channels
in the segment:
1. The 'update_best' once became false, it never becomes true again.
   In other word, if one of the channel in the segment is not usable,
   the remaining channels in the segment were never able to be the best
   channel.
2. The primary channel in the segment might be not usable due to the
   insufficient survey data. Therefore, it cannot be the best channel and
   we cannot take its factor/weight into account.

Co-developed-by: Money Wang <money.wang@xxxxxxxxxxxx>
Signed-off-by: Michael-CY Lee <michael-cy.lee@xxxxxxxxxxxx>
---
 src/ap/acs.c | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/src/ap/acs.c b/src/ap/acs.c
index f04c8a8d8..b571459af 100644
--- a/src/ap/acs.c
+++ b/src/ap/acs.c
@@ -793,11 +793,10 @@ acs_find_ideal_chan_mode(struct hostapd_iface *iface,
 		secondary_channel = iface->conf->secondary_channel;
 
 	for (i = 0; i < mode->num_channels; i++) {
-		double total_weight;
+		double total_weight = 0;
 		struct acs_bias *bias, tmp_bias;
-		bool update_best = true;
 
-		best = chan = &mode->channels[i];
+		chan = &mode->channels[i];
 
 		/* Since in the current ACS implementation the first channel is
 		 * always a primary channel, skip channels not available as
@@ -883,9 +882,12 @@ acs_find_ideal_chan_mode(struct hostapd_iface *iface,
 		}
 
 		factor = 0;
-		if (acs_usable_chan(chan))
+		best = NULL;
+		if (acs_usable_chan(chan)) {
 			factor = chan->interference_factor;
-		total_weight = 1;
+			total_weight = 1;
+			best = chan;
+		}
 
 		for (j = 1; j < n_chans; j++) {
 			adj_chan = acs_find_chan(iface, chan->freq +
@@ -903,15 +905,12 @@ acs_find_ideal_chan_mode(struct hostapd_iface *iface,
 			if (acs_usable_chan(adj_chan)) {
 				factor += adj_chan->interference_factor;
 				total_weight += 1;
-			} else {
-				update_best = false;
-			}
 
-			/* find the best channel in this segment */
-			if (update_best &&
-			    adj_chan->interference_factor <
-			    best->interference_factor)
-				best = adj_chan;
+				/* find the best channel in this segment */
+				if (!best || adj_chan->interference_factor <
+				    best->interference_factor)
+					best = adj_chan;
+			}
 		}
 
 		if (j != n_chans) {
@@ -972,6 +971,9 @@ acs_find_ideal_chan_mode(struct hostapd_iface *iface,
 			}
 		}
 
+		if (total_weight == 0)
+			continue;
+
 		factor /= total_weight;
 
 		bias = NULL;
-- 
2.25.1


_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux