git: f2a66c84c972 - stable/13 - LinuxKPI: 802.11: get rid of lkpi_ic_getradiocaps warnings

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Sun, 20 Feb 2022 18:15:38 UTC
The branch stable/13 has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=f2a66c84c972dbeae151d1432a894c64eb432eaf

commit f2a66c84c972dbeae151d1432a894c64eb432eaf
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2022-02-14 22:29:38 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2022-02-20 16:24:32 +0000

    LinuxKPI: 802.11: get rid of lkpi_ic_getradiocaps warnings
    
    Users are seeing warnings about 2 channels (1 per band)
    triggered by an ioctl from wpa_supplicant usually:
            lkpi_ic_getradiocaps: Adding chan ... returned error 55
    This was an early FAQ.
    
    Check the current number of channels against maxchans and the return
    code from net80211. In case net80211 reports that we reached the limit
    do not print the warning and do not try to add further channels.
    
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit cee56e77d77909df69624cc707a571647651c853)
---
 sys/compat/linuxkpi/common/src/linux_80211.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c
index beb2b03f0498..c69df86c3fa2 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211.c
+++ b/sys/compat/linuxkpi/common/src/linux_80211.c
@@ -2579,7 +2579,7 @@ lkpi_ic_getradiocaps(struct ieee80211com *ic, int maxchan,
 #endif
 
 		channels = hw->wiphy->bands[NL80211_BAND_2GHZ]->channels;
-		for (i = 0; i < nchans; i++) {
+		for (i = 0; i < nchans && *n < maxchan; i++) {
 			uint32_t nflags = 0;
 			int cflags = chan_flags;
 
@@ -2606,14 +2606,15 @@ lkpi_ic_getradiocaps(struct ieee80211com *ic, int maxchan,
 			    channels[i].hw_value, channels[i].center_freq,
 			    channels[i].max_power,
 			    nflags, bands, chan_flags);
-			if (error != 0) {
+			/* net80211::ENOBUFS: *n >= maxchans */
+			if (error != 0 && error != ENOBUFS)
 				printf("%s: %s: Adding chan %u/%u/%#x/%#x/%#x/%#x "
 				    "returned error %d\n", ic->ic_name,
 				    __func__, channels[i].hw_value,
 				    channels[i].center_freq, channels[i].flags,
 				    nflags, chan_flags, cflags, error);
+			if (error != 0)
 				break;
-			}
 		}
 	}
 
@@ -2648,7 +2649,7 @@ lkpi_ic_getradiocaps(struct ieee80211com *ic, int maxchan,
 #endif
 
 		channels = hw->wiphy->bands[NL80211_BAND_5GHZ]->channels;
-		for (i = 0; i < nchans; i++) {
+		for (i = 0; i < nchans && *n < maxchan; i++) {
 			uint32_t nflags = 0;
 			int cflags = chan_flags;
 
@@ -2675,14 +2676,15 @@ lkpi_ic_getradiocaps(struct ieee80211com *ic, int maxchan,
 			    channels[i].hw_value, channels[i].center_freq,
 			    channels[i].max_power,
 			    nflags, bands, chan_flags);
-			if (error != 0) {
+			/* net80211::ENOBUFS: *n >= maxchans */
+			if (error != 0 && error != ENOBUFS)
 				printf("%s: %s: Adding chan %u/%u/%#x/%#x/%#x/%#x "
 				    "returned error %d\n", ic->ic_name,
 				    __func__, channels[i].hw_value,
 				    channels[i].center_freq, channels[i].flags,
 				    nflags, chan_flags, cflags, error);
+			if (error != 0)
 				break;
-			}
 		}
 	}
 }