]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
ACS: Avoid invalid interference factor when survey channel time is zero
authorKarthikeyan Periyasamy <periyasa@codeaurora.org>
Sat, 5 May 2018 05:14:41 +0000 (10:44 +0530)
committerJouni Malinen <j@w1.fi>
Tue, 15 May 2018 22:16:54 +0000 (01:16 +0300)
When the channel time is zero the interference factor calculation falls
under divide by zero operation which results in invalid (NaN =
not-a-number) interference factor value. This leads to wrong ideal
channel selection in ACS during the scenario described below.

Scenario:

In VHT80 mode, the channel 36 (first channel) gets the channel time as
zero which causes the interfactor factor to be an invalid number (NaN).
Any operations (like addition, mulitplication, divide, etc.) with NaN
value results in a NaN value, so that average factor for the primary
channel 36 got the invalid value (NaN). Since channel 36 is the first
channel, ideal factor is assigned as NaN in the first iteration. The
following iteration condition check (factor < ideal_factor) with a NaN
value fail for all other primary channels. This results in channel 36
being chosen as the ideal channel in ACS which holds a NaN value.

Logs:

ACS: Survey analysis for channel 36 (5180 MHz)
ACS: 1: min_nf=-103 interference_factor=nan nf=0 time=0 busy=0 rx=0
ACS: 2: min_nf=-103 interference_factor=0.615385 nf=-102 time=13 busy=8 rx=0
ACS: 3: min_nf=-103 interference_factor=2.45455 nf=0 time=22 busy=16 rx=0
ACS: 4: min_nf=-103 interference_factor=0.785714 nf=-103 time=42 busy=33 rx=0
ACS: 5: min_nf=-103 interference_factor=nan nf=0 time=0 busy=0 rx=0
ACS:  * interference factor average: nan
...
ACS:  * channel 36: total interference = nan
..
ACS:  * channel 149: total interference = 5.93174e-21
..
ACS: Ideal channel is 36 (5180 MHz) with total interference factor of nan

Signed-off-by: Karthikeyan Periyasamy <periyasa@codeaurora.org>
src/ap/acs.c

index aa59058946b5d92cb1e75e22c8d89118a6afc515..6d4c0416dd4251b64154bf08a980a2f27c08e950 100644 (file)
@@ -314,7 +314,7 @@ acs_survey_interference_factor(struct freq_survey *survey, s8 min_nf)
 
        /* TODO: figure out the best multiplier for noise floor base */
        factor = pow(10, survey->nf / 5.0L) +
-               (busy / total) *
+               (total ? (busy / total) : 0) *
                pow(2, pow(10, (long double) survey->nf / 10.0L) -
                    pow(10, (long double) min_nf / 10.0L));