diff mbox series

[1/3] band: return -ENOTSUP when RSSI is too low for rate estimation

Message ID 20240415151130.40389-1-prestwoj@gmail.com (mailing list archive)
State New
Headers show
Series [1/3] band: return -ENOTSUP when RSSI is too low for rate estimation | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-alpine-ci-fetch success Fetch PR
prestwoj/iwd-ci-fetch success Fetch PR
prestwoj/iwd-ci-gitlint success GitLint
prestwoj/iwd-alpine-ci-makedistcheck fail Make Distcheck Make FAIL: ../../build-aux/test-driver: line 112: 21002 Aborted (core dumped) "$@" >> "$log_file" 2>&1 make[4]: *** [Makefile:2932: test-suite.log] Error 1 make[3]: *** [Makefile:3040: check-TESTS] Error 2 make[2]: *** [Makefile:3397: check-am] Error 2 make[1]: *** [Makefile:3399: check] Error 2 make: *** [Makefile:3318: distcheck] Error 1
prestwoj/iwd-alpine-ci-build success Build - Configure
prestwoj/iwd-ci-build success Build - Configure
prestwoj/iwd-alpine-ci-makecheckvalgrind fail Make Check FAIL: ./build-aux/test-driver: line 112: 43536 Aborted (core dumped) "$@" >> "$log_file" 2>&1 make[3]: *** [Makefile:2932: test-suite.log] Error 1 make[2]: *** [Makefile:3040: check-TESTS] Error 2 make[1]: *** [Makefile:3397: check-am] Error 2 make: *** [Makefile:3399: check] Error 2
prestwoj/iwd-alpine-ci-makecheck fail Make Check FAIL: ./build-aux/test-driver: line 112: 44423 Aborted (core dumped) "$@" >> "$log_file" 2>&1 make[3]: *** [Makefile:2932: test-suite.log] Error 1 make[2]: *** [Makefile:3040: check-TESTS] Error 2 make[1]: *** [Makefile:3397: check-am] Error 2 make: *** [Makefile:3399: check] Error 2
prestwoj/iwd-ci-makecheckvalgrind fail Make Check FAIL: ./build-aux/test-driver: line 112: 55079 Aborted (core dumped) "$@" >> "$log_file" 2>&1 make[3]: *** [Makefile:2931: test-suite.log] Error 1 make[2]: *** [Makefile:3039: check-TESTS] Error 2 make[1]: *** [Makefile:3396: check-am] Error 2 make: *** [Makefile:3398: check] Error 2
prestwoj/iwd-ci-clang success clang PASS
prestwoj/iwd-ci-makecheck fail Make Check FAIL: ./build-aux/test-driver: line 112: 61335 Aborted (core dumped) "$@" >> "$log_file" 2>&1 make[3]: *** [Makefile:2931: test-suite.log] Error 1 make[2]: *** [Makefile:3039: check-TESTS] Error 2 make[1]: *** [Makefile:3396: check-am] Error 2 make: *** [Makefile:3398: check] Error 2
prestwoj/iwd-alpine-ci-incremental_build success Incremental Build with patches
prestwoj/iwd-ci-incremental_build success Incremental Build with patches
prestwoj/iwd-ci-makedistcheck fail Make Distcheck Make FAIL: ../../build-aux/test-driver: line 112: 121514 Aborted (core dumped) "$@" >> "$log_file" 2>&1 make[4]: *** [Makefile:2931: test-suite.log] Error 1 make[3]: *** [Makefile:3039: check-TESTS] Error 2 make[2]: *** [Makefile:3396: check-am] Error 2 make[1]: *** [Makefile:3398: check] Error 2 make: *** [Makefile:3317: distcheck] Error 1
prestwoj/iwd-ci-testrunner success test-runner PASS

Commit Message

James Prestwood April 15, 2024, 3:11 p.m. UTC
This was overlooked in a prior patch and causes the rate estimation
to return -ENETUNREACH if the RSSI is too low to support the
various capabilities. This return was unhandled and was treated as
if the IE was invalid which then printed a warning.

The low RSSI case should just be ignored, similar to if the IE was
not provided at all. In this case return -ENOTSUP so the caller
moves on to the next capability set.

Note: this does result in most of the estimation functions only
      returning 0 or -ENOTSUP as they do little to no validation
      on the frame, but rather just test bits. Additional
      validation could be added in the future which would be
      handled by this patch.
---
 src/band.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Denis Kenzior April 15, 2024, 6:47 p.m. UTC | #1
Hi James,

On 4/15/24 10:11, James Prestwood wrote:
> This was overlooked in a prior patch and causes the rate estimation
> to return -ENETUNREACH if the RSSI is too low to support the
> various capabilities. This return was unhandled and was treated as
> if the IE was invalid which then printed a warning.
> 
> The low RSSI case should just be ignored, similar to if the IE was
> not provided at all. In this case return -ENOTSUP so the caller
> moves on to the next capability set.

Err, why?  Just handle the error code.

> 
> Note: this does result in most of the estimation functions only
>        returning 0 or -ENOTSUP as they do little to no validation
>        on the frame, but rather just test bits. Additional
>        validation could be added in the future which would be
>        handled by this patch.
> ---
>   src/band.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)

Hmm, this set is failing CI for some reason?

Regards,
-Denis
James Prestwood April 15, 2024, 7:01 p.m. UTC | #2
Hi Denis,

On 4/15/24 11:47 AM, Denis Kenzior wrote:
> Hi James,
>
> On 4/15/24 10:11, James Prestwood wrote:
>> This was overlooked in a prior patch and causes the rate estimation
>> to return -ENETUNREACH if the RSSI is too low to support the
>> various capabilities. This return was unhandled and was treated as
>> if the IE was invalid which then printed a warning.
>>
>> The low RSSI case should just be ignored, similar to if the IE was
>> not provided at all. In this case return -ENOTSUP so the caller
>> moves on to the next capability set.
>
> Err, why?  Just handle the error code.

Seemed better to do this than checking for 2 return codes. And IMO "Not 
Supported" actually describes the situation better than "Network is 
unreachable".

But I don't have a strong preference either way, if you prefer checking 
both we can do that too.

>
>>
>> Note: this does result in most of the estimation functions only
>>        returning 0 or -ENOTSUP as they do little to no validation
>>        on the frame, but rather just test bits. Additional
>>        validation could be added in the future which would be
>>        handled by this patch.
>> ---
>>   src/band.c | 8 ++++----
>>   1 file changed, 4 insertions(+), 4 deletions(-)
>
> Hmm, this set is failing CI for some reason?
Ah, good catch CI :) its because test-band was expecting -EBADMSG when 
all MCS' were unsupported. Really this is a valid IE so we shouldn't 
expect -EBADMSG there but we do. I'll have to change this, or check for 
-ENETUNREACH if we go back to that.
>
> Regards,
> -Denis
Denis Kenzior April 15, 2024, 7:07 p.m. UTC | #3
Hi James,

> 
> Seemed better to do this than checking for 2 return codes. And IMO "Not 
> Supported" actually describes the situation better than "Network is unreachable".

Well, it is supported, just not reachable ;)

> 
> But I don't have a strong preference either way, if you prefer checking both we 
> can do that too.

I rather we check both, since unit tests in particular would probably use the 
extra information.

>> Hmm, this set is failing CI for some reason?
> Ah, good catch CI :) its because test-band was expecting -EBADMSG when all MCS' 
> were unsupported. Really this is a valid IE so we shouldn't expect -EBADMSG 
> there but we do. I'll have to change this, or check for -ENETUNREACH if we go 
> back to that.

Heh :)

Regards,
-Denis
diff mbox series

Patch

diff --git a/src/band.c b/src/band.c
index 11cd965e..d71380ae 100644
--- a/src/band.c
+++ b/src/band.c
@@ -121,7 +121,7 @@  int band_estimate_nonht_rate(const struct band *band,
 	}
 
 	if (!max_rate)
-		return -ENETUNREACH;
+		return -ENOTSUP;
 
 	*out_data_rate = max_rate * 500000;
 	return 0;
@@ -319,7 +319,7 @@  int band_estimate_ht_rx_rate(const struct band *band,
 				rssi, sgi, out_data_rate))
 		return 0;
 
-	return -ENETUNREACH;
+	return -ENOTSUP;
 }
 
 static bool find_best_mcs_vht(uint8_t max_index, enum ofdm_channel_width width,
@@ -502,7 +502,7 @@  try_vht80:
 				rssi, nss, sgi, out_data_rate))
 		return 0;
 
-	return -ENETUNREACH;
+	return -ENOTSUP;
 }
 
 /*
@@ -678,7 +678,7 @@  int band_estimate_he_rx_rate(const struct band *band, const uint8_t *hec,
 	}
 
 	if (!rate)
-		return -EBADMSG;
+		return -ENOTSUP;
 
 	*out_data_rate = rate;