git: 52efc7630680 - 2022Q2 - */*: Restore a missing wpa BSD driver patch

From: Cy Schubert <cy_at_FreeBSD.org>
Date: Mon, 20 Jun 2022 15:12:51 UTC
The branch 2022Q2 has been updated by cy:

URL: https://cgit.FreeBSD.org/ports/commit/?id=52efc7630680ad1445bf062b25d1f868e26e4d0d

commit 52efc7630680ad1445bf062b25d1f868e26e4d0d
Author:     Cy Schubert <cy@FreeBSD.org>
AuthorDate: 2022-06-20 14:25:42 +0000
Commit:     Cy Schubert <cy@FreeBSD.org>
CommitDate: 2022-06-20 15:12:01 +0000

    */*: Restore a missing wpa BSD driver patch
    
    These patches were removed to sync with base where in fact base was
    missing these patches and base should have been synced with the ports.
    
    PR:             264238
    Fixes:          b8477825c2dc42f6c595697a36f593c71f39fbad
                    c86f32d652eb9dd023049122d8ca37cb13ed07b6
    MFH:            2022Q2
    (cherry picked from commit 05a849eec9d949b3de32e464570cefbabcd64702)
---
 net/hostapd-devel/Makefile                         |  2 +-
 .../files/patch-src_drivers_driver__bsd.c          | 65 +++++++++++++++++++++-
 net/hostapd/Makefile                               |  2 +-
 net/hostapd/files/patch-src_drivers_driver__bsd.c  | 65 +++++++++++++++++++++-
 security/wpa_supplicant-devel/Makefile             |  2 +-
 .../files/patch-src_drivers_driver__bsd.c          | 65 +++++++++++++++++++++-
 security/wpa_supplicant/Makefile                   |  2 +-
 .../files/patch-src_drivers_driver__bsd.c          | 65 +++++++++++++++++++++-
 8 files changed, 256 insertions(+), 12 deletions(-)

diff --git a/net/hostapd-devel/Makefile b/net/hostapd-devel/Makefile
index e3e48c5dc457..907873af49a0 100644
--- a/net/hostapd-devel/Makefile
+++ b/net/hostapd-devel/Makefile
@@ -2,7 +2,7 @@
 
 PORTNAME=	hostapd
 PORTVERSION=	${COMMIT_DATE}
-PORTREVISION=	2
+PORTREVISION=	3
 CATEGORIES=	net
 PKGNAMESUFFIX=	-devel
 
diff --git a/net/hostapd-devel/files/patch-src_drivers_driver__bsd.c b/net/hostapd-devel/files/patch-src_drivers_driver__bsd.c
index f56c30c30ad3..dda055f26664 100644
--- a/net/hostapd-devel/files/patch-src_drivers_driver__bsd.c
+++ b/net/hostapd-devel/files/patch-src_drivers_driver__bsd.c
@@ -1,5 +1,5 @@
---- src/drivers/driver_bsd.c.orig	2021-06-02 14:11:18.000000000 -0700
-+++ src/drivers/driver_bsd.c	2021-06-13 23:11:15.089256000 -0700
+--- src/drivers/driver_bsd.c.orig	2022-05-24 13:30:39.000000000 -0700
++++ src/drivers/driver_bsd.c	2022-06-20 07:18:14.191871000 -0700
 @@ -853,14 +853,18 @@
  		drv = bsd_get_drvindex(global, ifm->ifm_index);
  		if (drv == NULL)
@@ -21,3 +21,64 @@
 +		    (drv->flags & IFF_RUNNING)  == 0)) {
  			wpa_printf(MSG_DEBUG, "RTM_IFINFO: Interface '%s' UP",
  				   drv->ifname);
+ 			wpa_supplicant_event(drv->ctx, EVENT_INTERFACE_ENABLED,
+@@ -1220,7 +1224,10 @@
+ 		mode = 0 /* STA */;
+ 		break;
+ 	case IEEE80211_MODE_IBSS:
++#if 0
+ 		mode = IFM_IEEE80211_IBSS;
++#endif
++		mode = IFM_IEEE80211_ADHOC;
+ 		break;
+ 	case IEEE80211_MODE_AP:
+ 		mode = IFM_IEEE80211_HOSTAP;
+@@ -1267,6 +1274,13 @@
+ 			  params->wpa_ie[0] == WLAN_EID_RSN ? 2 : 1) < 0)
+ 		return -1;
+ 
++	/*
++	 * NB: interface must be marked UP for association
++	 * or scanning (ap_scan=2)
++	 */
++	if (bsd_get_iface_flags(drv) < 0)
++		return -1;
++
+ 	os_memset(&mlme, 0, sizeof(mlme));
+ 	mlme.im_op = IEEE80211_MLME_ASSOC;
+ 	if (params->ssid != NULL)
+@@ -1485,6 +1499,17 @@
+ 	if (devcaps.dc_drivercaps & IEEE80211_C_WPA2)
+ 		drv->capa.key_mgmt = WPA_DRIVER_CAPA_KEY_MGMT_WPA2 |
+ 			WPA_DRIVER_CAPA_KEY_MGMT_WPA2_PSK;
++#ifdef __FreeBSD__
++	drv->capa.enc |= WPA_DRIVER_CAPA_ENC_WEP40 |
++	    WPA_DRIVER_CAPA_ENC_WEP104 |
++	    WPA_DRIVER_CAPA_ENC_TKIP |
++	    WPA_DRIVER_CAPA_ENC_CCMP;
++#else
++	/*
++	 * XXX
++	 * FreeBSD exports hardware cryptocaps.  These have no meaning for wpa
++	 * since net80211 performs software crypto.
++	 */
+ 
+ 	if (devcaps.dc_cryptocaps & IEEE80211_CRYPTO_WEP)
+ 		drv->capa.enc |= WPA_DRIVER_CAPA_ENC_WEP40 |
+@@ -1493,6 +1518,7 @@
+ 		drv->capa.enc |= WPA_DRIVER_CAPA_ENC_TKIP;
+ 	if (devcaps.dc_cryptocaps & IEEE80211_CRYPTO_AES_CCM)
+ 		drv->capa.enc |= WPA_DRIVER_CAPA_ENC_CCMP;
++#endif
+ 
+ 	if (devcaps.dc_drivercaps & IEEE80211_C_HOSTAP)
+ 		drv->capa.flags |= WPA_DRIVER_FLAGS_AP;
+@@ -1545,6 +1571,8 @@
+ 		}
+ 		if (ifmr.ifm_current & IFM_IEEE80211_HOSTAP)
+ 			return IEEE80211_M_HOSTAP;
++		if (ifmr.ifm_current & IFM_IEEE80211_IBSS)
++			return IEEE80211_M_IBSS;
+ 		if (ifmr.ifm_current & IFM_IEEE80211_MONITOR)
+ 			return IEEE80211_M_MONITOR;
+ #ifdef IEEE80211_M_MBSS
diff --git a/net/hostapd/Makefile b/net/hostapd/Makefile
index 5cd5d4fea22f..114041a960bb 100644
--- a/net/hostapd/Makefile
+++ b/net/hostapd/Makefile
@@ -2,7 +2,7 @@
 
 PORTNAME=	hostapd
 PORTVERSION=	2.10
-PORTREVISION=	3
+PORTREVISION=	4
 CATEGORIES=	net
 MASTER_SITES=	https://w1.fi/releases/
 
diff --git a/net/hostapd/files/patch-src_drivers_driver__bsd.c b/net/hostapd/files/patch-src_drivers_driver__bsd.c
index f56c30c30ad3..2c49538712af 100644
--- a/net/hostapd/files/patch-src_drivers_driver__bsd.c
+++ b/net/hostapd/files/patch-src_drivers_driver__bsd.c
@@ -1,5 +1,5 @@
---- src/drivers/driver_bsd.c.orig	2021-06-02 14:11:18.000000000 -0700
-+++ src/drivers/driver_bsd.c	2021-06-13 23:11:15.089256000 -0700
+--- src/drivers/driver_bsd.c.orig	2022-01-16 12:51:29.000000000 -0800
++++ src/drivers/driver_bsd.c	2022-06-20 07:14:50.617305000 -0700
 @@ -853,14 +853,18 @@
  		drv = bsd_get_drvindex(global, ifm->ifm_index);
  		if (drv == NULL)
@@ -21,3 +21,64 @@
 +		    (drv->flags & IFF_RUNNING)  == 0)) {
  			wpa_printf(MSG_DEBUG, "RTM_IFINFO: Interface '%s' UP",
  				   drv->ifname);
+ 			wpa_supplicant_event(drv->ctx, EVENT_INTERFACE_ENABLED,
+@@ -1220,7 +1224,10 @@
+ 		mode = 0 /* STA */;
+ 		break;
+ 	case IEEE80211_MODE_IBSS:
++#if 0
+ 		mode = IFM_IEEE80211_IBSS;
++#endif
++		mode = IFM_IEEE80211_ADHOC;
+ 		break;
+ 	case IEEE80211_MODE_AP:
+ 		mode = IFM_IEEE80211_HOSTAP;
+@@ -1267,6 +1274,13 @@
+ 			  params->wpa_ie[0] == WLAN_EID_RSN ? 2 : 1) < 0)
+ 		return -1;
+ 
++	/*
++	 * NB: interface must be marked UP for association
++	 * or scanning (ap_scan=2)
++	 */
++	if (bsd_get_iface_flags(drv) < 0)
++		return -1;
++
+ 	os_memset(&mlme, 0, sizeof(mlme));
+ 	mlme.im_op = IEEE80211_MLME_ASSOC;
+ 	if (params->ssid != NULL)
+@@ -1485,6 +1499,17 @@
+ 	if (devcaps.dc_drivercaps & IEEE80211_C_WPA2)
+ 		drv->capa.key_mgmt = WPA_DRIVER_CAPA_KEY_MGMT_WPA2 |
+ 			WPA_DRIVER_CAPA_KEY_MGMT_WPA2_PSK;
++#ifdef __FreeBSD__
++	drv->capa.enc |= WPA_DRIVER_CAPA_ENC_WEP40 |
++	    WPA_DRIVER_CAPA_ENC_WEP104 |
++	    WPA_DRIVER_CAPA_ENC_TKIP |
++	    WPA_DRIVER_CAPA_ENC_CCMP;
++#else
++	/*
++	 * XXX
++	 * FreeBSD exports hardware cryptocaps.  These have no meaning for wpa
++	 * since net80211 performs software crypto.
++	 */
+ 
+ 	if (devcaps.dc_cryptocaps & IEEE80211_CRYPTO_WEP)
+ 		drv->capa.enc |= WPA_DRIVER_CAPA_ENC_WEP40 |
+@@ -1493,6 +1518,7 @@
+ 		drv->capa.enc |= WPA_DRIVER_CAPA_ENC_TKIP;
+ 	if (devcaps.dc_cryptocaps & IEEE80211_CRYPTO_AES_CCM)
+ 		drv->capa.enc |= WPA_DRIVER_CAPA_ENC_CCMP;
++#endif
+ 
+ 	if (devcaps.dc_drivercaps & IEEE80211_C_HOSTAP)
+ 		drv->capa.flags |= WPA_DRIVER_FLAGS_AP;
+@@ -1545,6 +1571,8 @@
+ 		}
+ 		if (ifmr.ifm_current & IFM_IEEE80211_HOSTAP)
+ 			return IEEE80211_M_HOSTAP;
++		if (ifmr.ifm_current & IFM_IEEE80211_IBSS)
++			return IEEE80211_M_IBSS;
+ 		if (ifmr.ifm_current & IFM_IEEE80211_MONITOR)
+ 			return IEEE80211_M_MONITOR;
+ #ifdef IEEE80211_M_MBSS
diff --git a/security/wpa_supplicant-devel/Makefile b/security/wpa_supplicant-devel/Makefile
index 6d83310e50da..d972b2c5c512 100644
--- a/security/wpa_supplicant-devel/Makefile
+++ b/security/wpa_supplicant-devel/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	wpa_supplicant
 PORTVERSION=	${COMMIT_DATE}
-PORTREVISION=	2
+PORTREVISION=	3
 CATEGORIES=	security net
 PKGNAMESUFFIX=	-devel
 
diff --git a/security/wpa_supplicant-devel/files/patch-src_drivers_driver__bsd.c b/security/wpa_supplicant-devel/files/patch-src_drivers_driver__bsd.c
index decf9a3aebdc..6a400fd174c2 100644
--- a/security/wpa_supplicant-devel/files/patch-src_drivers_driver__bsd.c
+++ b/security/wpa_supplicant-devel/files/patch-src_drivers_driver__bsd.c
@@ -1,5 +1,5 @@
---- src/drivers/driver_bsd.c.orig	2021-06-02 14:11:18.000000000 -0700
-+++ src/drivers/driver_bsd.c	2021-06-13 23:08:54.275496000 -0700
+--- src/drivers/driver_bsd.c.orig	2022-05-24 13:30:39.000000000 -0700
++++ src/drivers/driver_bsd.c	2022-06-20 07:13:36.571991000 -0700
 @@ -853,14 +853,18 @@
  		drv = bsd_get_drvindex(global, ifm->ifm_index);
  		if (drv == NULL)
@@ -21,3 +21,64 @@
 +		    (drv->flags & IFF_RUNNING)  == 0)) {
  			wpa_printf(MSG_DEBUG, "RTM_IFINFO: Interface '%s' UP",
  				   drv->ifname);
+ 			wpa_supplicant_event(drv->ctx, EVENT_INTERFACE_ENABLED,
+@@ -1220,7 +1224,10 @@
+ 		mode = 0 /* STA */;
+ 		break;
+ 	case IEEE80211_MODE_IBSS:
++#if 0
+ 		mode = IFM_IEEE80211_IBSS;
++#endif
++		mode = IFM_IEEE80211_ADHOC;
+ 		break;
+ 	case IEEE80211_MODE_AP:
+ 		mode = IFM_IEEE80211_HOSTAP;
+@@ -1267,6 +1274,13 @@
+ 			  params->wpa_ie[0] == WLAN_EID_RSN ? 2 : 1) < 0)
+ 		return -1;
+ 
++	/*
++	 * NB: interface must be marked UP for association
++	 * or scanning (ap_scan=2)
++	 */
++	if (bsd_get_iface_flags(drv) < 0)
++		return -1;
++
+ 	os_memset(&mlme, 0, sizeof(mlme));
+ 	mlme.im_op = IEEE80211_MLME_ASSOC;
+ 	if (params->ssid != NULL)
+@@ -1485,6 +1499,17 @@
+ 	if (devcaps.dc_drivercaps & IEEE80211_C_WPA2)
+ 		drv->capa.key_mgmt = WPA_DRIVER_CAPA_KEY_MGMT_WPA2 |
+ 			WPA_DRIVER_CAPA_KEY_MGMT_WPA2_PSK;
++#ifdef __FreeBSD__
++	drv->capa.enc |= WPA_DRIVER_CAPA_ENC_WEP40 |
++	    WPA_DRIVER_CAPA_ENC_WEP104 |
++	    WPA_DRIVER_CAPA_ENC_TKIP |
++	    WPA_DRIVER_CAPA_ENC_CCMP;
++#else
++	/*
++	 * XXX
++	 * FreeBSD exports hardware cryptocaps.  These have no meaning for wpa
++	 * since net80211 performs software crypto.
++	 */
+ 
+ 	if (devcaps.dc_cryptocaps & IEEE80211_CRYPTO_WEP)
+ 		drv->capa.enc |= WPA_DRIVER_CAPA_ENC_WEP40 |
+@@ -1493,6 +1518,7 @@
+ 		drv->capa.enc |= WPA_DRIVER_CAPA_ENC_TKIP;
+ 	if (devcaps.dc_cryptocaps & IEEE80211_CRYPTO_AES_CCM)
+ 		drv->capa.enc |= WPA_DRIVER_CAPA_ENC_CCMP;
++#endif
+ 
+ 	if (devcaps.dc_drivercaps & IEEE80211_C_HOSTAP)
+ 		drv->capa.flags |= WPA_DRIVER_FLAGS_AP;
+@@ -1545,6 +1571,8 @@
+ 		}
+ 		if (ifmr.ifm_current & IFM_IEEE80211_HOSTAP)
+ 			return IEEE80211_M_HOSTAP;
++		if (ifmr.ifm_current & IFM_IEEE80211_IBSS)
++			return IEEE80211_M_IBSS;
+ 		if (ifmr.ifm_current & IFM_IEEE80211_MONITOR)
+ 			return IEEE80211_M_MONITOR;
+ #ifdef IEEE80211_M_MBSS
diff --git a/security/wpa_supplicant/Makefile b/security/wpa_supplicant/Makefile
index 0248141d32b2..1b3e5889d2c6 100644
--- a/security/wpa_supplicant/Makefile
+++ b/security/wpa_supplicant/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	wpa_supplicant
 PORTVERSION=	2.10
-PORTREVISION=	3
+PORTREVISION=	4
 CATEGORIES=	security net
 MASTER_SITES=	https://w1.fi/releases/
 
diff --git a/security/wpa_supplicant/files/patch-src_drivers_driver__bsd.c b/security/wpa_supplicant/files/patch-src_drivers_driver__bsd.c
index decf9a3aebdc..440233164126 100644
--- a/security/wpa_supplicant/files/patch-src_drivers_driver__bsd.c
+++ b/security/wpa_supplicant/files/patch-src_drivers_driver__bsd.c
@@ -1,5 +1,5 @@
---- src/drivers/driver_bsd.c.orig	2021-06-02 14:11:18.000000000 -0700
-+++ src/drivers/driver_bsd.c	2021-06-13 23:08:54.275496000 -0700
+--- src/drivers/driver_bsd.c.orig	2022-01-16 12:51:29.000000000 -0800
++++ src/drivers/driver_bsd.c	2022-06-20 07:11:44.629814000 -0700
 @@ -853,14 +853,18 @@
  		drv = bsd_get_drvindex(global, ifm->ifm_index);
  		if (drv == NULL)
@@ -21,3 +21,64 @@
 +		    (drv->flags & IFF_RUNNING)  == 0)) {
  			wpa_printf(MSG_DEBUG, "RTM_IFINFO: Interface '%s' UP",
  				   drv->ifname);
+ 			wpa_supplicant_event(drv->ctx, EVENT_INTERFACE_ENABLED,
+@@ -1220,7 +1224,10 @@
+ 		mode = 0 /* STA */;
+ 		break;
+ 	case IEEE80211_MODE_IBSS:
++#if 0
+ 		mode = IFM_IEEE80211_IBSS;
++#endif
++		mode = IFM_IEEE80211_ADHOC;
+ 		break;
+ 	case IEEE80211_MODE_AP:
+ 		mode = IFM_IEEE80211_HOSTAP;
+@@ -1267,6 +1274,13 @@
+ 			  params->wpa_ie[0] == WLAN_EID_RSN ? 2 : 1) < 0)
+ 		return -1;
+ 
++	/*
++	 * NB: interface must be marked UP for association
++	 * or scanning (ap_scan=2)
++	 */
++	if (bsd_get_iface_flags(drv) < 0)
++		return -1;
++
+ 	os_memset(&mlme, 0, sizeof(mlme));
+ 	mlme.im_op = IEEE80211_MLME_ASSOC;
+ 	if (params->ssid != NULL)
+@@ -1485,6 +1499,17 @@
+ 	if (devcaps.dc_drivercaps & IEEE80211_C_WPA2)
+ 		drv->capa.key_mgmt = WPA_DRIVER_CAPA_KEY_MGMT_WPA2 |
+ 			WPA_DRIVER_CAPA_KEY_MGMT_WPA2_PSK;
++#ifdef __FreeBSD__
++	drv->capa.enc |= WPA_DRIVER_CAPA_ENC_WEP40 |
++	    WPA_DRIVER_CAPA_ENC_WEP104 |
++	    WPA_DRIVER_CAPA_ENC_TKIP |
++	    WPA_DRIVER_CAPA_ENC_CCMP;
++#else
++	/*
++	 * XXX
++	 * FreeBSD exports hardware cryptocaps.  These have no meaning for wpa
++	 * since net80211 performs software crypto.
++	 */
+ 
+ 	if (devcaps.dc_cryptocaps & IEEE80211_CRYPTO_WEP)
+ 		drv->capa.enc |= WPA_DRIVER_CAPA_ENC_WEP40 |
+@@ -1493,6 +1518,7 @@
+ 		drv->capa.enc |= WPA_DRIVER_CAPA_ENC_TKIP;
+ 	if (devcaps.dc_cryptocaps & IEEE80211_CRYPTO_AES_CCM)
+ 		drv->capa.enc |= WPA_DRIVER_CAPA_ENC_CCMP;
++#endif
+ 
+ 	if (devcaps.dc_drivercaps & IEEE80211_C_HOSTAP)
+ 		drv->capa.flags |= WPA_DRIVER_FLAGS_AP;
+@@ -1545,6 +1571,8 @@
+ 		}
+ 		if (ifmr.ifm_current & IFM_IEEE80211_HOSTAP)
+ 			return IEEE80211_M_HOSTAP;
++		if (ifmr.ifm_current & IFM_IEEE80211_IBSS)
++			return IEEE80211_M_IBSS;
+ 		if (ifmr.ifm_current & IFM_IEEE80211_MONITOR)
+ 			return IEEE80211_M_MONITOR;
+ #ifdef IEEE80211_M_MBSS