git: f1a110f1f0f2 - main - LinuxKPI: 802.11: fix lkpi_scan_ies_add() channel lookup

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Fri, 06 Jun 2025 16:29:39 UTC
The branch main has been updated by bz:

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

commit f1a110f1f0f2ef83758f7d0a984b14f512ea00fd
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2025-06-05 21:53:35 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2025-06-06 16:27:59 +0000

    LinuxKPI: 802.11: fix lkpi_scan_ies_add() channel lookup
    
    When looking up the channel we may not get a result if no flags are
    passed in as net80211 channel list setup and lookup coding requires a
    matching flag (band).  So pass in IEEE80211_CHAN_[AG] depending on band
    to increase the chances of finding a base channel and from that derive
    rates, etc.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      3 days
---
 sys/compat/linuxkpi/common/src/linux_80211.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c
index 4c511eeba388..2721aa84b9fd 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211.c
+++ b/sys/compat/linuxkpi/common/src/linux_80211.c
@@ -4118,12 +4118,26 @@ lkpi_scan_ies_add(uint8_t *p, struct ieee80211_scan_ies *scan_ies,
 		channels = supband->channels;
 		chan = NULL;
 		for (i = 0; i < supband->n_channels; i++) {
+			uint32_t flags;
 
 			if (channels[i].flags & IEEE80211_CHAN_DISABLED)
 				continue;
 
+			flags = 0;
+			switch (band) {
+			case NL80211_BAND_2GHZ:
+				flags |= IEEE80211_CHAN_G;
+				break;
+			case NL80211_BAND_5GHZ:
+				flags |= IEEE80211_CHAN_A;
+				break;
+			default:
+				panic("%s:%d: unupported band %d\n",
+				    __func__, __LINE__, band);
+			}
+
 			chan = ieee80211_find_channel(ic,
-			    channels[i].center_freq, 0);
+			    channels[i].center_freq, flags);
 			if (chan != NULL)
 				break;
 		}