From gaio at lilliput.linux.it  Mon Nov  1 13:41:01 2021
From: gaio at lilliput.linux.it (Marco Gaiarin)
Date: Mon, 1 Nov 2021 21:41:01 +0100
Subject: wpa_psk_radius info...
In-Reply-To: <20211015205130.GB512173@w1.fi>;
 from SmartGate on Mon, Nov 01, 2021 at 22:06:01PM +0100
References: <jhmg3i-1rq.ln1@hermione.lilliput.linux.it>
 <20211015205130.GB512173@w1.fi>
Message-ID: <rvv55i-4a43.ln1@hermione.lilliput.linux.it>

Mandi! Jouni Malinen
  In chel di` si favelave...

> for this functionality where a python script using pyrad implements a
> minimal RADIUS authentication server for this: build_tunnel_password()
> function at https://w1.fi/cgit/hostap/tree/tests/hwsim/test_radius.py#n1151

Really there's no examples out there? I'm really stuck in that, trying to
figure out how to implement it client side (hostapd on LEDE) and server side
(FreeRadius on Debian)...

Someone can help me? Thanks.

-- 
  E sempre allegri bisogna stare, che il nostro piangere fa male al Re
  fa male al ricco, al Cardinale,
  diventan tristi se noi piangiam...			(Fo, Jannacci)




From hellousers1987 at gmail.com  Mon Nov  1 23:31:59 2021
From: hellousers1987 at gmail.com (Hello Users)
Date: Tue, 2 Nov 2021 12:01:59 +0530
Subject: Hostapd 2.9 support for configuring 2 server certificates
In-Reply-To: <CAO7o39j_M7rpuW922pA4aX0-cMsq5T6cuLJ-=_9GCztBMHsx1w@mail.gmail.com>
References: <CAO7o39icbdZiW1q6VptCrPphh7W840kgSp=fGML_PkbWwkFL8Q@mail.gmail.com>
 <20211015205531.GC512173@w1.fi>
 <CAO7o39j_M7rpuW922pA4aX0-cMsq5T6cuLJ-=_9GCztBMHsx1w@mail.gmail.com>
Message-ID: <CAO7o39g1azew3-4ph5_MG70VBTCevdf-MbEx6=FStNHhoRcqAg@mail.gmail.com>

Hi Jouni,

Could you please help me to sort out the issue in configuring 2 server
certificates at hostapd.
The already configured server certificate is about to be expired and
requirement is to support both old and new certifcates during the
transition period.

>How did you try to configure this? Did you follow the example and
documentation shown in hostapd/hostapd.conf for
server_cert2/private_key2/private_key_passwd2?

Yes, as per the documentation in hostapd.conf, I configured it as
below. ca_cert is having the certificate authority for both of these
certificates
ca_cert=/tmp/certs/ca-chain.cert.pem
server_cert=/tmp/certs/radiussrv.cert.pem
private_key=/tmp/certs/radiussrv.key.pem
private_key2=/tmp/tstserver.p12
private_key_passwd2=gwvajjjkgnap

With debug prints, we usually get the configured certificate dump
after hostapd initialization in hostapd:tls_global_set_params(). So
there it dumps only the 2nd certificate .i.e. 1st certificate is
always overwritten. I was able to connect with both of these
certificates if it is configured individually. Issue happens when 2
certificates are configured at a time. So is it really possible for
configuring 2 certificates at server side so that based on client
capability it connects with appropriate certificates ?

>Please also note the comment about the number of deployed station/supplicant
implementations having interoperability issues with this capability.

So does that mean we should not go for this option ?

Regards,
Jincy S Sam


On Sun, Oct 17, 2021 at 9:49 AM Hello Users <hellousers1987 at gmail.com> wrote:
>
> Thanks Jouni for your reply.
>
> >How did you try to configure this? Did you follow the example and
> documentation shown in hostapd/hostapd.conf for
> server_cert2/private_key2/private_key_passwd2?
>
> Yes, as per the documentation in hostapd.conf, I configured it as
> below. ca_cert is having the certificate authority for both of these
> certificates
> ca_cert=/tmp/certs/ca-chain.cert.pem
> server_cert=/tmp/certs/radiussrv.cert.pem
> private_key=/tmp/certs/radiussrv.key.pem
> private_key2=/tmp/tstserver.p12
> private_key_passwd2=gwvajjjkgnap
>
> With debug prints, we usually get the configured certificate dump
> after hostapd initialization in hostapd:tls_global_set_params(). So
> there it dumps only the 2nd certificate .i.e. 1st certificate is
> always overwritten. I was able to connect with both of these
> certificates if it is configured individually. Issue happens when 2
> certificates are configured at a time.
> So is it really possible for configuring 2 certificates at server side
> so that based on client capability it connects with appropriate
> certificates ?
>
>
> >Please also note the comment about the number of deployed station/supplicant
> implementations having interoperability issues with this capability.
>
> So does that mean we should not go for this option ?
>
> Thanks and regards.
>
> On Sat, Oct 16, 2021 at 2:25 AM Jouni Malinen <j at w1.fi> wrote:
> >
> > On Mon, Oct 11, 2021 at 06:10:11PM +0530, Hello Users wrote:
> > > Please help me in understanding the below feature.
> > > As per hostapd 2.9 change logs, it mentions support to configure 2
> > > server certificates/keys(RSA/ECC). But when I tried to configure, it
> > > only took/connected with the 2nd configured certificate. The 1st
> > > configured certificate is always overwritten. What needs to be done
> > > here to get the client connected with either of the certificates?
> >
> > How did you try to configure this? Did you follow the example and
> > documentation shown in hostapd/hostapd.conf for
> > server_cert2/private_key2/private_key_passwd2?
> >
> > Please also note the comment about number of deployed station/supplicant
> > implementations having interoperability issues with this capability.
> >
> > --
> > Jouni Malinen                                            PGP id EFC895FA


From lorenzo at kernel.org  Mon Nov  1 01:33:56 2021
From: lorenzo at kernel.org (Lorenzo Bianconi)
Date: Mon, 1 Nov 2021 09:33:56 +0100
Subject: [PATCH 4/6] bss coloring: add the switch_color handler to the
 nl80211 driver
In-Reply-To: <447eb809f93929e57ddb3c1f9efdd788aaac0fb4.camel@mediatek.com>
References: <3602d12247be5d7a335ee9e3d57e04664256712b.1631091271.git.ryder.lee@mediatek.com>
 <eba9d1024574df24120c302c1e2993a5bf7dac43.1631091272.git.ryder.lee@mediatek.com>
 <447eb809f93929e57ddb3c1f9efdd788aaac0fb4.camel@mediatek.com>
Message-ID: <YX+mdBXvFwsdvz/c@lore-desk>

> On Wed, 2021-09-08 at 17:18 +0800, Ryder Lee wrote:
> > From: John Crispin <john at phrozen.org>
> > 
> > In order to start the CCA process we need to send
> > NL80211_CMD_COLOR_CHANGE
> > to the kernel. This patch adds the required code.
> > 
> > Co-developed-by: Lorenzo Bianconi <lorenzo at kernel.org>
> > Signed-off-by: Lorenzo Bianconi <lorenzo at kernel.org>
> > Signed-off-by: John Crispin <john at phrozen.org>
> > Signed-off-by: Ryder Lee <ryder.lee at mediatek.com>
> > ---
> >  src/drivers/driver_nl80211.c | 79
> > ++++++++++++++++++++++++++++++++++++
> >  1 file changed, 79 insertions(+)
> 
> Hi Jouni,
> 
> Any comments on this series?

I guess the kernel part is stable now so we can move on with userspace one.

Regards,
Lorenzo

> 
> Ryder
> 
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/hostap/attachments/20211101/1a8916f4/attachment.sig>

From neustradamus at hotmail.com  Tue Nov  2 05:55:39 2021
From: neustradamus at hotmail.com (* Neustradamus *)
Date: Tue, 2 Nov 2021 12:55:39 +0000
Subject: hostapd/wpa_supplicant 2.9.1 or 2.10 release with CVE fixes
 (2019-2020-2021) after more 2 years?
Message-ID: <PR3PR05MB7146DFF5E0BDFD3B23A0123BCB8B9@PR3PR05MB7146.eurprd05.prod.outlook.com>

Hello Team,

It is possible to have a 2.9.1 or 2.10 release with CVE fixes?
- https://w1.fi/security/
- https://w1.fi/security/2019-7/
- https://w1.fi/security/2020-1/
- https://w1.fi/security/2020-2/
- https://w1.fi/security/2021-1/

The current version is 2.9 (2019-08-07):
- https://w1.fi/cgit/hostap/

Already more 2 years without fixes.

A lot of projects have vulnerabilities because no official new build since 2019-08-07.

I am not the first to inform you about this major security problem.

Thanks in advance.

Regards,

Neustradamus

From worker at cksn.tk  Tue Nov  2 06:17:44 2021
From: worker at cksn.tk (worker at cksn.tk)
Date: Tue, 2 Nov 2021 14:17:44 +0100
Subject: Multi-PSK on Hostapd
Message-ID: <6bc398f1-0c82-eaf5-fd7c-0c02b9d76b4e@cksn.tk>

hi,

i want to attach to this discussion: 
http://lists.infradead.org/pipermail/hostap/2021-August/039806.html

is there any chance to implement this feature?

regards, volker.



From andrew at shadura.me  Tue Nov  2 06:53:01 2021
From: andrew at shadura.me (Andrej Shadura)
Date: Tue, 02 Nov 2021 14:53:01 +0100
Subject: hostapd/wpa_supplicant 2.9.1 or 2.10 release with CVE fixes
 (2019-2020-2021) after more 2 years?
In-Reply-To: <PR3PR05MB7146DFF5E0BDFD3B23A0123BCB8B9@PR3PR05MB7146.eurprd05.prod.outlook.com>
References: <PR3PR05MB7146DFF5E0BDFD3B23A0123BCB8B9@PR3PR05MB7146.eurprd05.prod.outlook.com>
Message-ID: <8754b662-72c0-4ecc-8c8a-1b702dbec951@www.fastmail.com>

Hi,

On Tue, 2 Nov 2021, at 13:55, * Neustradamus * wrote:
> It is possible to have a 2.9.1 or 2.10 release with CVE fixes?
> - https://w1.fi/security/
> - https://w1.fi/security/2019-7/
> - https://w1.fi/security/2020-1/
> - https://w1.fi/security/2020-2/
> - https://w1.fi/security/2021-1/
>
> The current version is 2.9 (2019-08-07):
> - https://w1.fi/cgit/hostap/
>
> Already more 2 years without fixes.
>
> A lot of projects have vulnerabilities because no official new build 
> since 2019-08-07.
>
> I am not the first to inform you about this major security problem.

Although I do agree a release would be great, but in fact most if not all major users follow security advisories and apply patches provided by the project. If you know of a hostapd downstream that doesn?t, I think you should talk to them and ask them to pull these patches.

-- 
Cheers,
  Andrej


From j at w1.fi  Wed Nov  3 04:21:46 2021
From: j at w1.fi (Jouni Malinen)
Date: Wed, 3 Nov 2021 13:21:46 +0200
Subject: [PATCH] P2P: Fix wpa_supplicant build when CONFIG_P2P=n
In-Reply-To: <20210904130132.1777-1-alexk@zuma.ai>
References: <20210904130132.1777-1-alexk@zuma.ai>
Message-ID: <20211103112146.GA6838@w1.fi>

On Sat, Sep 04, 2021 at 02:01:32PM +0100, Alex Kiernan wrote:
> diff --git a/wpa_supplicant/ap.c b/wpa_supplicant/ap.c
> @@ -239,6 +239,7 @@ static void wpas_conf_ap_he_6ghz(struct wpa_supplicant *wpa_s,
> +#ifdef CONFIG_P2P
>  	if (is_chanwidth_40_80 && ssid->p2p_group &&
>  	    get_max_oper_chwidth_6ghz(ssid->max_oper_chwidth) >= 40) {
>  		conf->secondary_channel =
> @@ -254,6 +255,7 @@ static void wpas_conf_ap_he_6ghz(struct wpa_supplicant *wpa_s,
>  	if ((is_chanwidth_40_80 || is_chanwidth_160) && ssid->p2p_group &&
>  	    get_max_oper_chwidth_6ghz(ssid->max_oper_chwidth) >= 80)
>  		wpas_conf_ap_vht(wpa_s, ssid, conf, mode);
> +#endif
>  }

This would result in a number of compiler warnings due to unused
variables within the function and an unused static function for the case
where CONFIG_P2P is not defined. I'll apply a more generic way of making
this full function conditional based on this patch:
http://patchwork.ozlabs.org/project/hostap/patch/20211031230337.23390-1-masashi.honma at gmail.com/
 
-- 
Jouni Malinen                                            PGP id EFC895FA


From j at w1.fi  Wed Nov  3 08:01:20 2021
From: j at w1.fi (Jouni Malinen)
Date: Wed, 3 Nov 2021 17:01:20 +0200
Subject: [PATCH] wolfSSL: Fix a link error when WPS NFC is disabled
In-Reply-To: <20211027011057.39631-1-masashi.honma@gmail.com>
References: <20211027011057.39631-1-masashi.honma@gmail.com>
Message-ID: <20211103150120.GA1351725@w1.fi>

Thanks, applied.
 
-- 
Jouni Malinen                                            PGP id EFC895FA


From j at w1.fi  Wed Nov  3 08:01:47 2021
From: j at w1.fi (Jouni Malinen)
Date: Wed, 3 Nov 2021 17:01:47 +0200
Subject: Complete removal of openssl as dependency for DPP
In-Reply-To: <20211029090533.3713530-1-cedric.izoard@ceva-dsp.com>
References: <20211029090533.3713530-1-cedric.izoard@ceva-dsp.com>
Message-ID: <20211103150147.GB1351725@w1.fi>

On Fri, Oct 29, 2021 at 11:05:29AM +0200, Cedric Izoard wrote:
> First patch fix an issue in previous serie.
> 
> The next two are re-write on previously posted version:
>  - EDCH: The workaround in no longer needed when using an intermediate
>    buffer but a check of the  secret length before the copy was missing
>    in previous version
>  - dpp_bootstrap_key_der: keep specific routimne for BoringSSL but
>    move it to crypt_openssl.c
> 
> The last one update DPP test when using BoringSSL

Thanks, all four patches applied.

-- 
Jouni Malinen                                            PGP id EFC895FA


From j at w1.fi  Wed Nov  3 08:02:55 2021
From: j at w1.fi (Jouni Malinen)
Date: Wed, 3 Nov 2021 17:02:55 +0200
Subject: [PATCH v2] Fix compiler error on CONFIG_AP without CONFIG_P2P
 builds
In-Reply-To: <20211031230337.23390-1-masashi.honma@gmail.com>
References: <20211031230056.23236-1-masashi.honma@gmail.com>
 <20211031230337.23390-1-masashi.honma@gmail.com>
Message-ID: <20211103150255.GC1351725@w1.fi>

On Mon, Nov 01, 2021 at 08:03:37AM +0900, Masashi Honma wrote:

> ../src/ap/ap_drv_ops.c:163:10: error: 'struct hostapd_data' has no member named 'p2p_group'

> /home/honma/git/hostap/wpa_supplicant/ap.c:245: undefined reference to `wpas_p2p_get_sec_channel_offset_40mhz'

Thanks, applied as two commits since these are independent issues.
 
-- 
Jouni Malinen                                            PGP id EFC895FA


From gokulkumar792 at gmail.com  Wed Nov  3 09:50:20 2021
From: gokulkumar792 at gmail.com (Gokul Sivakumar)
Date: Wed,  3 Nov 2021 22:20:20 +0530
Subject: [PATCH 1/5] wlantest: properly free allocated mem and stop abrupt
 return without deinit
Message-ID: <20211103165024.3634375-1-gokulkumar792@gmail.com>

In the cases when a failure is experienced, the value "-1" is returned from
the main function without doing any cleanup or deinit.

For Example, If wlantest is started with the following set of cmd line args
then later when returning after a failure from main function, the memory
allocated as part of handling the "-p" getopt cmd line option is not freed.
To fix memleaks in this case, properly free the previously allocated memory
with the help of wlantest_deinit() before returning from main.

$ sudo valgrind --leak-check=full --show-leak-kinds=all --verbose \
> --track-origins=yes --log-file=valgrind-out.txt \
> ./wlantest -i hwsim0 -dd -c -p "asdfasdfasdfasdf" -W "abcd"
Invalid WEP key 'abcd'

Memory leak reported by Valgrind when running wlantest as mentioned above.

==513454== HEAP SUMMARY:
==513454==     in use at exit: 128 bytes in 1 blocks
==513454==   total heap usage: 4 allocs, 3 frees, 5,720 bytes allocated
==513454==
==513454== Searching for pointers to 1 not-freed blocks
==513454== Checked 76,936 bytes
==513454==
==513454== 128 bytes in 1 blocks are definitely lost in loss record 1 of 1
==513454==    at 0x483DD99: calloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==513454==    by 0x1396CA: os_zalloc (in /home/ubuntu/hostap/wlantest/wlantest)
==513454==    by 0x10C345: add_passphrase (wlantest.c:125)
==513454==    by 0x10C345: main (wlantest.c:425)
==513454==
==513454== LEAK SUMMARY:
==513454==    definitely lost: 128 bytes in 1 blocks
==513454==    indirectly lost: 0 bytes in 0 blocks
==513454==      possibly lost: 0 bytes in 0 blocks
==513454==    still reachable: 0 bytes in 0 blocks
==513454==         suppressed: 0 bytes in 0 blocks
==513454==
==513454== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

Signed-off-by: Gokul Sivakumar <gokulkumar792 at gmail.com>
---
 wlantest/wlantest.c | 81 ++++++++++++++++++++++++---------------------
 1 file changed, 44 insertions(+), 37 deletions(-)

diff --git a/wlantest/wlantest.c b/wlantest/wlantest.c
index ac20b068e..ae4eff73c 100644
--- a/wlantest/wlantest.c
+++ b/wlantest/wlantest.c
@@ -364,20 +364,22 @@ int wlantest_relog(struct wlantest *wt)
 
 int main(int argc, char *argv[])
 {
-	int c;
+	int c, ret = 0;
 	const char *read_file = NULL;
 	const char *read_wired_file = NULL;
 	const char *ifname = NULL;
 	const char *ifname_wired = NULL;
 	const char *logfile = NULL;
 	struct wlantest wt;
-	int ctrl_iface = 0;
+	int ctrl_iface = 0, eloop_init_done = 0;
 
 	wpa_debug_level = MSG_INFO;
 	wpa_debug_show_keys = 1;
 
-	if (os_program_init())
-		return -1;
+	if (os_program_init()) {
+		ret = -1;
+		goto exit;
+	}
 
 	wlantest_init(&wt);
 
@@ -397,15 +399,18 @@ int main(int argc, char *argv[])
 			wt.ethernet = 1;
 			break;
 		case 'f':
-			if (add_pmk_file(&wt, optarg) < 0)
-				return -1;
+			if (add_pmk_file(&wt, optarg) < 0) {
+				ret = -1;
+				goto deinit;
+			}
 			break;
 		case 'F':
 			wt.assume_fcs = 1;
 			break;
 		case 'h':
 			usage();
-			return 0;
+			ret = 0;
+			goto deinit;
 		case 'i':
 			ifname = optarg;
 			break;
@@ -440,54 +445,53 @@ int main(int argc, char *argv[])
 			wpa_debug_timestamp = 1;
 			break;
 		case 'T':
-			if (add_ptk_file(&wt, optarg) < 0)
-				return -1;
+			if (add_ptk_file(&wt, optarg) < 0) {
+				ret = -1;
+				goto deinit;
+			}
 			break;
 		case 'w':
 			wt.write_file = optarg;
 			break;
 		case 'W':
-			if (add_wep(&wt, optarg) < 0)
-				return -1;
+			if (add_wep(&wt, optarg) < 0) {
+				ret = -1;
+				goto deinit;
+			}
 			break;
 		default:
 			usage();
-			return -1;
+			ret = -1;
+			goto deinit;
 		}
 	}
 
 	if (ifname == NULL && ifname_wired == NULL &&
 	    read_file == NULL && read_wired_file == NULL) {
 		usage();
-		return 0;
+		ret = 0;
+		goto deinit;
 	}
 
-	if (eloop_init())
-		return -1;
+	if (eloop_init()) {
+		ret = -1;
+		goto deinit;
+	}
+	eloop_init_done = 1;
 
 	if (logfile)
 		wpa_debug_open_file(logfile);
 
-	if (wt.write_file && write_pcap_init(&wt, wt.write_file) < 0)
-		return -1;
-
-	if (wt.pcapng_file && write_pcapng_init(&wt, wt.pcapng_file) < 0)
-		return -1;
-
-	if (read_wired_file && read_wired_cap_file(&wt, read_wired_file) < 0)
-		return -1;
-
-	if (read_file && read_cap_file(&wt, read_file) < 0)
-		return -1;
-
-	if (ifname && monitor_init(&wt, ifname) < 0)
-		return -1;
-
-	if (ifname_wired && monitor_init_wired(&wt, ifname_wired) < 0)
-		return -1;
-
-	if (ctrl_iface && ctrl_init(&wt) < 0)
-		return -1;
+	if ((wt.write_file && write_pcap_init(&wt, wt.write_file) < 0) ||
+	    (wt.pcapng_file && write_pcapng_init(&wt, wt.pcapng_file) < 0) ||
+	    (read_wired_file && read_wired_cap_file(&wt, read_wired_file) < 0) ||
+	    (read_file && read_cap_file(&wt, read_file) < 0) ||
+	    (ifname && monitor_init(&wt, ifname) < 0) ||
+	    (ifname_wired && monitor_init_wired(&wt, ifname_wired) < 0) ||
+	    (ctrl_iface && ctrl_init(&wt) < 0)) {
+		ret = -1;
+		goto deinit;
+	}
 
 	eloop_register_signal_terminate(wlantest_terminate, &wt);
 
@@ -497,11 +501,14 @@ int main(int argc, char *argv[])
 		   "fcs_error=%u",
 		   wt.rx_mgmt, wt.rx_ctrl, wt.rx_data, wt.fcs_error);
 
+deinit:
 	wlantest_deinit(&wt);
 
 	wpa_debug_close_file();
-	eloop_destroy();
+	if (eloop_init_done)
+		eloop_destroy();
 	os_program_deinit();
 
-	return 0;
+exit:
+	return ret;
 }
-- 
2.25.1



From gokulkumar792 at gmail.com  Wed Nov  3 09:50:21 2021
From: gokulkumar792 at gmail.com (Gokul Sivakumar)
Date: Wed,  3 Nov 2021 22:20:21 +0530
Subject: [PATCH 2/5] wlantest: add new cli cmd to dump the help menu for all
 the supported cmds
In-Reply-To: <20211103165024.3634375-1-gokulkumar792@gmail.com>
References: <20211103165024.3634375-1-gokulkumar792@gmail.com>
Message-ID: <20211103165024.3634375-2-gokulkumar792@gmail.com>

Having a help cli cmd to view all the supported commands is helpful when
running the wlantest_cli manually instead via the python test scripts.

$ wlantest_cli help
commands:
  ping = test connection to wlantest
  terminate = terminate wlantest
  list_bss = get BSS list
  list_sta <BSSID> = get STA list
  flush = drop all collected BSS data
  clear_sta_counters <BSSID> <STA> = clear STA counters
  clear_bss_counters <BSSID> = clear BSS counters
  get_sta_counter <counter> <BSSID> <STA> = get STA counter value
  get_bss_counter <counter> <BSSID> = get BSS counter value
  inject <frame> <prot> <sender> <BSSID> <STA/ff:ff:ff:ff:ff:ff>
  send <prot> <raw frame as hex dump>
  version = get wlantest version
  add_passphrase <passphrase> = add a known passphrase
  add_wepkey <WEP key> = add a known WEP key
  info_sta <field> <BSSID> <STA> = get STA information
  info_bss <field> <BSSID> = get BSS information
  clear_tdls_counters <BSSID> <STA1> <STA2> = clear TDLS counters
  get_tdls_counter <counter> <BSSID> <STA1> <STA2> = get TDLS counter value
  get_bss_counter <counter> <BSSID> = get BSS counter value
  relog = re-open log-file (allow rolling logs)
  get_tx_tid <BSSID> <STA> <TID> = get STA TX TID counter value
  get_rx_tid <BSSID> <STA> <TID> = get STA RX TID counter value
  help = show this usage help

$ wlantest_cli help add_passphrase
commands:
  add_passphrase <passphrase> = add a known passphrase

Signed-off-by: Gokul Sivakumar <gokulkumar792 at gmail.com>
---
 wlantest/wlantest_cli.c | 58 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)

diff --git a/wlantest/wlantest_cli.c b/wlantest/wlantest_cli.c
index ad5a48dea..7e0f8444a 100644
--- a/wlantest/wlantest_cli.c
+++ b/wlantest/wlantest_cli.c
@@ -14,6 +14,8 @@
 #include "utils/edit.h"
 #include "wlantest_ctrl.h"
 
+static void print_help(FILE *stream, const char *cmd);
+static char ** wlantest_cli_cmd_list(void);
 
 static int get_cmd_arg_num(const char *str, int pos)
 {
@@ -1566,6 +1568,27 @@ static char ** complete_get_tid(int s, const char *str, int pos)
 }
 
 
+static int wlantest_cli_cmd_help(int s, int argc, char *argv[])
+{
+	print_help(stdout, argc > 0 ? argv[0] : NULL);
+	return 0;
+}
+
+
+static char ** wlantest_cli_complete_help(int s, const char *str, int pos)
+{
+	int arg = get_cmd_arg_num(str, pos);
+	char **res = NULL;
+
+	switch (arg) {
+	case 1:
+		res = wlantest_cli_cmd_list();
+		break;
+	}
+
+	return res;
+}
+
 struct wlantest_cli_cmd {
 	const char *cmd;
 	int (*handler)(int s, int argc, char *argv[]);
@@ -1623,10 +1646,45 @@ static const struct wlantest_cli_cmd wlantest_cli_commands[] = {
 	{ "get_rx_tid", cmd_get_rx_tid,
 	  "<BSSID> <STA> <TID> = get STA RX TID counter value",
 	  complete_get_tid },
+	{ "help", wlantest_cli_cmd_help,
+	  "= show this usage help", wlantest_cli_complete_help },
 	{ NULL, NULL, NULL, NULL }
 };
 
 
+/*
+ * Prints command usage, lines are padded with the specified string.
+ */
+static void print_cmd_help(FILE *stream, const struct wlantest_cli_cmd *cmd,
+			   const char *pad)
+{
+	char c;
+	size_t n;
+
+	if (cmd->usage == NULL)
+		return;
+	fprintf(stream, "%s%s ", pad, cmd->cmd);
+	for (n = 0; (c = cmd->usage[n]); n++) {
+		fprintf(stream, "%c", c);
+		if (c == '\n')
+			fprintf(stream, "%s", pad);
+	}
+	fprintf(stream, "\n");
+}
+
+
+static void print_help(FILE *stream, const char *cmd)
+{
+	int n;
+
+	fprintf(stream, "commands:\n");
+	for (n = 0; wlantest_cli_commands[n].cmd; n++) {
+		if (cmd == NULL || str_starts(wlantest_cli_commands[n].cmd, cmd))
+			print_cmd_help(stream, &wlantest_cli_commands[n], "  ");
+	}
+}
+
+
 static int ctrl_command(int s, int argc, char *argv[])
 {
 	const struct wlantest_cli_cmd *cmd, *match = NULL;
-- 
2.25.1



From gokulkumar792 at gmail.com  Wed Nov  3 09:50:22 2021
From: gokulkumar792 at gmail.com (Gokul Sivakumar)
Date: Wed,  3 Nov 2021 22:20:22 +0530
Subject: [PATCH 3/5] wlantest: remove the duplicate functions & reuse the
 definitions from cli.h
In-Reply-To: <20211103165024.3634375-1-gokulkumar792@gmail.com>
References: <20211103165024.3634375-1-gokulkumar792@gmail.com>
Message-ID: <20211103165024.3634375-3-gokulkumar792@gmail.com>

The definitions of max_args, get_cmd_arg_num() & tokenize_cmd() are already
shared by the hostapd_cli & wpa_cli commands by including the cli.h header.
So follow the same for wlantest_cli and remove the duplicate function defs.

Signed-off-by: Gokul Sivakumar <gokulkumar792 at gmail.com>
---
 wlantest/Makefile       |  1 +
 wlantest/wlantest_cli.c | 50 +----------------------------------------
 2 files changed, 2 insertions(+), 49 deletions(-)

diff --git a/wlantest/Makefile b/wlantest/Makefile
index 0045020d4..1eba3cec9 100644
--- a/wlantest/Makefile
+++ b/wlantest/Makefile
@@ -64,6 +64,7 @@ TOBJS += gcmp.o
 
 
 OBJS_cli = wlantest_cli.o
+OBJS_cli += ../src/common/cli.o
 
 _OBJS_VAR := OBJS
 include ../src/objs.mk
diff --git a/wlantest/wlantest_cli.c b/wlantest/wlantest_cli.c
index 7e0f8444a..eb7bc59ba 100644
--- a/wlantest/wlantest_cli.c
+++ b/wlantest/wlantest_cli.c
@@ -13,27 +13,11 @@
 #include "utils/eloop.h"
 #include "utils/edit.h"
 #include "wlantest_ctrl.h"
+#include "common/cli.h"
 
 static void print_help(FILE *stream, const char *cmd);
 static char ** wlantest_cli_cmd_list(void);
 
-static int get_cmd_arg_num(const char *str, int pos)
-{
-	int arg = 0, i;
-
-	for (i = 0; i <= pos; i++) {
-		if (str[i] != ' ') {
-			arg++;
-			while (i <= pos && str[i] != ' ')
-				i++;
-		}
-	}
-
-	if (arg > 0)
-		arg--;
-	return arg;
-}
-
 
 static int get_prev_arg_pos(const char *str, int pos)
 {
@@ -1730,38 +1714,6 @@ struct wlantest_cli {
 };
 
 
-#define max_args 10
-
-static int tokenize_cmd(char *cmd, char *argv[])
-{
-	char *pos;
-	int argc = 0;
-
-	pos = cmd;
-	for (;;) {
-		while (*pos == ' ')
-			pos++;
-		if (*pos == '\0')
-			break;
-		argv[argc] = pos;
-		argc++;
-		if (argc == max_args)
-			break;
-		if (*pos == '"') {
-			char *pos2 = os_strrchr(pos, '"');
-			if (pos2)
-				pos = pos2 + 1;
-		}
-		while (*pos != '\0' && *pos != ' ')
-			pos++;
-		if (*pos == ' ')
-			*pos++ = '\0';
-	}
-
-	return argc;
-}
-
-
 static void wlantest_cli_edit_cmd_cb(void *ctx, char *cmd)
 {
 	struct wlantest_cli *cli = ctx;
-- 
2.25.1



From gokulkumar792 at gmail.com  Wed Nov  3 09:50:23 2021
From: gokulkumar792 at gmail.com (Gokul Sivakumar)
Date: Wed,  3 Nov 2021 22:20:23 +0530
Subject: [PATCH 4/5] wlantest: delete each entry from the wep list before
 freeing the entry
In-Reply-To: <20211103165024.3634375-1-gokulkumar792@gmail.com>
References: <20211103165024.3634375-1-gokulkumar792@gmail.com>
Message-ID: <20211103165024.3634375-4-gokulkumar792@gmail.com>

To be consistent with how all the other dl lists like passphrase, pmk, ptk
lists are freed, delete each entry from the wep list before freeing the
entry.

Signed-off-by: Gokul Sivakumar <gokulkumar792 at gmail.com>
---
 wlantest/wlantest.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/wlantest/wlantest.c b/wlantest/wlantest.c
index ae4eff73c..b24648805 100644
--- a/wlantest/wlantest.c
+++ b/wlantest/wlantest.c
@@ -77,6 +77,13 @@ static void ptk_deinit(struct wlantest_ptk *ptk)
 }
 
 
+static void wep_deinit(struct wlantest_wep *wep)
+{
+	dl_list_del(&wep->list);
+	os_free(wep);
+}
+
+
 static void wlantest_deinit(struct wlantest *wt)
 {
 	struct wlantest_passphrase *p, *pn;
@@ -104,7 +111,7 @@ static void wlantest_deinit(struct wlantest *wt)
 	dl_list_for_each_safe(ptk, npt, &wt->ptk, struct wlantest_ptk, list)
 		ptk_deinit(ptk);
 	dl_list_for_each_safe(wep, nw, &wt->wep, struct wlantest_wep, list)
-		os_free(wep);
+		wep_deinit(wep);
 	write_pcap_deinit(wt);
 	write_pcapng_deinit(wt);
 	clear_notes(wt);
-- 
2.25.1



From gokulkumar792 at gmail.com  Wed Nov  3 09:50:24 2021
From: gokulkumar792 at gmail.com (Gokul Sivakumar)
Date: Wed,  3 Nov 2021 22:20:24 +0530
Subject: [PATCH 5/5] wlantest: add the missing "WEP Key" cmd line option (-W)
 to the usage menu
In-Reply-To: <20211103165024.3634375-1-gokulkumar792@gmail.com>
References: <20211103165024.3634375-1-gokulkumar792@gmail.com>
Message-ID: <20211103165024.3634375-5-gokulkumar792@gmail.com>

Signed-off-by: Gokul Sivakumar <gokulkumar792 at gmail.com>
---
 wlantest/wlantest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/wlantest/wlantest.c b/wlantest/wlantest.c
index b24648805..a32eb9b48 100644
--- a/wlantest/wlantest.c
+++ b/wlantest/wlantest.c
@@ -27,7 +27,7 @@ static void usage(void)
 	       "[-P<RADIUS shared secret>]\n"
 	       "         [-n<write pcapng file>]\n"
 	       "         [-w<write pcap file>] [-f<MSK/PMK file>]\n"
-	       "         [-L<log file>] [-T<PTK file>]\n");
+	       "         [-L<log file>] [-T<PTK file>] [-W<WEP key>]\n");
 }
 
 
-- 
2.25.1



From j at w1.fi  Wed Nov  3 12:02:28 2021
From: j at w1.fi (Jouni Malinen)
Date: Wed, 3 Nov 2021 21:02:28 +0200
Subject: [PATCH 1/6] bss coloring: add support for handling collision
 events and triggering CCA
In-Reply-To: <3602d12247be5d7a335ee9e3d57e04664256712b.1631091271.git.ryder.lee@mediatek.com>
References: <3602d12247be5d7a335ee9e3d57e04664256712b.1631091271.git.ryder.lee@mediatek.com>
Message-ID: <20211103190228.GA1357880@w1.fi>

On Wed, Sep 08, 2021 at 05:18:50PM +0800, Ryder Lee wrote:
> diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c
> +static void
> +hostapd_switch_color_timeout_handler(void *eloop_data, void *user_ctx);

That needs to be within #ifdef CONFIG_IEEE80211AX to avoid compiler
warnings when cONFIG_IEEE80211AX is not defined.

> +void hostapd_cleanup_cca_params(struct hostapd_data *hapd)
> +{
> +	hapd->cca_count = 0;
> +	hapd->cca_color = 0;
> +	hapd->cca_c_off_beacon = 0;
> +	hapd->cca_c_off_proberesp = 0;
> +	hapd->cca_in_progress = 0;

It would be better to use bool cca_in_progress and true/false instead of
int and 1/0.

> +static void
> +hostapd_switch_color_timeout_handler(void *eloop_data, void *user_ctx)
> +{
> +	struct hostapd_data *hapd = (struct hostapd_data *) eloop_data;
> +	struct cca_settings settings;
> +	struct os_time now;

All uses of struct os_time should be replaced with struct os_reltime to
be able to handle possible clock changes.

> +	int i, r, b, ret;

b needs to be unsigned to avoid compiler warnings.

> +	if (os_get_time(&now))

os_get_reltime

> +	/* check if there has been a recent collision */
> +	if (now.sec - hapd->last_color_collision.sec >= 10)
> +		return;

What is this trying to do? Skip changes if there has not been additional
collisions during the last 10 seconds of the previously scheduled 50
second timeout? What is that 10 seconds based on?

> +	if (i == HE_OPERATION_BSS_COLOR_MAX) {
> +		/* there are no free colors so turn bss coloring off */
> +		wpa_printf(MSG_INFO, "no free colors left, turning of BSS coloring");
> +		hapd->iface->conf->he_op.he_bss_color_disabled = 1;
> +		hapd->iface->conf->he_op.he_bss_color = 1;

Should we use random BSS color in this case similarly to the change in
https://w1.fi/cgit/hostap/commit/src?id=41ec97cd09486a6bda21f5f5b89e5242e6ade2a2

> +void
> +hostapd_switch_color(struct hostapd_data *hapd, u64 bitmap)

This function seems to be completed unused.. It would be good to include
the user for this or be clear in the commit message that the caller will
be added in another commit (patch 5/6 in this series).

> +	if (hapd->cca_in_progress)
> +		return;
> +
> +	if (os_get_time(&hapd->last_color_collision))

os_get_reltime

> +	if (!eloop_is_timeout_registered(hostapd_switch_color_timeout_handler, hapd, NULL))
> +		eloop_register_timeout(DOT11BSS_COLOR_COLLISION_AP_PERIOD, 0,
> +				       hostapd_switch_color_timeout_handler, hapd, NULL);
> +}

What is this behavior based on? DOT11BSS_COLOR_COLLISION_AP_PERIOD
definition refers to IEEE Std 802.11ax-2021, 26.17.3.5.1 which notes
that the BSS Color Disabled subfield is set to 1 if the BSS color
collision persistent for at least dot11BSSColorCollisionAPPeriod.
However, this timeout seems to be used for changing the BSS color, not
only for disabling BSS color.

> diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h
> +	int cca_in_progress;
bool

> +	struct os_time last_color_collision;

os_reltime

> diff --git a/src/common/ieee802_11_defs.h b/src/common/ieee802_11_defs.h
> +/* IEEE802.11/D6.0 - 26.17.3.5.1
> + * the minimum default timeout between color collision and color change is defined as 50s
> + */
> +#define DOT11BSS_COLOR_COLLISION_AP_PERIOD	50

That comment is a bit confusing.. IEEE Std 802.11ax-2021, 26.17.3.5.1
seems to be talking about disabling BSS color after
dot11BSSColorCollisionAPPeriod and so does the definition of this MIB
variable while this comment talks about time between the color collision
and color change which sounds quite different.

-- 
Jouni Malinen                                            PGP id EFC895FA


From j at w1.fi  Wed Nov  3 12:08:37 2021
From: j at w1.fi (Jouni Malinen)
Date: Wed, 3 Nov 2021 21:08:37 +0200
Subject: [PATCH 2/6] bss_coloring: add the code required to generate the
 CCA IE
In-Reply-To: <68581fa847cf51a25d9df106dee373d66e7628be.1631091272.git.ryder.lee@mediatek.com>
References: <3602d12247be5d7a335ee9e3d57e04664256712b.1631091271.git.ryder.lee@mediatek.com>
 <68581fa847cf51a25d9df106dee373d66e7628be.1631091272.git.ryder.lee@mediatek.com>
Message-ID: <20211103190837.GB1357880@w1.fi>

On Wed, Sep 08, 2021 at 05:18:51PM +0800, Ryder Lee wrote:
> Signed-off-by: Lorenzo Bianconi <lorenzo at kernel.org>
> diff --git a/src/ap/beacon.c b/src/ap/beacon.c
> @@ -578,11 +578,17 @@ static u8 * hostapd_gen_probe_resp(struct hostapd_data *hapd,
>  #ifdef CONFIG_IEEE80211AX
>  	if (hapd->iconf->ieee80211ax && !hapd->conf->disable_11ax) {
> +		u8 *cca_pos;
> +
>  		pos = hostapd_eid_he_capab(hapd, pos, IEEE80211_MODE_AP);
>  		pos = hostapd_eid_he_operation(hapd, pos);
>  		pos = hostapd_eid_spatial_reuse(hapd, pos);
>  		pos = hostapd_eid_he_mu_edca_parameter_set(hapd, pos);
>  		pos = hostapd_eid_he_6ghz_band_cap(hapd, pos);
> +		cca_pos = hostapd_eid_cca(hapd, pos);

The BSS Color Change Announcement element is supposed to be between the
HE Operation and the Spatial Reuse Parameter Set elements, i.e., a
couple of lines above here..

> @@ -1567,12 +1573,18 @@ int ieee802_11_build_ap_params(struct hostapd_data *hapd,
>  #ifdef CONFIG_IEEE80211AX
>  	if (hapd->iconf->ieee80211ax && !hapd->conf->disable_11ax) {
> +		u8 *cca_pos;
> +
>  		tailpos = hostapd_eid_he_capab(hapd, tailpos,
>  					       IEEE80211_MODE_AP);
>  		tailpos = hostapd_eid_he_operation(hapd, tailpos);
>  		tailpos = hostapd_eid_spatial_reuse(hapd, tailpos);
>  		tailpos = hostapd_eid_he_mu_edca_parameter_set(hapd, tailpos);
>  		tailpos = hostapd_eid_he_6ghz_band_cap(hapd, tailpos);
> +		cca_pos = hostapd_eid_cca(hapd, tailpos);

Same here.

What about the (Re)Association Response frames? Should we add the BSS
Color Change Announcement element to them as well?
 
-- 
Jouni Malinen                                            PGP id EFC895FA


From j at w1.fi  Wed Nov  3 12:19:16 2021
From: j at w1.fi (Jouni Malinen)
Date: Wed, 3 Nov 2021 21:19:16 +0200
Subject: [PATCH 6/6] bss_coloring: allow using a random starting color
In-Reply-To: <46fa29623e1fb485e9070ef9d066a57c2111bad0.1631091272.git.ryder.lee@mediatek.com>
References: <3602d12247be5d7a335ee9e3d57e04664256712b.1631091271.git.ryder.lee@mediatek.com>
 <46fa29623e1fb485e9070ef9d066a57c2111bad0.1631091272.git.ryder.lee@mediatek.com>
Message-ID: <20211103191916.GC1357880@w1.fi>

On Wed, Sep 08, 2021 at 05:18:55PM +0800, Ryder Lee wrote:
> Enhance the possible values for he_bss_color. Anything greater than 63 will
> make hostapd choose a random color.

What's the use case for this? Isn't the initial BSS color supposed to be
selected based on what BSS colors are in use by neighboring OBSSs (see
IEEE Std 802.11ax-2021, 26.17.3.2)?

If that more complete implementation looking at neighboring OBSSs is not
added, would the automatic initialization to a random value be
sufficient for now?
https://w1.fi/cgit/hostap/commit/src?id=41ec97cd09486a6bda21f5f5b89e5242e6ade2a2

> -# he_bss_color: BSS color (1-63)
> +# he_bss_color:
> +# 0 = disable
> +# 1-63 = pre-defined color
> +# 64+ =	random color
>  #he_bss_color=1

Is it really expected to be possible to configure the BSS color to be
hardcoded to be disabled? In addition, that use of multiple different
values to indicate a random color feels quite strange.

-- 
Jouni Malinen                                            PGP id EFC895FA


From j at w1.fi  Wed Nov  3 14:24:45 2021
From: j at w1.fi (Jouni Malinen)
Date: Wed, 3 Nov 2021 23:24:45 +0200
Subject: [PATCH 7/7] Remove useless variable
In-Reply-To: <20211011112437.178673-8-jeltz+hostap@auro.re>
References: <20211011112437.178673-1-jeltz+hostap@auro.re>
 <20211011112437.178673-8-jeltz+hostap@auro.re>
Message-ID: <20211103212445.GA1365795@w1.fi>

On Mon, Oct 11, 2021 at 01:24:37PM +0200, Tom Barthe wrote:
> diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c
> @@ -2321,12 +2321,11 @@ ieee802_11_set_radius_info(struct hostapd_data *hapd, struct sta_info *sta,
>  {
>  	u32 session_timeout = info->session_timeout;
>  	u32 acct_interim_interval = info->acct_interim_interval;
> -	struct vlan_description *vlan_id = &info->vlan_id;
>  	struct hostapd_sta_wpa_psk_short *psk = info->psk;
>  	char *identity = info->identity;
>  	char *radius_cui = info->radius_cui;
>  
> -	sta->default_radius_vlan = *vlan_id;
> +	sta->default_radius_vlan = info->vlan_id;

This looks a bit strange as a separate patch since that
sta->default_radius_vlan does not even exist before the earlier patches
in this series. Maybe this should be merged into the patch 5/7 instead.
 
-- 
Jouni Malinen                                            PGP id EFC895FA


From j at w1.fi  Wed Nov  3 14:28:23 2021
From: j at w1.fi (Jouni Malinen)
Date: Wed, 3 Nov 2021 23:28:23 +0200
Subject: [PATCH 5/7] Add default_radius_vlan in sta_info
In-Reply-To: <20211011112437.178673-6-jeltz+hostap@auro.re>
References: <20211011112437.178673-1-jeltz+hostap@auro.re>
 <20211011112437.178673-6-jeltz+hostap@auro.re>
Message-ID: <20211103212823.GB1365795@w1.fi>

On Mon, Oct 11, 2021 at 01:24:35PM +0200, Tom Barthe wrote:
> Used to store the vlan_description corresponding to RADIUS tag 0.

> diff --git a/src/ap/sta_info.h b/src/ap/sta_info.h
> @@ -200,8 +200,9 @@ struct sta_info {
>  	struct hostapd_sta_wpa_psk_short *psk;
> +	struct vlan_description default_radius_vlan;

This would increase the size of struct sta_info by 34*sizeof(int)
unconditionally for all cases regardless of whether this
RADIUS-controlled PSK/passphrase-to-VLAN-mapping is used. That feels a
bit excessive.. Does this really need that full data structure to be
stored? Maybe a better way of doing this would be to introduce a new
data structure that would hold both of those two members here and that
data structure would be allocated conditionally only when the
RADIUS-based design is used.
 
-- 
Jouni Malinen                                            PGP id EFC895FA


From j at w1.fi  Wed Nov  3 14:33:14 2021
From: j at w1.fi (Jouni Malinen)
Date: Wed, 3 Nov 2021 23:33:14 +0200
Subject: [PATCH 2/7] Replace some vlan_ids with vlan_descriptions
In-Reply-To: <20211011112437.178673-3-jeltz+hostap@auro.re>
References: <20211011112437.178673-1-jeltz+hostap@auro.re>
 <20211011112437.178673-3-jeltz+hostap@auro.re>
Message-ID: <20211103213314.GC1365795@w1.fi>

On Mon, Oct 11, 2021 at 01:24:32PM +0200, Tom Barthe wrote:
>  src/ap/ap_config.c                            | 23 +++++++++++----
>  src/ap/ap_config.h                            |  3 +-
>  src/ap/wpa_auth.c                             | 29 +++++++++++--------
>  src/ap/wpa_auth.h                             |  5 ++--
>  src/ap/wpa_auth_glue.c                        | 28 +++++++++---------
>  tests/fuzzing/eapol-key-auth/eapol-key-auth.c |  6 ++--
>  6 files changed, 57 insertions(+), 37 deletions(-)

> diff --git a/src/ap/wpa_auth.h b/src/ap/wpa_auth.h
> +++ b/src/ap/wpa_auth.h
> @@ -296,7 +296,7 @@ struct wpa_auth_callbacks {
>  	const u8 * (*get_psk)(void *ctx, const u8 *addr, const u8 *p2p_dev_addr,
>  			      const u8 *prev_psk, size_t *psk_len,
> -			      int *vlan_id);
> +			      struct vlan_description *vlan);

This breaks wpa_supplicant build, i.e., wpa_supplicant/ibss_rsn.c and
wpa_supplicant/mesh_rsn.c needs matching changes for the get_psk()
callback functions.

-- 
Jouni Malinen                                            PGP id EFC895FA


From j at w1.fi  Wed Nov  3 14:41:52 2021
From: j at w1.fi (Jouni Malinen)
Date: Wed, 3 Nov 2021 23:41:52 +0200
Subject: [PATCH 0/7] Support for multiple RADIUS Tunnel-* attributes
In-Reply-To: <20211011112437.178673-1-jeltz+hostap@auro.re>
References: <20211011112437.178673-1-jeltz+hostap@auro.re>
Message-ID: <20211103214152.GD1365795@w1.fi>

On Mon, Oct 11, 2021 at 01:24:30PM +0200, Tom Barthe wrote:
>   Support for RADIUS attributes filtering by tag
>   Replace some vlan_ids with vlan_descriptions
>   Add a per PSK vlan_description
>   Fix selection of Tunnel* attributes by tag
>   Add default_radius_vlan in sta_info
>   Retrieve and use a per-PSK vlan_description
>   Remove useless variable

This set seems to break most of existing VLAN functionality. At least
the following hwsim test cases fail with these patches:
ap_vlan_open ap_vlan_file_open ap_vlan_file_open2 ap_vlan_wpa2 ap_vlan_wpa2_radius_local ap_vlan_tagged ap_vlan_without_station ap_open_per_sta_vif ap_vlan_open_per_sta_vif ap_vlan_reconnect

I did not look at the details on what exactly was causing this, but
hostapd seemed to end up assigning associating stations to VLAN-ID 0
instead of the VLAN configuration in the local files.

Similarly, number of RADIUS test cases failed:
radius_acct_psk radius_acct_psk_sha256 radius_acct_ft_psk radius_psk_default ap_vlan_wpa2_psk_radius_required

These showed "Invalid VLAN ID 0" in hostapd debug log.

In general, I'm recommending running all the hwsim test cases (see
tests/hwsim/vm/README) to test against regressions. It would also be
nice to see new test cases being added for any new functionality like
the changes in this patchset to demonstrate how the feature works and to
make sure there continues to be a good testing coverage for all the
functionality and means for automatically detecting regressions (like
these test case failures here demonstrate).
 
-- 
Jouni Malinen                                            PGP id EFC895FA


From ryder.lee at mediatek.com  Wed Nov  3 23:41:41 2021
From: ryder.lee at mediatek.com (Ryder Lee)
Date: Thu, 4 Nov 2021 14:41:41 +0800
Subject: [PATCH 1/6] bss coloring: add support for handling collision
 events and triggering CCA
In-Reply-To: <20211103190228.GA1357880@w1.fi>
References: <3602d12247be5d7a335ee9e3d57e04664256712b.1631091271.git.ryder.lee@mediatek.com>
 <20211103190228.GA1357880@w1.fi>
Message-ID: <f5e53481ea240d6434ff89a147be1eb43d6be546.camel@mediatek.com>


> > (!eloop_is_timeout_registered(hostapd_switch_color_timeout_handler,
> > hapd, NULL))
> > +		eloop_register_timeout(DOT11BSS_COLOR_COLLISION_AP_PERI
> > OD, 0,
> > +				       hostapd_switch_color_timeout_han
> > dler, hapd, NULL);
> > +}
> 
> What is this behavior based on? DOT11BSS_COLOR_COLLISION_AP_PERIOD
> definition refers to IEEE Std 802.11ax-2021, 26.17.3.5.1 which notes
> that the BSS Color Disabled subfield is set to 1 if the BSS color
> collision persistent for at least dot11BSSColorCollisionAPPeriod.
> However, this timeout seems to be used for changing the BSS color,
> not
> only for disabling BSS color.

This is a series of continuous actions I think. It depends on how we
interpret the 26.17.3.5 and what's the best time to change the color,
but I think most of implementations are similar.

1. BSS color collision persistent for at least
dot11BSSColorCollisionAPPeriod.
2. BSS Color Disabled subfield is set to 1.
3. Switch color out.

> > diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h
> > +	int cca_in_progress;
> 
> bool
> 
Will do, It's better to use bool indeed. I thought of this but changed
my mind after looking at csa_in_progress, so keeping int for the sake
of consistency.

> 
> > diff --git a/src/common/ieee802_11_defs.h
> > b/src/common/ieee802_11_defs.h
> > +/* IEEE802.11/D6.0 - 26.17.3.5.1
> > + * the minimum default timeout between color collision and color
> > change is defined as 50s
> > + */
> > +#define DOT11BSS_COLOR_COLLISION_AP_PERIOD	50
> 
> That comment is a bit confusing.. IEEE Std 802.11ax-2021, 26.17.3.5.1
> seems to be talking about disabling BSS color after
> dot11BSSColorCollisionAPPeriod and so does the definition of this MIB
> variable while this comment talks about time between the color
> collision
> and color change which sounds quite different.

I will revise this comment to reflect the IEEE Std 802.11ax-2021,
26.17.3.5.1.

Thank you for reviewing I will fix other parts.

Ryder



From ryder.lee at mediatek.com  Thu Nov  4 00:00:41 2021
From: ryder.lee at mediatek.com (Ryder Lee)
Date: Thu, 4 Nov 2021 15:00:41 +0800
Subject: [PATCH 2/6] bss_coloring: add the code required to generate the
 CCA IE
In-Reply-To: <20211103190837.GB1357880@w1.fi>
References: <3602d12247be5d7a335ee9e3d57e04664256712b.1631091271.git.ryder.lee@mediatek.com>
 <68581fa847cf51a25d9df106dee373d66e7628be.1631091272.git.ryder.lee@mediatek.com>
 <20211103190837.GB1357880@w1.fi>
Message-ID: <faa8a48f4e27ced025e3ce200428b8cd153b69ed.camel@mediatek.com>

On Wed, 2021-11-03 at 21:08 +0200, Jouni Malinen wrote:
> On Wed, Sep 08, 2021 at 05:18:51PM +0800, Ryder Lee wrote:
> > Signed-off-by: Lorenzo Bianconi <lorenzo at kernel.org>
> > diff --git a/src/ap/beacon.c b/src/ap/beacon.c
> > @@ -578,11 +578,17 @@ static u8 * hostapd_gen_probe_resp(struct
> > hostapd_data *hapd,
> >  #ifdef CONFIG_IEEE80211AX
> >  	if (hapd->iconf->ieee80211ax && !hapd->conf->disable_11ax) {
> > +		u8 *cca_pos;
> > +
> >  		pos = hostapd_eid_he_capab(hapd, pos,
> > IEEE80211_MODE_AP);
> >  		pos = hostapd_eid_he_operation(hapd, pos);
> >  		pos = hostapd_eid_spatial_reuse(hapd, pos);
> >  		pos = hostapd_eid_he_mu_edca_parameter_set(hapd, pos);
> >  		pos = hostapd_eid_he_6ghz_band_cap(hapd, pos);
> > +		cca_pos = hostapd_eid_cca(hapd, pos);
> 
> The BSS Color Change Announcement element is supposed to be between
> the
> HE Operation and the Spatial Reuse Parameter Set elements, i.e., a
> couple of lines above here..
> 
> > @@ -1567,12 +1573,18 @@ int ieee802_11_build_ap_params(struct
> > hostapd_data *hapd,
> >  #ifdef CONFIG_IEEE80211AX
> >  	if (hapd->iconf->ieee80211ax && !hapd->conf->disable_11ax) {
> > +		u8 *cca_pos;
> > +
> >  		tailpos = hostapd_eid_he_capab(hapd, tailpos,
> >  					       IEEE80211_MODE_AP);
> >  		tailpos = hostapd_eid_he_operation(hapd, tailpos);
> >  		tailpos = hostapd_eid_spatial_reuse(hapd, tailpos);
> >  		tailpos = hostapd_eid_he_mu_edca_parameter_set(hapd,
> > tailpos);
> >  		tailpos = hostapd_eid_he_6ghz_band_cap(hapd, tailpos);
> > +		cca_pos = hostapd_eid_cca(hapd, tailpos);
> 
> Same here.
> 
> What about the (Re)Association Response frames? Should we add the BSS
> Color Change Announcement element to them as well?

Yes, we need to add it into assoc frames to prevent corner cases
regarding color missmatching during connection. So far, we only reuse
CSA counter attributes to implement the CCA part in kernel side, but we
plan to add an assoc attribute. It will take some time to do it, so I
think we can get the basic part accepted by hostap first and an
incremental patch afterwards. What do you think>



From ryder.lee at mediatek.com  Thu Nov  4 00:04:33 2021
From: ryder.lee at mediatek.com (Ryder Lee)
Date: Thu, 4 Nov 2021 15:04:33 +0800
Subject: [PATCH 2/6] bss_coloring: add the code required to generate the
 CCA IE
In-Reply-To: <20211103190837.GB1357880@w1.fi>
References: <3602d12247be5d7a335ee9e3d57e04664256712b.1631091271.git.ryder.lee@mediatek.com>
 <68581fa847cf51a25d9df106dee373d66e7628be.1631091272.git.ryder.lee@mediatek.com>
 <20211103190837.GB1357880@w1.fi>
Message-ID: <241817ed8005b9d40ebc446201d55e946bfd8ff7.camel@mediatek.com>

On Wed, 2021-11-03 at 21:08 +0200, Jouni Malinen wrote:
> On Wed, Sep 08, 2021 at 05:18:51PM +0800, Ryder Lee wrote:
> > Signed-off-by: Lorenzo Bianconi <lorenzo at kernel.org>
> > diff --git a/src/ap/beacon.c b/src/ap/beacon.c
> > @@ -578,11 +578,17 @@ static u8 * hostapd_gen_probe_resp(struct
> > hostapd_data *hapd,
> >  #ifdef CONFIG_IEEE80211AX
> >  	if (hapd->iconf->ieee80211ax && !hapd->conf->disable_11ax) {
> > +		u8 *cca_pos;
> > +
> >  		pos = hostapd_eid_he_capab(hapd, pos,
> > IEEE80211_MODE_AP);
> >  		pos = hostapd_eid_he_operation(hapd, pos);
> >  		pos = hostapd_eid_spatial_reuse(hapd, pos);
> >  		pos = hostapd_eid_he_mu_edca_parameter_set(hapd, pos);
> >  		pos = hostapd_eid_he_6ghz_band_cap(hapd, pos);
> > +		cca_pos = hostapd_eid_cca(hapd, pos);
> 
> The BSS Color Change Announcement element is supposed to be between
> the
> HE Operation and the Spatial Reuse Parameter Set elements, i.e., a
> couple of lines above here..
> 
> > @@ -1567,12 +1573,18 @@ int ieee802_11_build_ap_params(struct
> > hostapd_data *hapd,
> >  #ifdef CONFIG_IEEE80211AX
> >  	if (hapd->iconf->ieee80211ax && !hapd->conf->disable_11ax) {
> > +		u8 *cca_pos;
> > +
> >  		tailpos = hostapd_eid_he_capab(hapd, tailpos,
> >  					       IEEE80211_MODE_AP);
> >  		tailpos = hostapd_eid_he_operation(hapd, tailpos);
> >  		tailpos = hostapd_eid_spatial_reuse(hapd, tailpos);
> >  		tailpos = hostapd_eid_he_mu_edca_parameter_set(hapd,
> > tailpos);
> >  		tailpos = hostapd_eid_he_6ghz_band_cap(hapd, tailpos);
> > +		cca_pos = hostapd_eid_cca(hapd, tailpos);
> 
> Same here.
> 
> What about the (Re)Association Response frames? Should we add the BSS
> Color Change Announcement element to them as well?

Yes, we need to add it into assoc frames to prevent corner cases
regarding color missmatching during connection. So far, we only reuse
CSA counter attributes to implement the CCA part in kernel side, but we
plan to add an assoc attribute. It will take some time to do it, so I
think we can get the basic part accepted by hostap first and an
incremental patch afterwards. What do you think?



From ryder.lee at mediatek.com  Thu Nov  4 00:06:07 2021
From: ryder.lee at mediatek.com (Ryder Lee)
Date: Thu, 4 Nov 2021 15:06:07 +0800
Subject: [PATCH 6/6] bss_coloring: allow using a random starting color
In-Reply-To: <20211103191916.GC1357880@w1.fi>
References: <3602d12247be5d7a335ee9e3d57e04664256712b.1631091271.git.ryder.lee@mediatek.com>
 <46fa29623e1fb485e9070ef9d066a57c2111bad0.1631091272.git.ryder.lee@mediatek.com>
 <20211103191916.GC1357880@w1.fi>
Message-ID: <d38fee49c9a51f384073467886f9cf4c0f743973.camel@mediatek.com>

On Wed, 2021-11-03 at 21:19 +0200, Jouni Malinen wrote:
> On Wed, Sep 08, 2021 at 05:18:55PM +0800, Ryder Lee wrote:
> > Enhance the possible values for he_bss_color. Anything greater than
> > 63 will
> > make hostapd choose a random color.
> 
> What's the use case for this? Isn't the initial BSS color supposed to
> be
> selected based on what BSS colors are in use by neighboring OBSSs
> (see
> IEEE Std 802.11ax-2021, 26.17.3.2)?
> 
> If that more complete implementation looking at neighboring OBSSs is
> not
> added, would the automatic initialization to a random value be
> sufficient for now?
> 
https://w1.fi/cgit/hostap/commit/src?id=41ec97cd09486a6bda21f5f5b89e5242e6ade2a2
> 
> > -# he_bss_color: BSS color (1-63)
> > +# he_bss_color:
> > +# 0 = disable
> > +# 1-63 = pre-defined color
> > +# 64+ =	random color
> >  #he_bss_color=1
> 
> Is it really expected to be possible to configure the BSS color to be
> hardcoded to be disabled? In addition, that use of multiple different
> values to indicate a random color feels quite strange.
> 

Agree. I will drop this one.



From ryder.lee at mediatek.com  Thu Nov  4 22:40:07 2021
From: ryder.lee at mediatek.com (Ryder Lee)
Date: Fri, 5 Nov 2021 13:40:07 +0800
Subject: [PATCH 1/6] bss coloring: add support for handling collision
 events and triggering CCA
In-Reply-To: <20211103190228.GA1357880@w1.fi>
References: <3602d12247be5d7a335ee9e3d57e04664256712b.1631091271.git.ryder.lee@mediatek.com>
 <20211103190228.GA1357880@w1.fi>
Message-ID: <34cd8315e2ff85797163513a03019c1060aee5a8.camel@mediatek.com>

> > +	/* check if there has been a recent collision */
> > +	if (now.sec - hapd->last_color_collision.sec >= 10)
> > +		return;
> 
> What is this trying to do? Skip changes if there has not been
> additional
> collisions during the last 10 seconds of the previously scheduled 50
> second timeout? What is that 10 seconds based on?

Yes, 10s is the approximate margin of collision persistent for current
implementation. Therefore a driver needs to report collision events
constantly to update the last_color_collision.sec to trigger CCA. I
could add some comments on this as an initial implementation and a todo
for note - maybe we can come out with a better method in the future.

Ryder



From ryder.lee at mediatek.com  Sun Nov  7 19:04:23 2021
From: ryder.lee at mediatek.com (Ryder Lee)
Date: Mon, 8 Nov 2021 11:04:23 +0800
Subject: [PATCH v2 2/5] bss_coloring: add the code required to generate the
 CCA IE
In-Reply-To: <2d69afce2fd6f44ae08ac75d5715fa9e43fe2a77.1636093546.git.ryder.lee@mediatek.com>
References: <2d69afce2fd6f44ae08ac75d5715fa9e43fe2a77.1636093546.git.ryder.lee@mediatek.com>
Message-ID: <d7a95338df080b7abafb3f796a0521130818f5e1.1636093546.git.ryder.lee@mediatek.com>

From: John Crispin <john at phrozen.org>

This IE is similar to the CSA one. It contains a counter and the target
color. Once the counter expired, the change to the new color happens.

Just note the current implementation is based on CCA counter attributes
that only takes beacon and prob_resp into account, as for the assoc_resp
frames will be added in the future patches.

Tested-by: Peter Chiu <chui-hao.chiu at mediatek.com>
Co-developed-by: Lorenzo Bianconi <lorenzo at kernel.org>
Signed-off-by: Lorenzo Bianconi <lorenzo at kernel.org>
Signed-off-by: John Crispin <john at phrozen.org>
Signed-off-by: Ryder Lee <ryder.lee at mediatek.com>
---
changes since v2 -
- fix the position of CCA IE.
---
 src/ap/beacon.c              | 18 ++++++++++++++++++
 src/ap/ieee802_11.h          |  1 +
 src/ap/ieee802_11_he.c       | 14 ++++++++++++++
 src/common/ieee802_11_defs.h |  1 +
 4 files changed, 34 insertions(+)

diff --git a/src/ap/beacon.c b/src/ap/beacon.c
index 15fc2b3db..794229527 100644
--- a/src/ap/beacon.c
+++ b/src/ap/beacon.c
@@ -578,8 +578,17 @@ static u8 * hostapd_gen_probe_resp(struct hostapd_data *hapd,
 
 #ifdef CONFIG_IEEE80211AX
 	if (hapd->iconf->ieee80211ax && !hapd->conf->disable_11ax) {
+		u8 *cca_pos;
+
 		pos = hostapd_eid_he_capab(hapd, pos, IEEE80211_MODE_AP);
 		pos = hostapd_eid_he_operation(hapd, pos);
+
+		/* CCA IE */
+		cca_pos = hostapd_eid_cca(hapd, pos);
+		if (cca_pos != pos)
+			hapd->cca_c_off_proberesp = cca_pos - (u8 *) resp - 2;
+		pos = cca_pos;
+
 		pos = hostapd_eid_spatial_reuse(hapd, pos);
 		pos = hostapd_eid_he_mu_edca_parameter_set(hapd, pos);
 		pos = hostapd_eid_he_6ghz_band_cap(hapd, pos);
@@ -1567,9 +1576,18 @@ int ieee802_11_build_ap_params(struct hostapd_data *hapd,
 
 #ifdef CONFIG_IEEE80211AX
 	if (hapd->iconf->ieee80211ax && !hapd->conf->disable_11ax) {
+		u8 *cca_pos;
+
 		tailpos = hostapd_eid_he_capab(hapd, tailpos,
 					       IEEE80211_MODE_AP);
 		tailpos = hostapd_eid_he_operation(hapd, tailpos);
+
+		/* CCA IE */
+		cca_pos = hostapd_eid_cca(hapd, tailpos);
+		if (cca_pos != tailpos)
+			hapd->cca_c_off_beacon = cca_pos - tail - 2;
+		tailpos = cca_pos;
+
 		tailpos = hostapd_eid_spatial_reuse(hapd, tailpos);
 		tailpos = hostapd_eid_he_mu_edca_parameter_set(hapd, tailpos);
 		tailpos = hostapd_eid_he_6ghz_band_cap(hapd, tailpos);
diff --git a/src/ap/ieee802_11.h b/src/ap/ieee802_11.h
index ea8c60846..65308ff34 100644
--- a/src/ap/ieee802_11.h
+++ b/src/ap/ieee802_11.h
@@ -100,6 +100,7 @@ u16 copy_sta_he_6ghz_capab(struct hostapd_data *hapd, struct sta_info *sta,
 			   const u8 *he_6ghz_capab);
 int hostapd_get_he_twt_responder(struct hostapd_data *hapd,
 				 enum ieee80211_op_mode mode);
+u8 * hostapd_eid_cca(struct hostapd_data *hapd, u8 *eid);
 void hostapd_tx_status(struct hostapd_data *hapd, const u8 *addr,
 		       const u8 *buf, size_t len, int ack);
 void hostapd_eapol_tx_status(struct hostapd_data *hapd, const u8 *dst,
diff --git a/src/ap/ieee802_11_he.c b/src/ap/ieee802_11_he.c
index 6cd6c90dc..a3203c993 100644
--- a/src/ap/ieee802_11_he.c
+++ b/src/ap/ieee802_11_he.c
@@ -520,3 +520,17 @@ int hostapd_get_he_twt_responder(struct hostapd_data *hapd,
 	return !!(mac_cap[HE_MAC_CAPAB_0] & HE_MACCAP_TWT_RESPONDER) &&
 		hapd->iface->conf->he_op.he_twt_responder;
 }
+
+u8 * hostapd_eid_cca(struct hostapd_data *hapd, u8 *eid)
+{
+	if (!hapd->cca_in_progress)
+		return eid;
+
+	*eid++ = WLAN_EID_EXTENSION;
+	*eid++ = 3;
+	*eid++ = WLAN_EID_EXT_COLOR_CHANGE_ANNOUNCEMENT;
+	*eid++ = hapd->cca_count;
+	*eid++ = hapd->cca_color;
+
+	return eid;
+}
diff --git a/src/common/ieee802_11_defs.h b/src/common/ieee802_11_defs.h
index adb89d111..a1112c99b 100644
--- a/src/common/ieee802_11_defs.h
+++ b/src/common/ieee802_11_defs.h
@@ -479,6 +479,7 @@
 #define WLAN_EID_EXT_HE_OPERATION 36
 #define WLAN_EID_EXT_HE_MU_EDCA_PARAMS 38
 #define WLAN_EID_EXT_SPATIAL_REUSE 39
+#define WLAN_EID_EXT_COLOR_CHANGE_ANNOUNCEMENT 42
 #define WLAN_EID_EXT_OCV_OCI 54
 #define WLAN_EID_EXT_SHORT_SSID_LIST 58
 #define WLAN_EID_EXT_HE_6GHZ_BAND_CAP 59
-- 
2.29.2



From ryder.lee at mediatek.com  Sun Nov  7 19:04:22 2021
From: ryder.lee at mediatek.com (Ryder Lee)
Date: Mon, 8 Nov 2021 11:04:22 +0800
Subject: [PATCH v2 1/5] bss coloring: add support for handling collision
 events and triggering CCA
Message-ID: <2d69afce2fd6f44ae08ac75d5715fa9e43fe2a77.1636093546.git.ryder.lee@mediatek.com>

From: John Crispin <john at phrozen.org>

Add the core code for handling bss color collision events and triggering
CCA inside the kernel. The caller of hostapd_switch_color() will be added
in the following commits.

Tested-by: Peter Chiu <chui-hao.chiu at mediatek.com>
Co-developed-by: Lorenzo Bianconi <lorenzo at kernel.org>
Signed-off-by: Lorenzo Bianconi <lorenzo at kernel.org>
Signed-off-by: John Crispin <john at phrozen.org>
Signed-off-by: Ryder Lee <ryder.lee at mediatek.com>
---
changes since v2 -
- use os_get_reltime and os_reltime instead.
- use bool cca_in_progress.
- use random BSS color to avoid hardcoded BSS color value of 1.
- modify comment for DOT11BSS_COLOR_COLLISION_AP_PERIOD.
- add a note for collision behavior.
- fix compiler warnings.
- Be clear in the commit message regarding hostapd_switch_color().
---
 src/ap/ap_drv_ops.h          |  12 ++++
 src/ap/hostapd.c             | 134 ++++++++++++++++++++++++++++++++++-
 src/ap/hostapd.h             |  16 +++++
 src/common/ieee802_11_defs.h |   6 ++
 src/drivers/driver.h         |  31 ++++++++
 5 files changed, 198 insertions(+), 1 deletion(-)

diff --git a/src/ap/ap_drv_ops.h b/src/ap/ap_drv_ops.h
index 61c8f64eb..003f0daf7 100644
--- a/src/ap/ap_drv_ops.h
+++ b/src/ap/ap_drv_ops.h
@@ -299,6 +299,18 @@ static inline int hostapd_drv_switch_channel(struct hostapd_data *hapd,
 	return hapd->driver->switch_channel(hapd->drv_priv, settings);
 }
 
+#ifdef CONFIG_IEEE80211AX
+static inline int hostapd_drv_switch_color(struct hostapd_data *hapd,
+					   struct cca_settings *settings)
+{
+	if (hapd->driver == NULL || hapd->driver->switch_color == NULL ||
+	    hapd->drv_priv == NULL)
+		return -1;
+
+	return hapd->driver->switch_color(hapd->drv_priv, settings);
+}
+#endif
+
 static inline int hostapd_drv_status(struct hostapd_data *hapd, char *buf,
 				     size_t buflen)
 {
diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c
index 913a8e29e..4ec3ee62d 100644
--- a/src/ap/hostapd.c
+++ b/src/ap/hostapd.c
@@ -66,7 +66,10 @@ static int setup_interface2(struct hostapd_iface *iface);
 static void channel_list_update_timeout(void *eloop_ctx, void *timeout_ctx);
 static void hostapd_interface_setup_failure_handler(void *eloop_ctx,
 						    void *timeout_ctx);
-
+#ifdef CONFIG_IEEE80211AX
+static void
+hostapd_switch_color_timeout_handler(void *eloop_data, void *user_ctx);
+#endif
 
 int hostapd_for_each_interface(struct hapd_interfaces *interfaces,
 			       int (*cb)(struct hostapd_iface *iface,
@@ -462,6 +465,9 @@ void hostapd_free_hapd_data(struct hostapd_data *hapd)
 	}
 	eloop_cancel_timeout(auth_sae_process_commit, hapd, NULL);
 #endif /* CONFIG_SAE */
+#ifdef CONFIG_IEEE80211AX
+	eloop_cancel_timeout(hostapd_switch_color_timeout_handler, hapd, NULL);
+#endif
 }
 
 
@@ -3691,6 +3697,132 @@ hostapd_switch_channel_fallback(struct hostapd_iface *iface,
 	hostapd_enable_iface(iface);
 }
 
+
+#ifdef CONFIG_IEEE80211AX
+void hostapd_cleanup_cca_params(struct hostapd_data *hapd)
+{
+	hapd->cca_count = 0;
+	hapd->cca_color = 0;
+	hapd->cca_c_off_beacon = 0;
+	hapd->cca_c_off_proberesp = 0;
+	hapd->cca_in_progress = false;
+}
+
+
+static int hostapd_fill_cca_settings(struct hostapd_data *hapd,
+				     struct cca_settings *settings)
+{
+	struct hostapd_iface *iface = hapd->iface;
+	u8 old_color;
+	int ret;
+
+	if (!iface || iface->conf->he_op.he_bss_color_disabled)
+		return -1;
+
+        old_color = iface->conf->he_op.he_bss_color;
+	iface->conf->he_op.he_bss_color = hapd->cca_color;
+	ret = hostapd_build_beacon_data(hapd, &settings->beacon_after);
+	iface->conf->he_op.he_bss_color = old_color;
+
+	settings->cca_count = hapd->cca_count;
+	settings->cca_color = hapd->cca_color,
+	hapd->cca_in_progress = true;
+
+	ret = hostapd_build_beacon_data(hapd, &settings->beacon_cca);
+	if (ret) {
+		free_beacon_data(&settings->beacon_after);
+		return ret;
+	}
+
+	settings->counter_offset_beacon = hapd->cca_c_off_beacon;
+	settings->counter_offset_presp = hapd->cca_c_off_proberesp;
+
+	return 0;
+}
+
+
+static void
+hostapd_switch_color_timeout_handler(void *eloop_data, void *user_ctx)
+{
+	struct hostapd_data *hapd = (struct hostapd_data *) eloop_data;
+	struct cca_settings settings;
+	struct os_reltime now;
+	unsigned int b;
+	int i, r, ret;
+
+	if (os_get_reltime(&now))
+		return;
+
+	/* 10s window is the approximate margin of collision persistent
+	 * as an initial implementation. CCA can only be triggered once
+	 * handler constantly receives collision events to update the
+	 * last_color_collision.sec. How does it work -
+	 *
+	 * 1. BSS color collision persistent for at least 50 seconds.
+	 * 2. The BSS Color Disabled subfield is set to 1.
+	 * 3. CCA.
+	 *
+	 * TODO: implement other 'persistent' computation methods.
+	 */
+	if (now.sec - hapd->last_color_collision.sec >= 10)
+		return;
+
+	r = os_random() % HE_OPERATION_BSS_COLOR_MAX;
+	for (i = 0; i < HE_OPERATION_BSS_COLOR_MAX; i++) {
+		if (r && (hapd->color_collision_bitmap & (1 << r)) == 0)
+			break;
+		r = (r + 1) % HE_OPERATION_BSS_COLOR_MAX;
+	}
+
+	if (i == HE_OPERATION_BSS_COLOR_MAX) {
+		/* there are no free colors so turn bss coloring off */
+		wpa_printf(MSG_INFO, "no free colors left, turning of BSS coloring");
+		hapd->iface->conf->he_op.he_bss_color_disabled = 1;
+		hapd->iface->conf->he_op.he_bss_color = os_random() % 63 + 1;
+		for (b = 0; b < hapd->iface->num_bss; b++)
+			ieee802_11_set_beacon(hapd->iface->bss[b]);
+		return;
+	}
+
+	for (b = 0; b < hapd->iface->num_bss; b++) {
+		struct hostapd_data *bss = hapd->iface->bss[b];
+
+		hostapd_cleanup_cca_params(bss);
+		bss->cca_color = r;
+		bss->cca_count = 10;
+
+		if (hostapd_fill_cca_settings(bss, &settings)) {
+			hostapd_cleanup_cca_params(bss);
+			continue;
+		}
+
+		ret = hostapd_drv_switch_color(bss, &settings);
+		free_beacon_data(&settings.beacon_cca);
+		free_beacon_data(&settings.beacon_after);
+
+		if (ret)
+			hostapd_cleanup_cca_params(bss);
+	}
+}
+
+
+void
+hostapd_switch_color(struct hostapd_data *hapd, u64 bitmap)
+{
+	if (hapd->cca_in_progress)
+		return;
+
+	if (os_get_reltime(&hapd->last_color_collision))
+		return;
+
+	hapd->color_collision_bitmap = bitmap;
+
+	if (!eloop_is_timeout_registered(hostapd_switch_color_timeout_handler, hapd, NULL))
+		eloop_register_timeout(DOT11BSS_COLOR_COLLISION_AP_PERIOD, 0,
+				       hostapd_switch_color_timeout_handler, hapd, NULL);
+}
+#endif
+
 #endif /* NEED_AP_MLME */
 
 
diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h
index 07d0aaa92..70ae05291 100644
--- a/src/ap/hostapd.h
+++ b/src/ap/hostapd.h
@@ -292,6 +292,16 @@ struct hostapd_data {
 	unsigned int cs_c_off_ecsa_beacon;
 	unsigned int cs_c_off_ecsa_proberesp;
 
+#ifdef CONFIG_IEEE80211AX
+	bool cca_in_progress;
+	u8 cca_count;
+	u8 cca_color;
+	unsigned int cca_c_off_beacon;
+	unsigned int cca_c_off_proberesp;
+	struct os_reltime last_color_collision;
+	u64 color_collision_bitmap;
+#endif
+
 #ifdef CONFIG_P2P
 	struct p2p_data *p2p;
 	struct p2p_group *p2p_group;
@@ -645,6 +655,12 @@ void hostapd_periodic_iface(struct hostapd_iface *iface);
 int hostapd_owe_trans_get_info(struct hostapd_data *hapd);
 void hostapd_ocv_check_csa_sa_query(void *eloop_ctx, void *timeout_ctx);
 
+
+#ifdef CONFIG_IEEE80211AX
+void hostapd_switch_color(struct hostapd_data *hapd, u64 bitmap);
+void hostapd_cleanup_cca_params(struct hostapd_data *hapd);
+#endif
+
 /* utils.c */
 int hostapd_register_probereq_cb(struct hostapd_data *hapd,
 				 int (*cb)(void *ctx, const u8 *sa,
diff --git a/src/common/ieee802_11_defs.h b/src/common/ieee802_11_defs.h
index 24dbfa8bd..adb89d111 100644
--- a/src/common/ieee802_11_defs.h
+++ b/src/common/ieee802_11_defs.h
@@ -2305,6 +2305,7 @@ struct ieee80211_spatial_reuse {
 #define HE_OPERATION_BSS_COLOR_PARTIAL		((u32) BIT(30))
 #define HE_OPERATION_BSS_COLOR_DISABLED		((u32) BIT(31))
 #define HE_OPERATION_BSS_COLOR_OFFSET		24
+#define HE_OPERATION_BSS_COLOR_MAX		64
 
 /* Spatial Reuse defines */
 #define SPATIAL_REUSE_SRP_DISALLOWED		BIT(0)
@@ -2450,6 +2451,11 @@ enum mscs_description_subelem {
  */
 #define FD_MAX_INTERVAL_6GHZ                  20 /* TUs */
 
+/* IEEE802.11/D6.0 - 26.17.3.5.1, AP needs to wait and see the collision
+ * persists for at least the minimum default timeout
+ */
+#define DOT11BSS_COLOR_COLLISION_AP_PERIOD	50
+
 /* Protected Vendor-specific QoS Management Action frame identifiers - WFA */
 #define QM_ACTION_VENDOR_TYPE 0x506f9a1a
 #define QM_ACTION_OUI_TYPE 0x1a
diff --git a/src/drivers/driver.h b/src/drivers/driver.h
index 2020184c5..f762ccccc 100644
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
@@ -2395,6 +2395,26 @@ struct csa_settings {
 	u16 counter_offset_presp[2];
 };
 
+/**
+ * struct cca_settings - Settings for color switch command
+ * @cca_count: Count in Beacon frames (TBTT) to perform the switch
+ * @cca_color: The new color that we are switching to
+ * @beacon_cca: Beacon/probe resp/asooc resp info for color switch period
+ * @beacon_after: Next beacon/probe resp/asooc resp info
+ * @counter_offset_beacon: Offset to the count field in beacon's tail
+ * @counter_offset_presp: Offset to the count field in probe resp.
+ */
+struct cca_settings {
+	u8 cca_count;
+	u8 cca_color;
+
+	struct beacon_data beacon_cca;
+	struct beacon_data beacon_after;
+
+	u16 counter_offset_beacon;
+	u16 counter_offset_presp;
+};
+
 /* TDLS peer capabilities for send_tdls_mgmt() */
 enum tdls_peer_capability {
 	TDLS_PEER_HT = BIT(0),
@@ -3977,6 +3997,17 @@ struct wpa_driver_ops {
 	 */
 	int (*switch_channel)(void *priv, struct csa_settings *settings);
 
+	/**
+	 * switch_color - Announce color switch and migrate the BSS to the
+	 * given color
+	 * @priv: Private driver interface data
+	 * @settings: Settings for CCA period and new color
+	 * Returns: 0 on success, -1 on failure
+	 *
+	 * This function is used to move the BSS to its new color.
+	 */
+	int (*switch_color)(void *priv, struct cca_settings *settings);
+
 	/**
 	 * add_tx_ts - Add traffic stream
 	 * @priv: Private driver interface data
-- 
2.29.2



From ryder.lee at mediatek.com  Sun Nov  7 19:04:24 2021
From: ryder.lee at mediatek.com (Ryder Lee)
Date: Mon, 8 Nov 2021 11:04:24 +0800
Subject: [PATCH v2 3/5] bss coloring: disable BSS color during CCA
In-Reply-To: <2d69afce2fd6f44ae08ac75d5715fa9e43fe2a77.1636093546.git.ryder.lee@mediatek.com>
References: <2d69afce2fd6f44ae08ac75d5715fa9e43fe2a77.1636093546.git.ryder.lee@mediatek.com>
Message-ID: <9ac28de67dc46471179ef84d516727a153dc89c0.1636093546.git.ryder.lee@mediatek.com>

From: John Crispin <john at phrozen.org>

While we are doing CCA the bss color disable bit inside the he oper field
needs to be set.

Tested-by: Peter Chiu <chui-hao.chiu at mediatek.com>
Co-developed-by: Lorenzo Bianconi <lorenzo at kernel.org>
Signed-off-by: Lorenzo Bianconi <lorenzo at kernel.org>
Signed-off-by: John Crispin <john at phrozen.org>
Signed-off-by: Ryder Lee <ryder.lee at mediatek.com>
---
 src/ap/ieee802_11_he.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/ap/ieee802_11_he.c b/src/ap/ieee802_11_he.c
index a3203c993..fc8ee1168 100644
--- a/src/ap/ieee802_11_he.c
+++ b/src/ap/ieee802_11_he.c
@@ -195,7 +195,7 @@ u8 * hostapd_eid_he_operation(struct hostapd_data *hapd, u8 *eid)
 	if (hapd->iface->conf->he_op.he_er_su_disable)
 		params |= HE_OPERATION_ER_SU_DISABLE;
 
-	if (hapd->iface->conf->he_op.he_bss_color_disabled)
+	if (hapd->iface->conf->he_op.he_bss_color_disabled || hapd->cca_in_progress)
 		params |= HE_OPERATION_BSS_COLOR_DISABLED;
 	if (hapd->iface->conf->he_op.he_bss_color_partial)
 		params |= HE_OPERATION_BSS_COLOR_PARTIAL;
-- 
2.29.2



From ryder.lee at mediatek.com  Sun Nov  7 19:04:25 2021
From: ryder.lee at mediatek.com (Ryder Lee)
Date: Mon, 8 Nov 2021 11:04:25 +0800
Subject: [PATCH v2 4/5] bss coloring: add the switch_color handler to the
 nl80211 driver
In-Reply-To: <2d69afce2fd6f44ae08ac75d5715fa9e43fe2a77.1636093546.git.ryder.lee@mediatek.com>
References: <2d69afce2fd6f44ae08ac75d5715fa9e43fe2a77.1636093546.git.ryder.lee@mediatek.com>
Message-ID: <c67dddcce3b58082415f4f967441c5c80663943c.1636093546.git.ryder.lee@mediatek.com>

From: John Crispin <john at phrozen.org>

In order to start the CCA process we need to send NL80211_CMD_COLOR_CHANGE
to the kernel. This patch adds the required code.

Tested-by: Peter Chiu <chui-hao.chiu at mediatek.com>
Co-developed-by: Lorenzo Bianconi <lorenzo at kernel.org>
Signed-off-by: Lorenzo Bianconi <lorenzo at kernel.org>
Signed-off-by: John Crispin <john at phrozen.org>
Signed-off-by: Ryder Lee <ryder.lee at mediatek.com>
---
 src/drivers/driver_nl80211.c | 79 ++++++++++++++++++++++++++++++++++++
 1 file changed, 79 insertions(+)

diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 9a9a146f7..4cc05ef38 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -9930,6 +9930,82 @@ error:
 }
 
 
+#ifdef CONFIG_IEEE80211AX
+static int nl80211_switch_color(void *priv, struct cca_settings *settings)
+{
+	struct nl_msg *msg;
+	struct i802_bss *bss = priv;
+	struct wpa_driver_nl80211_data *drv = bss->drv;
+	struct nlattr *beacon_cca;
+	int ret = -ENOBUFS;
+
+	wpa_printf(MSG_DEBUG, "nl80211: Color change request (cca_count=%u color=%d)",
+		   settings->cca_count, settings->cca_color);
+
+	if (drv->nlmode != NL80211_IFTYPE_AP)
+		return -EOPNOTSUPP;
+
+	if (!settings->beacon_cca.tail)
+		return -EINVAL;
+
+	if ((settings->beacon_cca.tail_len <= settings->counter_offset_beacon) ||
+	    (settings->beacon_cca.tail[settings->counter_offset_beacon] !=
+		     settings->cca_count))
+		return -EINVAL;
+
+	if (settings->beacon_cca.probe_resp &&
+	    ((settings->beacon_cca.probe_resp_len <=
+			settings->counter_offset_presp) ||
+	     (settings->beacon_cca.probe_resp[settings->counter_offset_presp] !=
+			settings->cca_count)))
+		return -EINVAL;
+
+	if (!(msg = nl80211_bss_msg(bss, 0, NL80211_CMD_COLOR_CHANGE_REQUEST)) ||
+	    nla_put_u8(msg, NL80211_ATTR_COLOR_CHANGE_COUNT,
+			settings->cca_count) ||
+	    nla_put_u8(msg, NL80211_ATTR_COLOR_CHANGE_COLOR,
+			settings->cca_color))
+		goto error;
+
+	/* beacon_after params */
+	ret = set_beacon_data(msg, &settings->beacon_after);
+	if (ret)
+		goto error;
+
+	/* beacon_csa params */
+	beacon_cca = nla_nest_start(msg, NL80211_ATTR_COLOR_CHANGE_ELEMS);
+	if (!beacon_cca)
+		goto fail;
+
+	ret = set_beacon_data(msg, &settings->beacon_cca);
+	if (ret)
+		goto error;
+
+	if (nla_put_u16(msg, NL80211_ATTR_CNTDWN_OFFS_BEACON,
+			settings->counter_offset_beacon) ||
+	    (settings->beacon_cca.probe_resp &&
+	     nla_put_u16(msg, NL80211_ATTR_CNTDWN_OFFS_PRESP,
+			 settings->counter_offset_presp)))
+		goto fail;
+
+	nla_nest_end(msg, beacon_cca);
+	ret = send_and_recv_msgs(drv, msg, NULL, NULL, NULL, NULL);
+	if (ret) {
+		wpa_printf(MSG_DEBUG, "nl80211: switch_color failed err=%d (%s)",
+			   ret, strerror(-ret));
+	}
+	return ret;
+
+fail:
+	ret = -ENOBUFS;
+error:
+	nlmsg_free(msg);
+	wpa_printf(MSG_DEBUG, "nl80211: Could not build color switch request");
+	return ret;
+}
+#endif
+
+
 static int nl80211_add_ts(void *priv, u8 tsid, const u8 *addr,
 			  u8 user_priority, u16 admitted_time)
 {
@@ -12192,6 +12268,9 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = {
 	.get_survey = wpa_driver_nl80211_get_survey,
 	.status = wpa_driver_nl80211_status,
 	.switch_channel = nl80211_switch_channel,
+#ifdef CONFIG_IEEE80211AX
+	.switch_color = nl80211_switch_color,
+#endif
 #ifdef ANDROID_P2P
 	.set_noa = wpa_driver_set_p2p_noa,
 	.get_noa = wpa_driver_get_p2p_noa,
-- 
2.29.2



From ryder.lee at mediatek.com  Sun Nov  7 19:04:26 2021
From: ryder.lee at mediatek.com (Ryder Lee)
Date: Mon, 8 Nov 2021 11:04:26 +0800
Subject: [PATCH v2 5/5] bss coloring: handle the collision and CCA events
 coming from the kernel
In-Reply-To: <2d69afce2fd6f44ae08ac75d5715fa9e43fe2a77.1636093546.git.ryder.lee@mediatek.com>
References: <2d69afce2fd6f44ae08ac75d5715fa9e43fe2a77.1636093546.git.ryder.lee@mediatek.com>
Message-ID: <d77b2a2deaf750ca5d212de576acdfe7eb9e559a.1636093546.git.ryder.lee@mediatek.com>

From: John Crispin <john at phrozen.org>

This patch activates the functionality of the previous patches by handling
the actual events that will trigger the CCA process.

Tested-by: Peter Chiu <chui-hao.chiu at mediatek.com>
Co-developed-by: Lorenzo Bianconi <lorenzo at kernel.org>
Signed-off-by: Lorenzo Bianconi <lorenzo at kernel.org>
Signed-off-by: John Crispin <john at phrozen.org>
Signed-off-by: Ryder Lee <ryder.lee at mediatek.com>
---
 src/ap/drv_callbacks.c             | 45 ++++++++++++++++++++-
 src/drivers/driver.h               | 27 +++++++++++++
 src/drivers/driver_common.c        |  4 ++
 src/drivers/driver_nl80211_event.c | 64 ++++++++++++++++++++++++++++++
 4 files changed, 139 insertions(+), 1 deletion(-)

diff --git a/src/ap/drv_callbacks.c b/src/ap/drv_callbacks.c
index ec5abf166..f6e61787c 100644
--- a/src/ap/drv_callbacks.c
+++ b/src/ap/drv_callbacks.c
@@ -43,7 +43,6 @@
 #include "fils_hlp.h"
 #include "neighbor_db.h"
 
-
 #ifdef CONFIG_FILS
 void hostapd_notify_assoc_fils_finish(struct hostapd_data *hapd,
 				      struct sta_info *sta)
@@ -1769,6 +1768,39 @@ static void hostapd_event_wds_sta_interface_status(struct hostapd_data *hapd,
 }
 
 
+#ifdef CONFIG_IEEE80211AX
+static void hostapd_event_bss_color_collision(struct hostapd_data *hapd,
+					      u64 bitmap)
+{
+	/* the bss color is shared amongst all BBSs on a specific phy.
+	 * therefore we always start the color change on the primary BSS
+	 */
+	wpa_printf(MSG_DEBUG, "BSS color collision on %s", hapd->conf->iface);
+	hostapd_switch_color(hapd->iface->bss[0], bitmap);
+}
+
+static void hostapd_event_cca(struct hostapd_data *hapd, enum wpa_event_type event)
+{
+	switch (event) {
+	case EVENT_CCA_STARTED_NOTIFY:
+		wpa_printf(MSG_DEBUG, "CCA started on on %s", hapd->conf->iface);
+		break;
+	case EVENT_CCA_NOTIFY:
+		wpa_printf(MSG_DEBUG, "CCA finished on on %s", hapd->conf->iface);
+		hapd->iface->conf->he_op.he_bss_color = hapd->cca_color;
+		hostapd_cleanup_cca_params(hapd);
+		break;
+	case EVENT_CCA_ABORTED_NOTIFY:
+		wpa_printf(MSG_DEBUG, "CCA aborted on on %s", hapd->conf->iface);
+		hostapd_cleanup_cca_params(hapd);
+		break;
+	default:
+		break;
+	}
+}
+#endif
+
+
 #ifdef CONFIG_OWE
 static int hostapd_notif_update_dh_ie(struct hostapd_data *hapd,
 				      const u8 *peer, const u8 *ie,
@@ -2075,6 +2107,17 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
 			data->wds_sta_interface.ifname,
 			data->wds_sta_interface.sta_addr);
 		break;
+#ifdef CONFIG_IEEE80211AX
+	case EVENT_BSS_COLOR_COLLISION:
+		hostapd_event_bss_color_collision(hapd,
+						  data->bss_color_collision.bitmap);
+		break;
+	case EVENT_CCA_STARTED_NOTIFY:
+	case EVENT_CCA_ABORTED_NOTIFY:
+	case EVENT_CCA_NOTIFY:
+		hostapd_event_cca(hapd, event);
+		break;
+#endif
 	default:
 		wpa_printf(MSG_DEBUG, "Unknown event %d", event);
 		break;
diff --git a/src/drivers/driver.h b/src/drivers/driver.h
index f762ccccc..cc327fc5a 100644
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
@@ -5158,6 +5158,26 @@ enum wpa_event_type {
 	 * is required to provide more details of the frame.
 	 */
 	EVENT_UNPROT_BEACON,
+
+	/**
+	  * EVENT_BSS_COLOR_COLLISION - Notification of a BSS color collision
+	  */
+	EVENT_BSS_COLOR_COLLISION,
+
+	/**
+	 * EVENT_CCA_STARTED_NOTIFY - Notification that CCA has started
+	 */
+	EVENT_CCA_STARTED_NOTIFY,
+
+	/**
+	 * EVENT_CCA_ABORTED_NOTIFY - Notification that CCA has aborted
+	 */
+	EVENT_CCA_ABORTED_NOTIFY,
+
+	/**
+	 * EVENT_CCA_NOTIFY - Notification that CCA has completed
+	 */
+	EVENT_CCA_NOTIFY,
 };
 
 
@@ -6050,6 +6070,13 @@ union wpa_event_data {
 	struct unprot_beacon {
 		const u8 *sa;
 	} unprot_beacon;
+
+	/**
+	 * struct bss_color_collision - Data for EVENT_BSS_COLOR_COLLISION
+	 */
+	struct bss_color_collision {
+		u64 bitmap;
+	} bss_color_collision;
 };
 
 /**
diff --git a/src/drivers/driver_common.c b/src/drivers/driver_common.c
index 1cb976011..551851f52 100644
--- a/src/drivers/driver_common.c
+++ b/src/drivers/driver_common.c
@@ -90,6 +90,10 @@ const char * event_to_string(enum wpa_event_type event)
 	E2S(WDS_STA_INTERFACE_STATUS);
 	E2S(UPDATE_DH);
 	E2S(UNPROT_BEACON);
+	E2S(BSS_COLOR_COLLISION);
+	E2S(CCA_STARTED_NOTIFY);
+	E2S(CCA_ABORTED_NOTIFY);
+	E2S(CCA_NOTIFY);
 	}
 
 	return "UNKNOWN";
diff --git a/src/drivers/driver_nl80211_event.c b/src/drivers/driver_nl80211_event.c
index 0f0a01d01..8beaa0a77 100644
--- a/src/drivers/driver_nl80211_event.c
+++ b/src/drivers/driver_nl80211_event.c
@@ -172,6 +172,11 @@ static const char * nl80211_command_to_string(enum nl80211_commands cmd)
 	C2S(NL80211_CMD_UNPROT_BEACON)
 	C2S(NL80211_CMD_CONTROL_PORT_FRAME_TX_STATUS)
 	C2S(NL80211_CMD_SET_SAR_SPECS)
+	C2S(NL80211_CMD_OBSS_COLOR_COLLISION)
+	C2S(NL80211_CMD_COLOR_CHANGE_REQUEST)
+	C2S(NL80211_CMD_COLOR_CHANGE_STARTED)
+	C2S(NL80211_CMD_COLOR_CHANGE_ABORTED)
+	C2S(NL80211_CMD_COLOR_CHANGE_COMPLETED)
 	C2S(__NL80211_CMD_AFTER_LAST)
 	}
 #undef C2S
@@ -2854,6 +2859,51 @@ nl80211_control_port_frame_tx_status(struct wpa_driver_nl80211_data *drv,
 	wpa_supplicant_event(drv->ctx, EVENT_EAPOL_TX_STATUS, &event);
 }
 
+#ifdef CONFIG_IEEE80211AX
+static void mlme_event_obss_color_collision(struct wpa_driver_nl80211_data *drv,
+					    struct nlattr *tb[])
+{
+	union wpa_event_data data;
+
+	if (!tb[NL80211_ATTR_OBSS_COLOR_BITMAP])
+		return;
+
+	os_memset(&data, 0, sizeof(data));
+	data.bss_color_collision.bitmap = nla_get_u64(tb[NL80211_ATTR_OBSS_COLOR_BITMAP]);
+
+	wpa_printf(MSG_DEBUG, "nl80211: BSS color collision - bitmap %08lx",
+		   data.bss_color_collision.bitmap);
+
+	wpa_supplicant_event(drv->ctx, EVENT_BSS_COLOR_COLLISION, &data);
+}
+
+static void mlme_event_color_change_announcement_started(struct wpa_driver_nl80211_data *drv)
+{
+	union wpa_event_data data = {};
+
+	wpa_printf(MSG_DEBUG, "nl80211: CCA started");
+
+	wpa_supplicant_event(drv->ctx, EVENT_CCA_STARTED_NOTIFY, &data);
+}
+
+static void mlme_event_color_change_announcement_aborted(struct wpa_driver_nl80211_data *drv)
+{
+	union wpa_event_data data = {};
+
+	wpa_printf(MSG_DEBUG, "nl80211: CCA aborted");
+
+	wpa_supplicant_event(drv->ctx, EVENT_CCA_ABORTED_NOTIFY, &data);
+}
+
+static void mlme_event_color_change_announcement_completed(struct wpa_driver_nl80211_data *drv)
+{
+	union wpa_event_data data = {};
+
+	wpa_printf(MSG_DEBUG, "nl80211: CCA completed");
+
+	wpa_supplicant_event(drv->ctx, EVENT_CCA_NOTIFY, &data);
+}
+#endif
 
 static void do_process_drv_event(struct i802_bss *bss, int cmd,
 				 struct nlattr **tb)
@@ -3101,6 +3151,20 @@ static void do_process_drv_event(struct i802_bss *bss, int cmd,
 						     tb[NL80211_ATTR_ACK],
 						     tb[NL80211_ATTR_COOKIE]);
 		break;
+#ifdef CONFIG_IEEE80211AX
+	case NL80211_CMD_OBSS_COLOR_COLLISION:
+		mlme_event_obss_color_collision(drv, tb);
+		break;
+	case NL80211_CMD_COLOR_CHANGE_STARTED:
+		mlme_event_color_change_announcement_started(drv);
+		break;
+	case NL80211_CMD_COLOR_CHANGE_ABORTED:
+		mlme_event_color_change_announcement_aborted(drv);
+		break;
+	case NL80211_CMD_COLOR_CHANGE_COMPLETED:
+		mlme_event_color_change_announcement_completed(drv);
+		break;
+#endif
 	default:
 		wpa_dbg(drv->ctx, MSG_DEBUG, "nl80211: Ignored unknown event "
 			"(cmd=%d)", cmd);
-- 
2.29.2



From j at w1.fi  Mon Nov  8 09:57:00 2021
From: j at w1.fi (Jouni Malinen)
Date: Mon, 8 Nov 2021 19:57:00 +0200
Subject: [PATCH 1/2] Add helper function to read file link targets
In-Reply-To: <CH2PR21MB1445E01D10108BA39081D581C2769@CH2PR21MB1445.namprd21.prod.outlook.com>
References: <CH2PR21MB1445E01D10108BA39081D581C2769@CH2PR21MB1445.namprd21.prod.outlook.com>
Message-ID: <20211108175700.GA14846@w1.fi>

On Tue, Apr 06, 2021 at 11:45:48PM +0000, Andrew Beltrano wrote:
> diff?--git?a/src/utils/common.c?b/src/utils/common.c

> +#include?<sys/stat.h>
> +int?read_link_target(const?char?*name,?char?**target)
> +???if?(lstat(name,?&statbuf)?<?0)
..

src/utils/common.c is supposed to be mostly platform independent
functionality while platform/operating system specific functionality
would be in src/utils/os_*.c. This function seems to be in that latter
category and I'd assume it would have quite different behavior on
Windows, for example, and maybe not even applicable for that case to
meet the patch 2/2 need.

-- 
Jouni Malinen                                            PGP id EFC895FA


From j at w1.fi  Mon Nov  8 10:06:11 2021
From: j at w1.fi (Jouni Malinen)
Date: Mon, 8 Nov 2021 20:06:11 +0200
Subject: [PATCH 2/2] Use wpa conf file link target for writing
In-Reply-To: <CH2PR21MB1445AC7AABF81771E33B3D0BC2769@CH2PR21MB1445.namprd21.prod.outlook.com>
References: <CH2PR21MB1445AC7AABF81771E33B3D0BC2769@CH2PR21MB1445.namprd21.prod.outlook.com>
Message-ID: <20211108180611.GB14846@w1.fi>

On Tue, Apr 06, 2021 at 11:46:55PM +0000, Andrew Beltrano wrote:
> When the wpa conf file is a symbolic link, the link is clobbered when
> written. This occurs because the rename() of the (regular) tmp file
> used to write changes replaces the original file, thus discarding the
> link.
> 
> Fix this by first resolving the conf file link target (if any), and
> using the target as the defacto file path instead of the link file
> itself. This ensures the tmp file is created on the same filesystem
> as the link target, which is required for rename().

> diff --git a/wpa_supplicant/config_file.c b/wpa_supplicant/config_file.c
> @@ -1545,15 +1545,23 @@ int wpa_config_write(const char *name, struct wpa_config *config)
> +	} else if (read_link_target(name, &link_target) < 0) {
> +		wpa_printf(MSG_ERROR, "Failed to read '%s' link target for writing", name);
> +		return -1;
> +	} 

How should this behave on platforms that do not support symbolic links
(see the comment on patch 1/2)? Should this skip that error return and
continue without overriding the name pointer?

I'm also a bit hesitant on this type of design that is not really atomic
since that symlink case would seem to have a potential race condition if
the symlink is replaced between this read_link_target() call and the
rename(). If that were to happen, the original file might not be
modified at all. That might be fine in this particular case since the
target file is supposed to be in a directory that has limited write
access, but anyway, it would be good to be clear on the expectations for
that.

-- 
Jouni Malinen                                            PGP id EFC895FA


From j at w1.fi  Mon Nov  8 10:28:35 2021
From: j at w1.fi (Jouni Malinen)
Date: Mon, 8 Nov 2021 20:28:35 +0200
Subject: [PATCH 1/2] DPP: Add Configuration Request timeout in hostapd
In-Reply-To: <CH2PR21MB14457FA89C3985EE34219E43C2499@CH2PR21MB1445.namprd21.prod.outlook.com>
References: <CH2PR21MB14457FA89C3985EE34219E43C2499@CH2PR21MB1445.namprd21.prod.outlook.com>
Message-ID: <20211108182835.GC14846@w1.fi>

On Mon, Apr 19, 2021 at 11:05:18PM +0000, Andrew Beltrano wrote:
> Add 10s timeout for receipt of Configuration Request frame from
> enrollee.

It would be good to copy the description of the need for this change
from the cover letter (0/2) into the actual commit message here since
the cover letter is not going to be stored in the repository.
Furthermore, I would combine these patches into a single commit instead
of splitting the practically same functionality between hostapd and
wpa_supplicant.

> diff --git a/src/ap/dpp_hostapd.c b/src/ap/dpp_hostapd.c
> @@ -440,6 +442,24 @@ static void hostapd_dpp_init_timeout(void *eloop_ctx, void *timeout_ctx)

> @@ -2001,6 +2025,8 @@ hostapd_dpp_gas_req_handler(struct hostapd_data *hapd, const u8 *sa,
> +	if (auth->configurator)
> +		eloop_cancel_timeout(hostapd_dpp_conf_req_rx_wait_timeout, hapd, NULL);

In addition to this normal case, the timeout should likely be canceled
in some other paths as well. At least the one in hostapd_dpp_auth_init()
when a previous session is terminated to start a new one should cancel
this timeout to avoid unexpected calls during a consecutive exchange.
Similarly, hostapd_dpp_deinit() needs to cancel this to avoid
dereferencing freed memory after interface removal if that removal were
to happen during this timeout.
 
-- 
Jouni Malinen                                            PGP id EFC895FA


From j at w1.fi  Mon Nov  8 10:31:27 2021
From: j at w1.fi (Jouni Malinen)
Date: Mon, 8 Nov 2021 20:31:27 +0200
Subject: [PATCH 2/2] DPP: Add Configuration Request timeout in wpas
In-Reply-To: <CH2PR21MB1445FDFD1EE3516E0CA58C97C2499@CH2PR21MB1445.namprd21.prod.outlook.com>
References: <CH2PR21MB1445FDFD1EE3516E0CA58C97C2499@CH2PR21MB1445.namprd21.prod.outlook.com>
Message-ID: <20211108183127.GD14846@w1.fi>

On Mon, Apr 19, 2021 at 11:05:49PM +0000, Andrew Beltrano wrote:
> Add 10s timeout for receipt of Configuration Request frame from
> enrollee.
> ---

This needs a Signed-off-by: line or well, like I noted for 1/2, I'd
actually merge this into the same patch with the more complete commit
message.

> diff --git a/wpa_supplicant/dpp_supplicant.c b/wpa_supplicant/dpp_supplicant.c
> @@ -2968,6 +2992,8 @@ wpas_dpp_gas_req_handler(void *ctx, void *resp_ctx, const u8 *sa,
> +	if (auth->configurator)
> +		eloop_cancel_timeout(wpas_dpp_conf_req_rx_wait_timeout, wpa_s, NULL);

Similarly to the hostapd case, this needs to be canceled in more places.
At least wpa_dpp_auth_init() and wpas_dpp_deinit() need this for the
same reasons as the hostapd patch.
 
-- 
Jouni Malinen                                            PGP id EFC895FA


From j at w1.fi  Mon Nov  8 10:43:26 2021
From: j at w1.fi (Jouni Malinen)
Date: Mon, 8 Nov 2021 20:43:26 +0200
Subject: [PATCH v2 1/2] Make tls_engine_load_dynamic_generic externally
 accessible.
In-Reply-To: <CH2PR21MB144513CBC6EB6A369B16DC2BC25E9@CH2PR21MB1445.namprd21.prod.outlook.com>
References: <CH2PR21MB144513CBC6EB6A369B16DC2BC25E9@CH2PR21MB1445.namprd21.prod.outlook.com>
Message-ID: <20211108184326.GE14846@w1.fi>

On Fri, Apr 30, 2021 at 10:48:21PM +0000, Andrew Beltrano wrote:
> Expose tls_engine_load_dynamic_generic such that it can be used
> by other code wishing to load an openssl engine dynamically. The
> function is already written in way that is not specific to tls and was
> moved verbatim.

> diff --git a/hostapd/Android.mk b/hostapd/Android.mk
> +ifndef OPENSSL_NO_ENGINE
> +NEED_OPENSSL_ENGINE=y
> +endif

What would define that OPENSSL_NO_ENGINE for Android.mk? Isn't that
defined only within the OpenSSL header files and those do not get
imported here into build process.

>  ifdef CONFIG_DPP2
>  L_CFLAGS += -DCONFIG_DPP2
>  endif

So this was within the CONFIG_DPP block and as such, would apply to any
crypto library (even though I understand that OpenSSL is the only one
currently supported for DPP). Defining NEED_OPENSSL_ENGINE=y here feels
incorrect, i.e., this all should really be done within the OpenSSL
specific block below:

>  ifdef TLS_FUNCS
> +ifndef OPENSSL_NO_ENGINE
> +NEED_OPENSSL_ENGINE=y
> +endif

I.e., here.. But the same question about defining OPENSSL_NO_ENGINE
applies.

> +ifdef NEED_OPENSSL_ENGINE
> +OBJS += src/crypto/openssl_engine.o
> +CFLAGS += -DCONFIG_OPENSSL_ENGINE
> +endif

This should also be within the OpenSSL specific block, i.e., somewhere
next to the place where crypto_openssl.c is included. Please also note
that Android.mk uses the source code file name (.c) instead of the
object file.

> diff --git a/hostapd/Makefile b/hostapd/Makefile
> +ifndef OPENSSL_NO_ENGINE
> +NEED_OPENSSL_ENGINE=y
> +endif
>  ifdef CONFIG_DPP2

The same comments above apply to Makefile except for that last .o --> .c
part.

-- 
Jouni Malinen                                            PGP id EFC895FA


From j at w1.fi  Mon Nov  8 10:57:45 2021
From: j at w1.fi (Jouni Malinen)
Date: Mon, 8 Nov 2021 20:57:45 +0200
Subject: [PATCH] DPP: Allow loading bootstrap keys using an OpenSSL engine
In-Reply-To: <CH2PR21MB14456ADF3FF22106E15325FCC2769@CH2PR21MB1445.namprd21.prod.outlook.com>
References: <CH2PR21MB14456ADF3FF22106E15325FCC2769@CH2PR21MB1445.namprd21.prod.outlook.com>
Message-ID: <20211108185745.GF14846@w1.fi>

On Tue, Apr 06, 2021 at 04:03:48PM +0000, Andrew Beltrano wrote:
> Add ability to load a DPP bootstrap key-pair using an arbitrary OpenSSL
> engine instead of requiring the private key to be specified explicitly.
> The engine name, so path, and key identifier must be specified to
> enable loading a key using an OpenSSL engine. The key identifier is
> an engine-specific field used to identify the key to load.
> 
> Explicit private keys, if specified, take precedence over OpenSSL
> engine-based keys.

> diff --git a/src/common/dpp.c b/src/common/dpp.c
> @@ -180,6 +180,13 @@ void dpp_bootstrap_info_free(struct dpp_bootstrap_info *info)
> +#ifndef OPENSSL_NO_ENGINE
> +	os_free(info->key_id);
> +	os_free(info->engine_id);
> +	os_free(info->engine_path);
> +	if (info->engine)
> +		ENGINE_finish(info->engine);
> +#endif /* OPENSSL_NO_ENGINE */
>  	EVP_PKEY_free(info->pubkey);
>  	str_clear_free(info->configurator_params);
>  	os_free(info);

I'd prefer to move most of the OpenSSL specific items away from dpp.c
(as was actually done with another patch for the items shown here in the
earlier code snapshot). Maybe that info->engine could be a new context
struct from src/crypto/crypto.h with the key_id/engine_id/engine_path
being "hidden" within that struct just like the OpenSSL specific
reference within crypto_openssl.c.

> @@ -3893,6 +3900,11 @@ int dpp_bootstrap_gen(struct dpp_global *dpp, const char *cmd)
>  	info = get_param(cmd, " info=");
>  	curve = get_param(cmd, " curve=");
>  	key = get_param(cmd, " key=");
> +#ifndef OPENSSL_NO_ENGINE
> +	bi->key_id = get_param(cmd, " key_id=");
> +	bi->engine_id = get_param(cmd, " engine=");
> +	bi->engine_path = get_param(cmd, " engine_path=");
> +#endif /* OPENSSL_NO_ENGINE */

This could be done without that OPENSSL_NO_ENGINE.

> +#ifndef OPENSSL_NO_ENGINE
> +	else if (bi->key_id) {
> +		bi->engine = dpp_load_engine(bi->engine_id, bi->engine_path);
> +		if (!bi->engine)
> +			goto fail;
> +	}
> +#endif /* OPENSSL_NO_ENGINE */

And I guess this could also get rid of the OPENSSL_NO_ENGINE use and
replace dpp_load_engine() with something like crypto_load_engine(). It
might also be more convenient to provide key_id to that function so that
all such crypto implementation specific parameters would be within the
same context and dpp_load_keypair() would not need to pass the key_id
separately.

> diff --git a/src/common/dpp.h b/src/common/dpp.h
> +#ifndef OPENSSL_NO_ENGINE
> +#include <openssl/engine.h>
> +#endif /* OPENSSL_NO_ENGINE */ 

> @@ -166,6 +169,12 @@ struct dpp_bootstrap_info {
> +#ifndef OPENSSL_NO_ENGINE
> +	char *key_id;
> +	char *engine_id;
> +	char *engine_path;
> +	ENGINE *engine;
> +#endif /* OPENSSL_NO_ENGINE */
>  };

So that could be replaced with struct crypto_engine (etc.) so that all
the OpenSSL specific stuff could be in openssl_engine.c (or
crypto_openssl.c if the Makefile conditions do not work easily for
adding that file based on OPENSSL_NO_ENGINE).

> diff --git a/src/common/dpp_crypto.c b/src/common/dpp_crypto.c
> +#ifndef OPENSSL_NO_ENGINE
> +static EVP_PKEY * dpp_load_keypair(const struct dpp_curve_params **curve,
> +				  ENGINE *engine, const char *key_id)
> +{

EVP_PKEY/ENGINE could be replace with struct crypto_ec_key/crypto_engine
now.

> +	EVP_PKEY *pkey;
> +	EC_KEY *eckey;
> +	const EC_GROUP *group;
> +	int nid;
> +
> +	pkey = ENGINE_load_private_key(engine, key_id, NULL, NULL);

And most of the fucntion contents moved into the OpenSSL specific file.
Or well, I guess the full function could go there since there would not
really be much need for an extra wrapper on top of that.

> +static int dpp_openssl_engine_load_dynamic(const char *engine_id,
> +			const char *engine_path)
> +{
> +	const char *pre_cmd[] = {
> +		"SO_PATH", engine_path,
> +		"ID", engine_id,
> +		"LIST_ADD", "1",
> +		"LOAD", NULL,
> +		NULL, NULL
> +	};
> +	const char *post_cmd[] = {
> +		NULL, NULL
> +	};
> +
> +	if (!engine_id || !engine_path)
> +		return 0;
> +
> +	wpa_printf(MSG_DEBUG, "ENGINE: Loading %s Engine from %s",
> +		   engine_id, engine_path);
> +
> +	return openssl_engine_load_dynamic_generic(pre_cmd, post_cmd, engine_id);
> +}

I'm not sure what would be the cleanest approach for this function.
Maybe this should all go into the OpenSSL specific files even though
this does not strictly speaking call any OpenSSL library specific
function, but that last function there is still a crypto library
specific one.

> +ENGINE * dpp_load_engine(const char *engine_id, const char *engine_path)
> +{
> +	if (dpp_openssl_engine_load_dynamic(engine_id, engine_path) < 0)
> +		return NULL;
> +
> +	ENGINE *engine = ENGINE_by_id(engine_id);
> +	if (!engine) {
> +		wpa_printf(MSG_ERROR, "ENGINE: engine %s not available [%s]",
> +			engine_id, ERR_error_string(ERR_get_error(), NULL));
> +		return NULL;
> +	}
> +
> +	if (ENGINE_init(engine) != 1) {
> +		wpa_printf(MSG_ERROR, "ENGINE: engine init failed "
> +			"(engine: %s) [%s]", engine_id,
> +			ERR_error_string(ERR_get_error(), NULL));
> +		ENGINE_free(engine);
> +		return NULL;
> +	}
> +
> +	return engine;
> +}

And this would move into openssl_engine/crypto_openssl.c as well.

-- 
Jouni Malinen                                            PGP id EFC895FA


From worker at cksn.tk  Tue Nov  9 07:28:01 2021
From: worker at cksn.tk (worker at cksn.tk)
Date: Tue, 9 Nov 2021 16:28:01 +0100
Subject: rewrite RADIUS_ATTR_USER_PASSWORD
Message-ID: <87e8b6f3-53f7-bf77-9463-30f9b71732e9@cksn.tk>

Hello,
at this point in the code 
(https://w1.fi/cgit/hostap/tree/src/ap/ieee802_11_auth.c#n129) the 
radius request is assembled, especially the RADIUS_ATTR_USER_PASSWORD 
attribute. but i don't understand why here the MAC address of the client 
is transmitted as password. is it possible from the data situation at 
this point to get the PSK entered by the user?

Volker.


From amo at semihalf.com  Wed Nov 10 11:16:35 2021
From: amo at semihalf.com (Andrzej Ostruszka)
Date: Wed, 10 Nov 2021 19:16:35 +0000
Subject: [PATCH] wpa_supplicant: Add support for pregenerated MAC
Message-ID: <20211110191635.1175508-1-amo@semihalf.com>

Add new 'mac_addr' policy (3) with which supplicant expects to also
obtain 'mac_value' with pregenerated value of MAC address to be used for
given SSID.

The main difference between this policy and policy 1 is the ability to
control persistence of the MAC address used.  For example if there is
a requirement to always use the same (but random) MAC address for given
SSID (even if user removes/forgets the network) this could be handled
outside of the wpa_supplicant by using some SSID based hashing scheme to
generate MAC (or by just storing the randomly generated one) and
providing it to wpa_supplicant together with mac_addr=3 policy.

Signed-off-by: Andrzej Ostruszka <amo at semihalf.com>
Change-Id: I4046cf1cd08c84350a44703fe1fa0ecab4c82870
---
 wpa_supplicant/config.c                 | 46 ++++++++++++++++++++++++-
 wpa_supplicant/config_ssid.h            |  9 +++++
 wpa_supplicant/dbus/dbus_new_handlers.c | 22 +++++++++++-
 wpa_supplicant/wpa_supplicant.c         | 16 +++++++--
 wpa_supplicant/wpa_supplicant_i.h       |  3 +-
 5 files changed, 90 insertions(+), 6 deletions(-)

diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c
index bf97de698..1d17a3a32 100644
--- a/wpa_supplicant/config.c
+++ b/wpa_supplicant/config.c
@@ -2321,6 +2321,49 @@ static char * wpa_config_write_peerkey(const struct parse_data *data,
 #endif /* NO_CONFIG_WRITE */
 
 
+static int wpa_config_parse_mac_value(const struct parse_data *data,
+                                      struct wpa_ssid *ssid, int line,
+                                      const char *value)
+{
+	u8 mac_value[ETH_ALEN];
+
+	if (hwaddr_aton(value, mac_value) == 0) {
+		if (os_memcmp(mac_value, ssid->mac_value, ETH_ALEN) == 0)
+			return 1;
+		os_memcpy(ssid->mac_value, mac_value, ETH_ALEN);
+		return 0;
+	}
+
+	wpa_printf(MSG_ERROR, "Line %d: Invalid MAC address '%s'",
+		   line, value);
+	return -1;
+}
+
+#ifndef NO_CONFIG_WRITE
+static char * wpa_config_write_mac_value(const struct parse_data *data,
+                                         struct wpa_ssid *ssid)
+{
+	const size_t size = 3 * ETH_ALEN;
+	char *value;
+	int res;
+
+	if (ssid->mac_addr != 3)
+		return NULL;
+
+	value = os_malloc(size);
+	if (value == NULL)
+		return NULL;
+	res = os_snprintf(value, size, MACSTR, MAC2STR(ssid->mac_value));
+	if (os_snprintf_error(size, res)) {
+		os_free(value);
+		return NULL;
+	}
+	value[size-1] = '\0';
+	return value;
+}
+#endif /* NO_CONFIG_WRITE */
+
+
 /* Helper macros for network block parser */
 
 #ifdef OFFSET
@@ -2618,7 +2661,8 @@ static const struct parse_data ssid_fields[] = {
 	{ INT(update_identifier) },
 	{ STR_RANGE(roaming_consortium_selection, 0, MAX_ROAMING_CONS_OI_LEN) },
 #endif /* CONFIG_HS20 */
-	{ INT_RANGE(mac_addr, 0, 2) },
+	{ INT_RANGE(mac_addr, 0, 3) },
+	{ FUNC_KEY(mac_value) },
 	{ INT_RANGE(pbss, 0, 2) },
 	{ INT_RANGE(wps_disabled, 0, 1) },
 	{ INT_RANGE(fils_dh_group, 0, 65535) },
diff --git a/wpa_supplicant/config_ssid.h b/wpa_supplicant/config_ssid.h
index 339eead1c..61a5139ec 100644
--- a/wpa_supplicant/config_ssid.h
+++ b/wpa_supplicant/config_ssid.h
@@ -954,6 +954,7 @@ struct wpa_ssid {
 	 * 0 = use permanent MAC address
 	 * 1 = use random MAC address for each ESS connection
 	 * 2 = like 1, but maintain OUI (with local admin bit set)
+	 * 3 = use dedicated/pregenerated MAC address
 	 *
 	 * Internally, special value -1 is used to indicate that the parameter
 	 * was not specified in the configuration (i.e., default behavior is
@@ -961,6 +962,14 @@ struct wpa_ssid {
 	 */
 	int mac_addr;
 
+	/**
+	 * mac_value - specific MAC address to be used
+	 *
+	 * When mac_addr policy is equal to 3 this is the value of the MAC
+	 * address that should be used.
+	 */
+	u8 mac_value[ETH_ALEN];
+
 	/**
 	 * no_auto_peer - Do not automatically peer with compatible mesh peers
 	 *
diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c
index db9f30c9a..c4a7ceb44 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers.c
@@ -148,7 +148,7 @@ static const char * const dont_quote[] = {
 #ifdef CONFIG_P2P
 	"go_p2p_dev_addr", "p2p_client_list", "psk_list",
 #endif /* CONFIG_P2P */
-	NULL
+	"mac_value", NULL
 };
 
 static dbus_bool_t should_quote_opt(const char *key)
@@ -202,6 +202,8 @@ dbus_bool_t set_network_properties(struct wpa_supplicant *wpa_s,
 	struct wpa_dbus_dict_entry entry = { .type = DBUS_TYPE_STRING };
 	DBusMessageIter	iter_dict;
 	char *value = NULL;
+	bool mac_addr3_set = false;
+	bool mac_value_set = false;
 
 	if (!wpa_dbus_dict_open_read(iter, &iter_dict, error))
 		return FALSE;
@@ -311,12 +313,30 @@ dbus_bool_t set_network_properties(struct wpa_supplicant *wpa_s,
 		else if (os_strcmp(entry.key, "priority") == 0)
 			wpa_config_update_prio_list(wpa_s->conf);
 
+		/*
+		 * MAC address policy "3" needs to come with mac_value in
+		 * the message so make sure that it is present (checked after
+		 * the loop - here we just note what has been supplied).
+		 */
+		if (os_strcmp(entry.key, "mac_addr") == 0 &&
+		    atoi(value) == 3)
+			mac_addr3_set = true;
+		if (os_strcmp(entry.key, "mac_value") == 0)
+			mac_value_set = true;
+
 	skip_update:
 		os_free(value);
 		value = NULL;
 		wpa_dbus_dict_entry_clear(&entry);
 	}
 
+	if (mac_addr3_set && !mac_value_set) {
+		wpa_printf(MSG_ERROR, "Invalid mac_addr policy config");
+		dbus_set_error_const(error, DBUS_ERROR_INVALID_ARGS,
+				     "Invalid mac_addr policy config");
+		return FALSE;
+	}
+
 	return TRUE;
 
 error:
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index b80f1d4f0..c6f32e75f 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -2058,13 +2058,16 @@ void wpas_connect_work_done(struct wpa_supplicant *wpa_s)
 }
 
 
-int wpas_update_random_addr(struct wpa_supplicant *wpa_s, int style)
+int wpas_update_random_addr(struct wpa_supplicant *wpa_s, int style,
+			    struct wpa_ssid *ssid)
 {
 	struct os_reltime now;
 	u8 addr[ETH_ALEN];
 
 	os_get_reltime(&now);
 	if (wpa_s->last_mac_addr_style == style &&
+	    /* pregenerated addresses do not expire */
+	    wpa_s->last_mac_addr_style != 3 &&
 	    wpa_s->last_mac_addr_change.sec != 0 &&
 	    !os_reltime_expired(&now, &wpa_s->last_mac_addr_change,
 				wpa_s->conf->rand_addr_lifetime)) {
@@ -2083,6 +2086,13 @@ int wpas_update_random_addr(struct wpa_supplicant *wpa_s, int style)
 		if (random_mac_addr_keep_oui(addr) < 0)
 			return -1;
 		break;
+	case 3:
+		if (!ssid) {
+			wpa_msg(wpa_s, MSG_ERROR, "Invalid 'ssid' for address policy 3");
+			return -1;
+		}
+		os_memcpy(addr, ssid->mac_value, ETH_ALEN);
+		break;
 	default:
 		return -1;
 	}
@@ -2116,7 +2126,7 @@ int wpas_update_random_addr_disassoc(struct wpa_supplicant *wpa_s)
 	    !wpa_s->conf->preassoc_mac_addr)
 		return 0;
 
-	return wpas_update_random_addr(wpa_s, wpa_s->conf->preassoc_mac_addr);
+	return wpas_update_random_addr(wpa_s, wpa_s->conf->preassoc_mac_addr, NULL);
 }
 
 
@@ -2251,7 +2261,7 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
 #endif /* CONFIG_SAE */
 
 	if (rand_style > 0 && !wpa_s->reassoc_same_ess) {
-		if (wpas_update_random_addr(wpa_s, rand_style) < 0)
+		if (wpas_update_random_addr(wpa_s, rand_style, ssid) < 0)
 			return;
 		wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid);
 	} else if (rand_style == 0 && wpa_s->mac_addr_changed) {
diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h
index cbc955159..ee8049a4c 100644
--- a/wpa_supplicant/wpa_supplicant_i.h
+++ b/wpa_supplicant/wpa_supplicant_i.h
@@ -1631,7 +1631,8 @@ int disallowed_ssid(struct wpa_supplicant *wpa_s, const u8 *ssid,
 void wpas_request_connection(struct wpa_supplicant *wpa_s);
 void wpas_request_disconnection(struct wpa_supplicant *wpa_s);
 int wpas_build_ext_capab(struct wpa_supplicant *wpa_s, u8 *buf, size_t buflen);
-int wpas_update_random_addr(struct wpa_supplicant *wpa_s, int style);
+int wpas_update_random_addr(struct wpa_supplicant *wpa_s, int style,
+			    struct wpa_ssid *ssid);
 int wpas_update_random_addr_disassoc(struct wpa_supplicant *wpa_s);
 void add_freq(int *freqs, int *num_freqs, int freq);
 
-- 
2.34.0.rc0.344.g81b53c2807-goog



From worker at cksn.tk  Wed Nov 10 22:57:44 2021
From: worker at cksn.tk (worker at cksn.tk)
Date: Thu, 11 Nov 2021 07:57:44 +0100
Subject: [PATCH] wpa_supplicant: Add support for pregenerated MAC
In-Reply-To: <20211110191635.1175508-1-amo@semihalf.com>
References: <20211110191635.1175508-1-amo@semihalf.com>
Message-ID: <a2090d1e-8d52-b11d-3f1d-2c31ddb5146e@cksn.tk>

does this fix the problem that the user privacy setting will change the 
device-MAC address all the time? or what does it do in detail? i will 
reference this post here, so we also trying to fix some MAC/SSID/PSK 
issues: 
https://community.ui.com/questions/Does-Ubiquiti-have-any-plan-to-implement-WPA2-PPSK/1e42db2c-5fbf-42d7-a37e-793cdcc20b80

volker.

On 10.11.21 20:16, Andrzej Ostruszka wrote:
> Add new 'mac_addr' policy (3) with which supplicant expects to also
> obtain 'mac_value' with pregenerated value of MAC address to be used for
> given SSID.
>
> The main difference between this policy and policy 1 is the ability to
> control persistence of the MAC address used.  For example if there is
> a requirement to always use the same (but random) MAC address for given
> SSID (even if user removes/forgets the network) this could be handled
> outside of the wpa_supplicant by using some SSID based hashing scheme to
> generate MAC (or by just storing the randomly generated one) and
> providing it to wpa_supplicant together with mac_addr=3 policy.
>
> Signed-off-by: Andrzej Ostruszka <amo at semihalf.com>
> Change-Id: I4046cf1cd08c84350a44703fe1fa0ecab4c82870
> ---
>   wpa_supplicant/config.c                 | 46 ++++++++++++++++++++++++-
>   wpa_supplicant/config_ssid.h            |  9 +++++
>   wpa_supplicant/dbus/dbus_new_handlers.c | 22 +++++++++++-
>   wpa_supplicant/wpa_supplicant.c         | 16 +++++++--
>   wpa_supplicant/wpa_supplicant_i.h       |  3 +-
>   5 files changed, 90 insertions(+), 6 deletions(-)
>
> diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c
> index bf97de698..1d17a3a32 100644
> --- a/wpa_supplicant/config.c
> +++ b/wpa_supplicant/config.c
> @@ -2321,6 +2321,49 @@ static char * wpa_config_write_peerkey(const struct parse_data *data,
>   #endif /* NO_CONFIG_WRITE */
>   
>   
> +static int wpa_config_parse_mac_value(const struct parse_data *data,
> +                                      struct wpa_ssid *ssid, int line,
> +                                      const char *value)
> +{
> +	u8 mac_value[ETH_ALEN];
> +
> +	if (hwaddr_aton(value, mac_value) == 0) {
> +		if (os_memcmp(mac_value, ssid->mac_value, ETH_ALEN) == 0)
> +			return 1;
> +		os_memcpy(ssid->mac_value, mac_value, ETH_ALEN);
> +		return 0;
> +	}
> +
> +	wpa_printf(MSG_ERROR, "Line %d: Invalid MAC address '%s'",
> +		   line, value);
> +	return -1;
> +}
> +
> +#ifndef NO_CONFIG_WRITE
> +static char * wpa_config_write_mac_value(const struct parse_data *data,
> +                                         struct wpa_ssid *ssid)
> +{
> +	const size_t size = 3 * ETH_ALEN;
> +	char *value;
> +	int res;
> +
> +	if (ssid->mac_addr != 3)
> +		return NULL;
> +
> +	value = os_malloc(size);
> +	if (value == NULL)
> +		return NULL;
> +	res = os_snprintf(value, size, MACSTR, MAC2STR(ssid->mac_value));
> +	if (os_snprintf_error(size, res)) {
> +		os_free(value);
> +		return NULL;
> +	}
> +	value[size-1] = '\0';
> +	return value;
> +}
> +#endif /* NO_CONFIG_WRITE */
> +
> +
>   /* Helper macros for network block parser */
>   
>   #ifdef OFFSET
> @@ -2618,7 +2661,8 @@ static const struct parse_data ssid_fields[] = {
>   	{ INT(update_identifier) },
>   	{ STR_RANGE(roaming_consortium_selection, 0, MAX_ROAMING_CONS_OI_LEN) },
>   #endif /* CONFIG_HS20 */
> -	{ INT_RANGE(mac_addr, 0, 2) },
> +	{ INT_RANGE(mac_addr, 0, 3) },
> +	{ FUNC_KEY(mac_value) },
>   	{ INT_RANGE(pbss, 0, 2) },
>   	{ INT_RANGE(wps_disabled, 0, 1) },
>   	{ INT_RANGE(fils_dh_group, 0, 65535) },
> diff --git a/wpa_supplicant/config_ssid.h b/wpa_supplicant/config_ssid.h
> index 339eead1c..61a5139ec 100644
> --- a/wpa_supplicant/config_ssid.h
> +++ b/wpa_supplicant/config_ssid.h
> @@ -954,6 +954,7 @@ struct wpa_ssid {
>   	 * 0 = use permanent MAC address
>   	 * 1 = use random MAC address for each ESS connection
>   	 * 2 = like 1, but maintain OUI (with local admin bit set)
> +	 * 3 = use dedicated/pregenerated MAC address
>   	 *
>   	 * Internally, special value -1 is used to indicate that the parameter
>   	 * was not specified in the configuration (i.e., default behavior is
> @@ -961,6 +962,14 @@ struct wpa_ssid {
>   	 */
>   	int mac_addr;
>   
> +	/**
> +	 * mac_value - specific MAC address to be used
> +	 *
> +	 * When mac_addr policy is equal to 3 this is the value of the MAC
> +	 * address that should be used.
> +	 */
> +	u8 mac_value[ETH_ALEN];
> +
>   	/**
>   	 * no_auto_peer - Do not automatically peer with compatible mesh peers
>   	 *
> diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c
> index db9f30c9a..c4a7ceb44 100644
> --- a/wpa_supplicant/dbus/dbus_new_handlers.c
> +++ b/wpa_supplicant/dbus/dbus_new_handlers.c
> @@ -148,7 +148,7 @@ static const char * const dont_quote[] = {
>   #ifdef CONFIG_P2P
>   	"go_p2p_dev_addr", "p2p_client_list", "psk_list",
>   #endif /* CONFIG_P2P */
> -	NULL
> +	"mac_value", NULL
>   };
>   
>   static dbus_bool_t should_quote_opt(const char *key)
> @@ -202,6 +202,8 @@ dbus_bool_t set_network_properties(struct wpa_supplicant *wpa_s,
>   	struct wpa_dbus_dict_entry entry = { .type = DBUS_TYPE_STRING };
>   	DBusMessageIter	iter_dict;
>   	char *value = NULL;
> +	bool mac_addr3_set = false;
> +	bool mac_value_set = false;
>   
>   	if (!wpa_dbus_dict_open_read(iter, &iter_dict, error))
>   		return FALSE;
> @@ -311,12 +313,30 @@ dbus_bool_t set_network_properties(struct wpa_supplicant *wpa_s,
>   		else if (os_strcmp(entry.key, "priority") == 0)
>   			wpa_config_update_prio_list(wpa_s->conf);
>   
> +		/*
> +		 * MAC address policy "3" needs to come with mac_value in
> +		 * the message so make sure that it is present (checked after
> +		 * the loop - here we just note what has been supplied).
> +		 */
> +		if (os_strcmp(entry.key, "mac_addr") == 0 &&
> +		    atoi(value) == 3)
> +			mac_addr3_set = true;
> +		if (os_strcmp(entry.key, "mac_value") == 0)
> +			mac_value_set = true;
> +
>   	skip_update:
>   		os_free(value);
>   		value = NULL;
>   		wpa_dbus_dict_entry_clear(&entry);
>   	}
>   
> +	if (mac_addr3_set && !mac_value_set) {
> +		wpa_printf(MSG_ERROR, "Invalid mac_addr policy config");
> +		dbus_set_error_const(error, DBUS_ERROR_INVALID_ARGS,
> +				     "Invalid mac_addr policy config");
> +		return FALSE;
> +	}
> +
>   	return TRUE;
>   
>   error:
> diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
> index b80f1d4f0..c6f32e75f 100644
> --- a/wpa_supplicant/wpa_supplicant.c
> +++ b/wpa_supplicant/wpa_supplicant.c
> @@ -2058,13 +2058,16 @@ void wpas_connect_work_done(struct wpa_supplicant *wpa_s)
>   }
>   
>   
> -int wpas_update_random_addr(struct wpa_supplicant *wpa_s, int style)
> +int wpas_update_random_addr(struct wpa_supplicant *wpa_s, int style,
> +			    struct wpa_ssid *ssid)
>   {
>   	struct os_reltime now;
>   	u8 addr[ETH_ALEN];
>   
>   	os_get_reltime(&now);
>   	if (wpa_s->last_mac_addr_style == style &&
> +	    /* pregenerated addresses do not expire */
> +	    wpa_s->last_mac_addr_style != 3 &&
>   	    wpa_s->last_mac_addr_change.sec != 0 &&
>   	    !os_reltime_expired(&now, &wpa_s->last_mac_addr_change,
>   				wpa_s->conf->rand_addr_lifetime)) {
> @@ -2083,6 +2086,13 @@ int wpas_update_random_addr(struct wpa_supplicant *wpa_s, int style)
>   		if (random_mac_addr_keep_oui(addr) < 0)
>   			return -1;
>   		break;
> +	case 3:
> +		if (!ssid) {
> +			wpa_msg(wpa_s, MSG_ERROR, "Invalid 'ssid' for address policy 3");
> +			return -1;
> +		}
> +		os_memcpy(addr, ssid->mac_value, ETH_ALEN);
> +		break;
>   	default:
>   		return -1;
>   	}
> @@ -2116,7 +2126,7 @@ int wpas_update_random_addr_disassoc(struct wpa_supplicant *wpa_s)
>   	    !wpa_s->conf->preassoc_mac_addr)
>   		return 0;
>   
> -	return wpas_update_random_addr(wpa_s, wpa_s->conf->preassoc_mac_addr);
> +	return wpas_update_random_addr(wpa_s, wpa_s->conf->preassoc_mac_addr, NULL);
>   }
>   
>   
> @@ -2251,7 +2261,7 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
>   #endif /* CONFIG_SAE */
>   
>   	if (rand_style > 0 && !wpa_s->reassoc_same_ess) {
> -		if (wpas_update_random_addr(wpa_s, rand_style) < 0)
> +		if (wpas_update_random_addr(wpa_s, rand_style, ssid) < 0)
>   			return;
>   		wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid);
>   	} else if (rand_style == 0 && wpa_s->mac_addr_changed) {
> diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h
> index cbc955159..ee8049a4c 100644
> --- a/wpa_supplicant/wpa_supplicant_i.h
> +++ b/wpa_supplicant/wpa_supplicant_i.h
> @@ -1631,7 +1631,8 @@ int disallowed_ssid(struct wpa_supplicant *wpa_s, const u8 *ssid,
>   void wpas_request_connection(struct wpa_supplicant *wpa_s);
>   void wpas_request_disconnection(struct wpa_supplicant *wpa_s);
>   int wpas_build_ext_capab(struct wpa_supplicant *wpa_s, u8 *buf, size_t buflen);
> -int wpas_update_random_addr(struct wpa_supplicant *wpa_s, int style);
> +int wpas_update_random_addr(struct wpa_supplicant *wpa_s, int style,
> +			    struct wpa_ssid *ssid);
>   int wpas_update_random_addr_disassoc(struct wpa_supplicant *wpa_s);
>   void add_freq(int *freqs, int *num_freqs, int freq);
>   


From consult.awy at gmail.com  Thu Nov 11 08:41:45 2021
From: consult.awy at gmail.com (Alan Young)
Date: Thu, 11 Nov 2021 16:41:45 +0000
Subject: [PATCH] ACS, DFS: Support min_tx_power configuration
Message-ID: <77e8410a-4831-3101-cee4-a0a3dc94ed97@gmail.com>


-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-ACS-DFS-Support-min_tx_power-configuration.patch
Type: text/x-patch
Size: 4793 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/hostap/attachments/20211111/2a4761b3/attachment.bin>

From kyle at wirestar.net  Tue Nov 16 07:56:53 2021
From: kyle at wirestar.net (Kyle Leissner)
Date: Tue, 16 Nov 2021 09:56:53 -0600
Subject: Arbitrary RADIUS attributes from WPA2 handshake
Message-ID: <CAJDrMUd4tL-FGP7ubEmrawNyO6_dOVjAFtBQcjmzb2TkHjZwng@mail.gmail.com>

When an endpoint is performing WPA2-PSK and a RADIUS server is
configured for dynamic PSK, we would like to be able to send some of
the data of the WPA2 handshake inside the RADIUS request. The data we
would like to have is: the EAPOL key frame; the ANonce; the BSSID and
the WLAN name (SSID).

Is there a way to accomplish this natively in Hostadp today? I see
from the documentation, there is an option to add Arbitrary RADIUS
attributes, but I am unsure if these four attributes are available
natively?

# Arbitrary RADIUS attributes can be added into Access-Request and
# Accounting-Request packets by specifying the contents of the attributes with
# the following configuration parameters. There can be multiple of these to
# add multiple attributes. These parameters can also be used to override some
# of the attributes added automatically by hostapd.
# Format: <attr_id>[:<syntax:value>]
# attr_id: RADIUS attribute type (e.g., 26 = Vendor-Specific)
# syntax: s = string (UTF-8), d = integer, x = octet string
# value: attribute value in format indicated by the syntax
# If syntax and value parts are omitted, a null value (single 0x00 octet) is
# used.


From damiendejean at chromium.org  Wed Nov 17 01:40:31 2021
From: damiendejean at chromium.org (Damien Dejean)
Date: Wed, 17 Nov 2021 09:40:31 +0000
Subject: [PATCH] DBus: add RemoveAllCreds to the API.
Message-ID: <20211117094031.3355517-1-damiendejean@chromium.org>

Adds a method to allow the caller to remove all the interworking
credentials in one call.

Signed-off-by: Damien Dejean <damiendejean at chromium.org>
---
 tests/hwsim/test_dbus.py                | 17 ++++++
 wpa_supplicant/ctrl_iface.c             | 55 ++-----------------
 wpa_supplicant/dbus/dbus_new.c          |  6 ++
 wpa_supplicant/dbus/dbus_new_handlers.c | 40 +++++++++++++-
 wpa_supplicant/dbus/dbus_new_handlers.h |  3 +
 wpa_supplicant/wpa_supplicant.c         | 73 +++++++++++++++++++++++++
 wpa_supplicant/wpa_supplicant_i.h       |  4 ++
 7 files changed, 146 insertions(+), 52 deletions(-)

diff --git a/tests/hwsim/test_dbus.py b/tests/hwsim/test_dbus.py
index c9e2db028..59e7e4098 100644
--- a/tests/hwsim/test_dbus.py
+++ b/tests/hwsim/test_dbus.py
@@ -6118,6 +6118,23 @@ def test_dbus_creds(dev, apdev):
     if not "FAIL" in dev[0].get_cred(0, 'domain'):
         raise Exception("Credential remove failed")
 
+    # Removal of multiple credentials
+    cred1 = {'domain': 'server1.w1.fi','realm': 'server1.w1.fi','eap': 'TTLS'}
+    iface.AddCred(dbus.Dictionary(cred1, signature='sv'))
+    if "FAIL" in dev[0].get_cred(0, 'domain'):
+        raise Exception("Failed to add credential")
+
+    cred2 = {'domain': 'server2.w1.fi','realm': 'server2.w1.fi','eap': 'TTLS'}
+    iface.AddCred(dbus.Dictionary(cred2, signature='sv'))
+    if "FAIL" in dev[0].get_cred(1, 'domain'):
+        raise Exception("Failed to add credential")
+
+    iface.RemoveAllCreds()
+    if not "FAIL" in dev[0].get_cred(0, 'domain'):
+        raise Exception("Credential remove failed")
+    if not "FAIL" in dev[0].get_cred(1, 'domain'):
+        raise Exception("Credential remove failed")
+
 def test_dbus_interworking(dev, apdev):
     "D-Bus interworking selection"
     (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0])
diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index 9dc17f5ee..95e5efdb7 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -3793,47 +3793,6 @@ static int wpa_supplicant_ctrl_iface_add_cred(struct wpa_supplicant *wpa_s,
 }
 
 
-static int wpas_ctrl_remove_cred(struct wpa_supplicant *wpa_s,
-				 struct wpa_cred *cred)
-{
-	struct wpa_ssid *ssid;
-	char str[20];
-	int id;
-
-	if (cred == NULL) {
-		wpa_printf(MSG_DEBUG, "CTRL_IFACE: Could not find cred");
-		return -1;
-	}
-
-	id = cred->id;
-	if (wpa_config_remove_cred(wpa_s->conf, id) < 0) {
-		wpa_printf(MSG_DEBUG, "CTRL_IFACE: Could not find cred");
-		return -1;
-	}
-
-	wpa_msg(wpa_s, MSG_INFO, CRED_REMOVED "%d", id);
-
-	/* Remove any network entry created based on the removed credential */
-	ssid = wpa_s->conf->ssid;
-	while (ssid) {
-		if (ssid->parent_cred == cred) {
-			int res;
-
-			wpa_printf(MSG_DEBUG, "Remove network id %d since it "
-				   "used the removed credential", ssid->id);
-			res = os_snprintf(str, sizeof(str), "%d", ssid->id);
-			if (os_snprintf_error(sizeof(str), res))
-				str[sizeof(str) - 1] = '\0';
-			ssid = ssid->next;
-			wpa_supplicant_ctrl_iface_remove_network(wpa_s, str);
-		} else
-			ssid = ssid->next;
-	}
-
-	return 0;
-}
-
-
 static int wpa_supplicant_ctrl_iface_remove_cred(struct wpa_supplicant *wpa_s,
 						 char *cmd)
 {
@@ -3844,13 +3803,7 @@ static int wpa_supplicant_ctrl_iface_remove_cred(struct wpa_supplicant *wpa_s,
 	 * "provisioning_sp=<FQDN> */
 	if (os_strcmp(cmd, "all") == 0) {
 		wpa_printf(MSG_DEBUG, "CTRL_IFACE: REMOVE_CRED all");
-		cred = wpa_s->conf->cred;
-		while (cred) {
-			prev = cred;
-			cred = cred->next;
-			wpas_ctrl_remove_cred(wpa_s, prev);
-		}
-		return 0;
+		return wpa_supplicant_remove_all_creds(wpa_s);
 	}
 
 	if (os_strncmp(cmd, "sp_fqdn=", 8) == 0) {
@@ -3866,7 +3819,7 @@ static int wpa_supplicant_ctrl_iface_remove_cred(struct wpa_supplicant *wpa_s,
 					if (os_strcmp(prev->domain[i], cmd + 8)
 					    != 0)
 						continue;
-					wpas_ctrl_remove_cred(wpa_s, prev);
+					wpa_supplicant_remove_cred(wpa_s, prev);
 					break;
 				}
 			}
@@ -3883,7 +3836,7 @@ static int wpa_supplicant_ctrl_iface_remove_cred(struct wpa_supplicant *wpa_s,
 			cred = cred->next;
 			if (prev->provisioning_sp &&
 			    os_strcmp(prev->provisioning_sp, cmd + 16) == 0)
-				wpas_ctrl_remove_cred(wpa_s, prev);
+				wpa_supplicant_remove_cred(wpa_s, prev);
 		}
 		return 0;
 	}
@@ -3892,7 +3845,7 @@ static int wpa_supplicant_ctrl_iface_remove_cred(struct wpa_supplicant *wpa_s,
 	wpa_printf(MSG_DEBUG, "CTRL_IFACE: REMOVE_CRED id=%d", id);
 
 	cred = wpa_config_get_cred(wpa_s->conf, id);
-	return wpas_ctrl_remove_cred(wpa_s, cred);
+	return wpa_supplicant_remove_cred(wpa_s, cred);
 }
 
 
diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c
index 22971acff..501d3854c 100644
--- a/wpa_supplicant/dbus/dbus_new.c
+++ b/wpa_supplicant/dbus/dbus_new.c
@@ -3678,6 +3678,12 @@ static const struct wpa_dbus_method_desc wpas_dbus_interface_methods[] = {
 		  END_ARGS
 	  }
 	},
+	{ "RemoveAllCreds", WPAS_DBUS_NEW_IFACE_INTERFACE,
+	  (WPADBusMethodHandler) wpas_dbus_handler_remove_all_creds,
+	  {
+		  END_ARGS
+	  }
+	},
 	{ "InterworkingSelect", WPAS_DBUS_NEW_IFACE_INTERFACE,
 	  (WPADBusMethodHandler) wpas_dbus_handler_interworking_select,
 	  {
diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c
index 14e55211c..bf22203e0 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers.c
@@ -1705,6 +1705,7 @@ DBusMessage * wpas_dbus_handler_remove_cred(DBusMessage *message,
 	const char *op;
 	char *iface, *cred_id;
 	int id;
+	struct wpa_cred *cred;
 	int result;
 
 	dbus_message_get_args(message, NULL, DBUS_TYPE_OBJECT_PATH, &op,
@@ -1728,7 +1729,17 @@ DBusMessage * wpas_dbus_handler_remove_cred(DBusMessage *message,
 		goto out;
 	}
 
-	result = wpa_config_remove_cred(wpa_s->conf, id);
+	cred = wpa_config_get_cred(wpa_s->conf, id);
+	if (!cred) {
+		wpa_printf(MSG_ERROR,
+			   "%s[dbus]: could not find credential %s",
+			   __func__, op);
+		reply = wpas_dbus_error_invalid_args(message,
+			"could not find credentials");
+		goto out;
+	}
+
+	result = wpa_supplicant_remove_cred(wpa_s, cred);
 	if (result == -1) {
 		wpa_printf(MSG_ERROR,
 			   "%s[dbus]: error occurred when removing cred %d",
@@ -1744,6 +1755,33 @@ out:
 	return reply;
 }
 
+/**
+ * wpas_dbus_handler_remove_all_creds - Remove all the configured sets of
+ * credentials.
+ * @message: Pointer to incoming dbus message
+ * @wpa_s: wpa_supplicant structure for a network interface
+ * Returns: NULL indicating success or DBus error message on failure
+ *
+ * Handler function for "RemoveAllCreds" method call of a network interface.
+ */
+DBusMessage * wpas_dbus_handler_remove_all_creds(DBusMessage *message,
+						 struct wpa_supplicant *wpa_s)
+{
+	int res;
+	DBusMessage *reply = NULL;
+
+	res = wpa_supplicant_remove_all_creds(wpa_s);
+	if (res < 0) {
+		wpa_printf(MSG_ERROR,
+			   "%s[dbus]: failed to remove all credentials",
+			   __func__);
+		reply = wpas_dbus_error_unknown_error(message,
+			"failed to remove all credentials");
+	}
+
+	return reply;
+}
+
 DBusMessage * wpas_dbus_handler_interworking_select(DBusMessage *message,
 						    struct wpa_supplicant *wpa_s)
 {
diff --git a/wpa_supplicant/dbus/dbus_new_handlers.h b/wpa_supplicant/dbus/dbus_new_handlers.h
index 90e523e00..417a79f3b 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers.h
+++ b/wpa_supplicant/dbus/dbus_new_handlers.h
@@ -155,6 +155,9 @@ DBusMessage * wpas_dbus_handler_add_cred(DBusMessage *message,
 DBusMessage * wpas_dbus_handler_remove_cred(DBusMessage *message,
 					    struct wpa_supplicant *wpa_s);
 
+DBusMessage * wpas_dbus_handler_remove_all_creds(DBusMessage *message,
+						 struct wpa_supplicant *wpa_s);
+
 DBusMessage * wpas_dbus_handler_interworking_select(DBusMessage *message,
 						    struct wpa_supplicant *wpa_s);
 
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index b80f1d4f0..34da9cac4 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -4512,6 +4512,79 @@ void wpa_supplicant_select_network(struct wpa_supplicant *wpa_s,
 }
 
 
+/**
+ * wpa_supplicant_remove_cred - Remove the set of provided credentials and all
+ * the network entries created based on the removed credentials.
+ * @wpa_s: wpa_supplicant structure for a network interface
+ * @cred: the set of credentials to remove
+ */
+int wpa_supplicant_remove_cred(struct wpa_supplicant* wpa_s,
+			       struct wpa_cred* cred)
+{
+	struct wpa_ssid *ssid;
+	int id;
+
+	if (cred == NULL) {
+		wpa_printf(MSG_DEBUG, "Could not find cred");
+		return -1;
+	}
+
+	id = cred->id;
+	if (wpa_config_remove_cred(wpa_s->conf, id) < 0) {
+		wpa_printf(MSG_DEBUG, "Could not find cred %d", id);
+		return -1;
+	}
+
+	wpa_msg(wpa_s, MSG_INFO, CRED_REMOVED "%d", id);
+
+	/* Remove any network entry created based on the removed credential */
+	ssid = wpa_s->conf->ssid;
+	while (ssid) {
+		if (ssid->parent_cred == cred) {
+			int res;
+			wpa_printf(MSG_DEBUG, "Remove network id %d since it "
+				   "used the removed credential", ssid->id);
+			res = wpa_supplicant_remove_network(wpa_s, ssid->id);
+			if (res == -1) {
+				wpa_printf(MSG_DEBUG,
+					   "Could not find network id=%d",
+					   ssid->id);
+			}
+			ssid = ssid->next;
+		} else
+			ssid = ssid->next;
+	}
+
+	return 0;
+}
+
+
+/**
+ * wpa_supplicant_remove_cred - Remove all the interworking credentials.
+ * @wpa_s: wpa_supplicant structure for a network interface
+ */
+int wpa_supplicant_remove_all_creds(struct wpa_supplicant* wpa_s)
+{
+	int res;
+	struct wpa_cred *cred, *prev;
+
+	cred = wpa_s->conf->cred;
+	while (cred) {
+		prev = cred;
+		cred = cred->next;
+		res = wpa_supplicant_remove_cred(wpa_s, prev);
+		if (res < 0) {
+			wpa_printf(MSG_DEBUG, "Remove all credentials failed "
+				   "because remove of credential id=%d failed",
+				   prev->id);
+			return -1;
+		}
+	}
+
+	return 0;
+}
+
+
 /**
  * wpas_set_pkcs11_engine_and_module_path - Set PKCS #11 engine and module path
  * @wpa_s: wpa_supplicant structure for a network interface
diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h
index cbc955159..d68350ae9 100644
--- a/wpa_supplicant/wpa_supplicant_i.h
+++ b/wpa_supplicant/wpa_supplicant_i.h
@@ -38,6 +38,7 @@ struct wpa_bss;
 struct wpa_scan_results;
 struct hostapd_hw_modes;
 struct wpa_driver_associate_params;
+struct wpa_cred;
 
 /*
  * Forward declarations of private structures used within the ctrl_iface
@@ -1578,6 +1579,9 @@ void wpa_supplicant_disable_network(struct wpa_supplicant *wpa_s,
 				    struct wpa_ssid *ssid);
 void wpa_supplicant_select_network(struct wpa_supplicant *wpa_s,
 				   struct wpa_ssid *ssid);
+int wpa_supplicant_remove_cred(struct wpa_supplicant* wpa_s,
+			       struct wpa_cred* cred);
+int wpa_supplicant_remove_all_creds(struct wpa_supplicant* wpa_s);
 int wpas_set_pkcs11_engine_and_module_path(struct wpa_supplicant *wpa_s,
 					   const char *pkcs11_engine_path,
 					   const char *pkcs11_module_path);
-- 
2.34.0.rc1.387.gb447b232ab-goog



From Hicham_Hassoubi at bose.com  Thu Nov 18 14:49:18 2021
From: Hicham_Hassoubi at bose.com (Hassoubi, Hicham)
Date: Thu, 18 Nov 2021 22:49:18 +0000
Subject: Question: Reconnect P2P Client after reboot
Message-ID: <A8A5E515-0632-4382-BAED-3AAAE7544ADA@bose.com>

Hello,
I have multiple nodes and one of them is P2P GO, the GO creates a manual persistent group and invites the other nodes. Is it possible to persist the P2P network on the Client side and reconnect to the GO after reboot? If yes please share the sequence of commands.
Thank you
Hicham Hassoubi


From an_aire at yahoo.com  Thu Nov 11 03:47:55 2021
From: an_aire at yahoo.com (Andrejs Aire)
Date: Thu, 11 Nov 2021 13:47:55 +0200
Subject: MACsec: EAPOL-MKA is not starting on hostap
References: <4f4841e1-d411-215e-21b3-ce7219f2fd8f.ref@yahoo.com>
Message-ID: <4f4841e1-d411-215e-21b3-ce7219f2fd8f@yahoo.com>

Hi

I'm facing a problem with MACsec setup on wired connection with the 
latest hostap release v2.9.
My setup is trivial (just for testing) - HOSTAP and RADIUS on the same 
machine,
communicating via RADIUS protocol over 127.0.0.1;
The wpa_supplicant is requesting service from another machine connected 
to HOSTAP via network interface.
EAP frame exchange for authorization between wpa_supplicant and HOSTAP 
takes place via multicast address 01:80:c2:00:00:03.

The problem:
1) The wpa_supplicant is successfully authenticated @RADIUS which is 
indicated by the 'Success' EAP frame sent by the HOSTAP. At this moment 
the MKA should step in.
2) The wpa_supplicant sends an EAPOL-MKA frame which to my understanding 
is kind of heartbeat or indicator.
The HOSTAP does not respond with any EAPOL-MKA frames and does not send 
any EAPOL frame after.
3) The EAPOL-MKA "indicator" is repeated 3 times more by the 
wpa_supplicant and this is the end.

The fragment of debug trace from hostapd at the stage of authentication 
finish:
...
...
EAP: EAP entering state SUCCESS2
enp0s8: CTRL-EVENT-EAP-SUCCESS2 08:00:27:6e:f4:d8
IEEE 802.1X: 08:00:27:6e:f4:d8 BE_AUTH entering state SUCCESS
enp0s8: STA 08:00:27:6e:f4:d8 IEEE 802.1X: Sending EAP Packet 
(identifier 112)
IEEE 802.1X: 08:00:27:6e:f4:d8 AUTH_PAE entering state AUTHENTICATED
enp0s8: STA 08:00:27:6e:f4:d8 IEEE 802.1X: authorizing port
enp0s8: STA 08:00:27:6e:f4:d8 IEEE 802.1X: authenticated - EAP type: 13 
(TLS)
IEEE 802.1X: External notification - Create MKA for 08:00:27:6e:f4:d8
MACsec: Successfully fetched key (len=64)
MSK:? - hexdump(len=64): [REMOVED]
MACsec: Failed to get SessionID from EAPOL state machines
IEEE 802.1X: Could not get EAP Session Id
...
...

The last two lines of the above trace point to a problem I cannot 
explain. Please advise.
My hostapd.conf settings are:
ieee8021x=1
eapol_version=3
eapol_key_index_workaround=0

use_pae_group_addr=1
driver=macsec_linux
macsec_policy=1
eap_server=0
own_ip_addr=127.0.0.1
radius_client_addr=127.0.0.1
auth_server_addr=127.0.0.1
auth_server_port=1812
auth_server_shared_secret=testing123
acct_server_addr=127.0.0.1
acct_server_port=1813
acct_server_shared_secret=testing123

Interesting is that if I use the same hostapd binary but change the 
hostapd.conf for the in-built EAP authenticator
instead of external RADIUS server, then the EAPOL-MKA wakes up and 
MACsec is successfully enabled.

The "Failed to get SessionID..." lines are not observed in the trace 
output and the HOSTAP sends EAPOL-MKA frames.
My hostapd.conf settings for a "good" case differ from above 
configuration only with 'eap_server=1' and paths to the user file and 
certificates.
Of course, the RADIUS related section is entirely commented out.

Please give me a clue what could be a problem in "bad" case. What is the 
root cause for the following trace output?
MACsec: Failed to get SessionID from EAPOL state machines
IEEE 802.1X: Could not get EAP Session Id

Thanks in advance,
Andre




From ouden.biz at gmail.com  Sun Nov 21 20:04:12 2021
From: ouden.biz at gmail.com (Ouden Lin)
Date: Mon, 22 Nov 2021 12:04:12 +0800
Subject: [PATCH] nl80211: Clear preq NL handle after Unsbcsribe mgmt
Message-ID: <20211122040412.17008-1-ouden.lin@realtek.com>

From: Ouden <Ouden.Biz at gmail.com>

When entering the P2P connection, the radio working "p2p-listen" will enable and disable the probe request report.
This will set and clear the pointer nl_preq.
In the state WAIT_PEER_CONNECT that initiates the negotiation, the disable probe request report will not be triggered.
At the start of GO (start AP), Unsbcsribe mgmt will delete all management reports, including Probe Requst,
However, nl_preq is still not deleted.
Finally, Go cannot enable probe request reporting until the trigger is disabled.

This patch will check nl_preq after Unsubscribe mgmt.

Logs for as:
P2P: Go to Listen state while waiting for the peer to become ready for GO Negotiation
P2P: State WAIT_PEER_IDLE -> WAIT_PEER_CONNECT
P2P: Starting short listen state (state=WAIT_PEER_CONNECT)

nl80211: Enable Probe Request reporting nl_preq=0x562934543420
nl80211: Register frame type=0x40 (WLAN_FC_STYPE_PROBE_REQ) nl_handle=0x562934543420 match=

P2P: GO Negotiation with 00:AA:BB:0b:f0:3b
P2P: State WAIT_PEER_CONNECT -> IDLE
P2P: Skip stop_listen since we are on correct channel for response
P2P: State IDLE -> GO_NEG

Change-Id: I318ead337928e0f757bfaddfe808d967b05069b0
nl80211: Setup AP operations for P2P group (GO)
nl80211: Unsubscribe mgmt frames handle 0x8888dea1bcc6c2c9 (start AP)
nl80211: Setup AP(wlan1) - device_ap_sme=1 use_monitor=0
nl80211: Subscribe to mgmt frames with AP handle 0x5629344e4a40 (device SME)
nl80211: Probe Request reporting already on! nl_preq=0x8888dea1bcdcbca9

Signed-off-by: Ouden <Ouden.Biz at gmail.com>
---
 src/drivers/driver_nl80211.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 9a9a146f7..48d278f17 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -6721,6 +6721,11 @@ done:
 
 	if (is_ap_interface(nlmode)) {
 		nl80211_mgmt_unsubscribe(bss, "start AP");
+		if (bss->nl_preq) {
+			wpa_printf(MSG_DEBUG, "nl80211: Disable Probe Request "
+				   "reporting nl_preq=%p", bss->nl_preq);
+			nl80211_destroy_eloop_handle(&bss->nl_preq, 0);
+		}
 		/* Setup additional AP mode functionality if needed */
 		if (nl80211_setup_ap(bss))
 			return -1;
-- 
2.30.2



From magnusmalm at gmail.com  Mon Nov 22 06:18:48 2021
From: magnusmalm at gmail.com (Magnus Malm)
Date: Mon, 22 Nov 2021 15:18:48 +0100
Subject: [RFC PATCH 0/1] Add FQDN support for auth and acct server addresses
Message-ID: <20211122141849.286896-1-magnusmalm@gmail.com>

This is an RFC patch to add support for configuring RADIUS server address using Fully Qualified
Domain Names (FQDN). The patch in current form implements this support. The drawback is that
resolving is done in a syncronous manner. That is, the entire hostapd process locks up for the
duration of resolving.

One way to solve this would be to use, for instance, c-ares[1].

Besides the syncronous nature of resolving, which at first glance seems rather straight forward to
fix, this patch unfortunately breaks failover in the case a primary RADIUS server address is
configured to a FQDN that fails to resolve at startup.

I cannot for the life of me grok the code enough to realize why this is. hostapd simply never try
the secondary configured address.

Any and all comments, suggestions, and help is deeply appreciated.

Kind regards,
Magnus Malm

[1]: https://c-ares.org/

Magnus Malm (1):
  Add FQDN support for auth and acct server addresses

 hostapd/config_file.c      | 31 ++++++++++++++-
 src/radius/radius_client.c | 13 ++++++-
 src/radius/radius_client.h |  3 ++
 src/utils/ip_addr.c        | 77 ++++++++++++++++++++++++++++++++++++++
 src/utils/ip_addr.h        |  1 +
 5 files changed, 123 insertions(+), 2 deletions(-)

-- 
2.33.0



From magnusmalm at gmail.com  Mon Nov 22 06:18:49 2021
From: magnusmalm at gmail.com (Magnus Malm)
Date: Mon, 22 Nov 2021 15:18:49 +0100
Subject: [RFC PATCH 1/1] Add FQDN support for auth and acct server addresses
In-Reply-To: <20211122141849.286896-1-magnusmalm@gmail.com>
References: <20211122141849.286896-1-magnusmalm@gmail.com>
Message-ID: <20211122141849.286896-2-magnusmalm@gmail.com>

This patch adds support to configure Fully Qualified Domain Names (FQDN)
for authentication and accounting server addresses.

Signed-off-by: Magnus Malm <magnusmalm at gmail.com>
---
 hostapd/config_file.c      | 31 ++++++++++++++-
 src/radius/radius_client.c | 13 ++++++-
 src/radius/radius_client.h |  3 ++
 src/utils/ip_addr.c        | 77 ++++++++++++++++++++++++++++++++++++++
 src/utils/ip_addr.h        |  1 +
 5 files changed, 123 insertions(+), 2 deletions(-)

diff --git a/hostapd/config_file.c b/hostapd/config_file.c
index daf3f37ad..2e4aef0b5 100644
--- a/hostapd/config_file.c
+++ b/hostapd/config_file.c
@@ -24,6 +24,7 @@
 #include "ap/wpa_auth.h"
 #include "ap/ap_config.h"
 #include "config_file.h"
+#include "ip_addr.h"
 
 
 #ifndef CONFIG_NO_VLAN
@@ -627,6 +628,21 @@ static int hostapd_config_read_eap_user(const char *fname,
 
 
 #ifndef CONFIG_NO_RADIUS
+
+static int radius_parse_fqdn(const char *fqdn,
+			     struct hostapd_radius_server *nserv)
+{
+	size_t len = strnlen(fqdn, NI_MAXHOST);
+
+	if (len < 1)
+		return -1;
+
+	strncpy(nserv->fqdn_addr, fqdn, len);
+	nserv->fqdn_addr[len + 1] = '\0';
+
+	return 1;
+}
+
 static int
 hostapd_config_read_radius_addr(struct hostapd_radius_server **server,
 				int *num_server, const char *val, int def_port,
@@ -648,7 +664,20 @@ hostapd_config_read_radius_addr(struct hostapd_radius_server **server,
 	os_memset(nserv, 0, sizeof(*nserv));
 	nserv->port = def_port;
 	ret = hostapd_parse_ip_addr(val, &nserv->addr);
-	nserv->index = server_index++;
+
+	/* RADIUS address is not a valid IP address, see if it's a FQDN */
+	if (ret) {
+		if ((radius_parse_fqdn(val, nserv) < 0)) {
+			wpa_printf(MSG_ERROR, "FQDN %s parse failed", val);
+			return -1;
+		} else {
+			nserv->resolved = resolve_fqdn(nserv->fqdn_addr, &nserv->addr);
+                        if (!nserv->resolved)
+				wpa_printf(MSG_INFO, "FQDN %s resolve failed", nserv->fqdn_addr);
+                }
+		ret = 0;
+        }
+        nserv->index = server_index++;
 
 	return ret;
 }
diff --git a/src/radius/radius_client.c b/src/radius/radius_client.c
index ee9e46d2a..47f2aa96a 100644
--- a/src/radius/radius_client.c
+++ b/src/radius/radius_client.c
@@ -1136,7 +1136,18 @@ radius_change_server(struct radius_client_data *radius,
 				       radius_client_timer, radius, NULL);
 	}
 
-	switch (nserv->addr.af) {
+	/* If FQDN is confiured but it was not resolved when the config file was
+	 * read at startup, try again. */
+	if ((os_strncmp("", nserv->fqdn_addr, sizeof(nserv->fqdn_addr)) != 0) &&
+	    !nserv->resolved) {
+		nserv->resolved = resolve_fqdn(nserv->fqdn_addr, &nserv->addr);
+		if (!nserv->resolved) {
+			wpa_printf(MSG_ERROR, "FQDN %s failed to be resolved", nserv->fqdn_addr);
+			return -1;
+		}
+	}
+
+        switch (nserv->addr.af) {
 	case AF_INET:
 		os_memset(&serv, 0, sizeof(serv));
 		serv.sin_family = AF_INET;
diff --git a/src/radius/radius_client.h b/src/radius/radius_client.h
index 687cd81ae..989209ef3 100644
--- a/src/radius/radius_client.h
+++ b/src/radius/radius_client.h
@@ -9,6 +9,7 @@
 #ifndef RADIUS_CLIENT_H
 #define RADIUS_CLIENT_H
 
+#include <netdb.h>
 #include "ip_addr.h"
 
 struct radius_msg;
@@ -29,6 +30,8 @@ struct hostapd_radius_server {
 	 * addr - radiusAuthServerAddress or radiusAccServerAddress
 	 */
 	struct hostapd_ip_addr addr;
+	char fqdn_addr[NI_MAXHOST];
+	int resolved;
 
 	/**
 	 * port - radiusAuthClientServerPortNumber or radiusAccClientServerPortNumber
diff --git a/src/utils/ip_addr.c b/src/utils/ip_addr.c
index 92a359039..96a7b3b29 100644
--- a/src/utils/ip_addr.c
+++ b/src/utils/ip_addr.c
@@ -6,11 +6,88 @@
  * See README for more details.
  */
 
+#include <netdb.h>
+#include <resolv.h>
+
 #include "includes.h"
 
 #include "common.h"
 #include "ip_addr.h"
 
+/**
+ * Do a DNS lookup on fqdn_addr and, if successful, set addr accordingly. If
+ * resolve fails, return 0, otherwise 1.
+ */
+int resolve_fqdn(const char *fqdn_addr, struct hostapd_ip_addr *addr)
+{
+	struct addrinfo *servinfo = NULL;
+	struct addrinfo hints;
+	struct addrinfo *next = NULL;
+	int sfd = 0;
+	int rc = 0;
+
+	/* Ensure we do not get old DNS entries from getaddrinfo() */
+	res_init();
+
+	os_memset(&hints, 0, sizeof(struct addrinfo));
+	hints.ai_family = AF_UNSPEC;     /* IPv4 or IPv6*/
+	hints.ai_socktype = SOCK_DGRAM;  /* DGRAM sockets only */
+	hints.ai_protocol = IPPROTO_UDP; /* UDP only */
+	hints.ai_flags = AI_NUMERICSERV; /* No service name lookup */
+
+	rc = getaddrinfo(fqdn_addr, NULL, &hints, &servinfo);
+	if (rc != 0 || !servinfo) {
+		freeaddrinfo(servinfo);
+		return 0;
+	}
+
+	/* For each addrinfo entry (if any), validate it by trying to connect to
+	 * it. Break out of the loop with first entry we can connect with. */
+	for (next = servinfo; next != NULL; next = next->ai_next) {
+		/* We're only interested in IPv4 or IPv6 entries */
+		if (next->ai_family == AF_INET || next->ai_family == AF_INET6) {
+			sfd = socket(next->ai_family, next->ai_socktype, next->ai_protocol);
+			if (sfd == -1)
+				continue;
+
+			if (connect(sfd, next->ai_addr, next->ai_addrlen) == -1) {
+				close(sfd);
+				continue;
+			}
+
+			/* Connection established. Use this entry. */
+			close(sfd);
+			break;
+                }
+        }
+
+	/* Could not connect using any entry returned by getaddrinfo() */
+	if (next == NULL) {
+		freeaddrinfo(servinfo);
+		return 0;
+	}
+
+	/* Update addr with the entry we could connect with */
+	addr->af = next->ai_family;
+	switch (next->ai_family) {
+	case AF_INET:
+		addr->u.v4.s_addr = (*(struct sockaddr_in *)next->ai_addr).sin_addr.s_addr;
+		break;
+
+#ifdef CONFIG_IPV6
+	case AF_INET6:
+		os_memcpy(addr->u.v6.s6_addr, &(*(struct sockaddr_in6 *)next->ai_addr).sin6_addr,
+			  sizeof(struct in6_addr));
+		break;
+#endif /* CONFIG_IPV6 */
+	default:
+		return 0;
+	}
+
+	freeaddrinfo(servinfo);
+	return 1;
+}
+
 const char * hostapd_ip_txt(const struct hostapd_ip_addr *addr, char *buf,
 			    size_t buflen)
 {
diff --git a/src/utils/ip_addr.h b/src/utils/ip_addr.h
index 0670411cc..25d69b544 100644
--- a/src/utils/ip_addr.h
+++ b/src/utils/ip_addr.h
@@ -24,4 +24,5 @@ const char * hostapd_ip_txt(const struct hostapd_ip_addr *addr, char *buf,
 			    size_t buflen);
 int hostapd_parse_ip_addr(const char *txt, struct hostapd_ip_addr *addr);
 
+int resolve_fqdn(const char *fqdn_addr, struct hostapd_ip_addr *addr);
 #endif /* IP_ADDR_H */
-- 
2.33.0



From magnusmalm at gmail.com  Mon Nov 22 06:26:06 2021
From: magnusmalm at gmail.com (Magnus Malm)
Date: Mon, 22 Nov 2021 15:26:06 +0100
Subject: [RFC PATCH 0/1] Add FQDN support for auth and acct server addresses
Message-ID: <20211122142606.289898-1-magnusmalm@gmail.com>

This is an RFC patch to add support for configuring RADIUS server address using Fully Qualified
Domain Names (FQDN). The patch in current form implements this support. The drawback is that
resolving is done in a syncronous manner. That is, the entire hostapd process locks up for the
duration of resolving.

One way to solve this would be to use, for instance, c-ares[1].

Besides the syncronous nature of resolving, which at first glance seems rather straight forward to
fix, this patch unfortunately breaks failover in the case a primary RADIUS server address is
configured to a FQDN that fails to resolve at startup.

I cannot for the life of me grok the code enough to realize why this is. hostapd simply never try
the secondary configured address.

Any and all comments, suggestions, and help is deeply appreciated.

Kind regards,
Magnus Malm

[1]: https://c-ares.org/

Magnus Malm (1):
  Add FQDN support for auth and acct server addresses

 hostapd/config_file.c      | 31 ++++++++++++++-
 src/radius/radius_client.c | 13 ++++++-
 src/radius/radius_client.h |  3 ++
 src/utils/ip_addr.c        | 77 ++++++++++++++++++++++++++++++++++++++
 src/utils/ip_addr.h        |  1 +
 5 files changed, 123 insertions(+), 2 deletions(-)

-- 
2.33.0



From jcrites at blackberry.com  Mon Nov 29 06:11:40 2021
From: jcrites at blackberry.com (Jim Crites)
Date: Mon, 29 Nov 2021 14:11:40 +0000
Subject: is openssl 3.0 supported by wpa-2.9 and/or wpa-2.10 
In-Reply-To: <514b950eef4340ecbf9c1161434ab8e4@blackberry.com>
References: <514b950eef4340ecbf9c1161434ab8e4@blackberry.com>
Message-ID: <8eaff0075e514d35897aae722b7ae132@blackberry.com>

From: Jim Crites 
Sent: November 24, 2021 10:13 AM
To: 'hostap at lists.infradead.org' <hostap at lists.infradead.org>
Cc: Hanqi Yang <hanyang at blackberry.com>; Don Tegnelia <dtegnelia at blackberry.com>
Subject: is openssl 3.0 supported by wpa-2.9 and/or wpa-2.10 

Jouni et al,

We have a requirement for openssl 3.0 support with a supplicant package.
It doesn?t appear that wpa-2.9 supports it. Is that the case ?
Will wpa-2.10 support it ?

Thanks,
Jim

????? Jim Crites
Senior Systems Software Developer
Blackberry
4000 Centre Green Way, Suite 200
Cary, NC 27513
mailto:jcrites at blackberry.com
919.677.4626


----------------------------------------------------------------------
This transmission (including any attachments) may contain confidential information, privileged material (including material protected by the solicitor-client or other applicable privileges), or constitute non-public information. Any use of this information by anyone other than the intended recipient is prohibited. If you have received this transmission in error, please immediately reply to the sender and delete this information from your system. Use, dissemination, distribution, or reproduction of this transmission by unintended recipients is not authorized and may be unlawful.

From andrei.otcheretianski at intel.com  Tue Nov 30 07:39:43 2021
From: andrei.otcheretianski at intel.com (Andrei Otcheretianski)
Date: Tue, 30 Nov 2021 17:39:43 +0200
Subject: [PATCH] nl80211: set NL80211_SCAN_FLAG_COLOCATED_6GHZ in scan
Message-ID: <20211130153943.3531922-1-andrei.otcheretianski@intel.com>

From: Tova Mussai <tova.mussai at intel.com>

Set NL80211_SCAN_FLAG_COLOCATED_6GHZ in the scan params to enable
scanning for co-located AP's found in 2.4/5 GHz bands.

Signed-off-by: Tova Mussai <tova.mussai at intel.com>
Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski at intel.com>
---
 src/drivers/driver_nl80211_scan.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/drivers/driver_nl80211_scan.c b/src/drivers/driver_nl80211_scan.c
index 1316084805..356fbcebfa 100644
--- a/src/drivers/driver_nl80211_scan.c
+++ b/src/drivers/driver_nl80211_scan.c
@@ -300,6 +300,9 @@ nl80211_scan_common(struct i802_bss *bss, u8 cmd,
 			NL80211_SCAN_FLAG_OCE_PROBE_REQ_DEFERRAL_SUPPRESSION;
 	}
 
+	/* scan for 6ghz colocated APs that reported by other APs */
+	scan_flags |= NL80211_SCAN_FLAG_COLOCATED_6GHZ;
+
 	if (scan_flags &&
 	    nla_put_u32(msg, NL80211_ATTR_SCAN_FLAGS, scan_flags))
 		goto fail;
-- 
2.25.1



