From nobody Tue Sep 12 05:53:02 2023 X-Original-To: dev-commits-ports-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4RlCRf3B5rz4sYDP; Tue, 12 Sep 2023 05:53:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RlCRf20Ncz3d2J; Tue, 12 Sep 2023 05:53:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694497982; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ioH/Ffksvjdj2BUzLAHeNDxzplorxLD3emvj193xfeA=; b=p7gJiHuRioJwu4qC8zzYuTev3DXUWUKJnr3WVeYP20oiMERGR/THomCpnOuzEaTSgeZXKM T32ArsQchXHT9aFsg8dt591LwdiZzN7ZRilyL0Fx5ofUrmI5VhNOKYcHlEteO58dlA/BJn DX0yqlKGnNmOQjCwDpKdn/R0NL3NT88y3yQitScU8ZDnqEPW+XGCvcVO1h9i/C2Fqxgzr8 g9bCe70SpgJthZTfc/3v2qwJSlN6F8XLBP7brwK+YTW/aDxyGJ1KUpBmZF4m+XHYWOA7x3 foYsEFxvZkdbNBqKiuqo+Wsio6z0P33MEwQWJqLweuGFha23yXjZVyLGnwSd5A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1694497982; a=rsa-sha256; cv=none; b=bBPwKq6/KYXvFT1hesYeIHJGYwYiUFPUEEv1coK/UX/7pKPVBUCeRNtszd5/6uS8DjSMi8 /D0nsiamhx77/XFtaIx3ZcBsnJGQ1ISqY8RrC1kVEgDlw6+sVSKdmKOHz1G685jBaYlvdl HEXcaQhYYnpuL32orFqOqEQ12nRVk8E/39+bbWKhA59rgFquTUOO9jT7eXZGmdd/tMG8NJ CDOPZ88CLvvFs4BlzBmT655y0EmF6rBSbqYpW6xh7ARZQIwAf5gZlliqvYAV5cPyumId/9 nhDYM4iegmE4CLwd1h1HqqLTvOOT0c1how9Gu6jU/8gXgQ39KIQgLjPh1nI0ig== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694497982; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ioH/Ffksvjdj2BUzLAHeNDxzplorxLD3emvj193xfeA=; b=sIe7h+ziCKPxxPY2pOke+Z/0Pt56o8vlcH8NmhrITkSn2Ux/+KrL2BYi77PHv5O3vD7woi n5D+PJWTo1lnSw3ys+LnVqBAujsi4a0tmb3C5Bw2BJ3BatkJzMD6xtPQA7TZZjtlMrX1DV iBR5FBAJAX8DPtnCrAOpzsDDJ+avpybkDsqvSMFkRIstkGVach6jK2cIMuhVE5M/arX/qd CIbCAISgLi8HRVSgk2iGyifHKyI16MqrGxUZjTU9HLQ42/SXCxcShKtuKojjRr3u/qCVzj ke+4a8PLUo+34ikwSp6vs0Tb3xC/ZzQPDM8G26AdOnrdmfzZEB8cGTncMx8VUw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4RlCRf15sWz4qg; Tue, 12 Sep 2023 05:53:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 38C5r2tX086479; Tue, 12 Sep 2023 05:53:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 38C5r2QZ086476; Tue, 12 Sep 2023 05:53:02 GMT (envelope-from git) Date: Tue, 12 Sep 2023 05:53:02 GMT Message-Id: <202309120553.38C5r2QZ086476@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Cy Schubert Subject: git: 087cebebd616 - main - net/hostapd: driver_bsd.c: backout upstream IFF_ change and add logging List-Id: Commit messages for all branches of the ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-all@freebsd.org X-BeenThere: dev-commits-ports-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: cy X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 087cebebd616c77d469a9e337fa0c99041b3ccfb Auto-Submitted: auto-generated The branch main has been updated by cy: URL: https://cgit.FreeBSD.org/ports/commit/?id=087cebebd616c77d469a9e337fa0c99041b3ccfb commit 087cebebd616c77d469a9e337fa0c99041b3ccfb Author: Cy Schubert AuthorDate: 2023-09-11 06:20:47 +0000 Commit: Cy Schubert CommitDate: 2023-09-12 05:50:53 +0000 net/hostapd: driver_bsd.c: backout upstream IFF_ change and add logging This reverts the state to our old supplicant logic setting or clearing IFF_UP if needed. In addition this adds logging for the cases in which we do (not) change the interface state. Depending on testing this seems to help bringing WiFi up or not log any needed changes (which would be the expected wpa_supplicant logic now). People should look out for ``(changed)`` log entries (at least if debugging the issue; this way we will at least have data points). There is a hypothesis still pondered that the entire IFF_UP toggling only exploits a race in net80211 (see further discssussions for more debugging and alternative solutions see D38508 and D38753). That may also explain why the changes to the rc startup script [1] only helped partially for some people to no longer see the continuous CTRL-EVENT-SCAN-FAILED. It is highly likely that we will want further changes and until we know for sure that people are seeing ''(changed)'' events this should stay local. Should we need to upstream this we'll likely need #ifdef __FreeBSD__ around this code. PR: 273696 Obtained from: src bfb202c4554a MFH: 2023Q3 --- net/hostapd/Makefile | 2 +- net/hostapd/files/patch-src_drivers_driver__bsd.c | 130 ++++++++++++++++++++-- 2 files changed, 122 insertions(+), 10 deletions(-) diff --git a/net/hostapd/Makefile b/net/hostapd/Makefile index a0e8f9b5ca05..b6db58496f49 100644 --- a/net/hostapd/Makefile +++ b/net/hostapd/Makefile @@ -1,6 +1,6 @@ PORTNAME= hostapd PORTVERSION= 2.10 -PORTREVISION= 5 +PORTREVISION= 6 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 112a8230671c..014a10354b0c 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 2022-01-16 12:51:29.000000000 -0800 -+++ src/drivers/driver_bsd.c 2022-07-03 14:12:06.167581000 -0700 ++++ src/drivers/driver_bsd.c 2023-09-10 23:11:43.205866000 -0700 @@ -14,6 +14,7 @@ #include "driver.h" #include "eloop.h" @@ -8,7 +8,62 @@ #include "common/wpa_common.h" #include -@@ -853,14 +854,18 @@ +@@ -293,8 +294,9 @@ + } + + static int +-bsd_get_iface_flags(struct bsd_driver_data *drv) ++bsd_ctrl_iface(void *priv, int enable) + { ++ struct bsd_driver_data *drv = priv; + struct ifreq ifr; + + os_memset(&ifr, 0, sizeof(ifr)); +@@ -306,7 +308,34 @@ + return -1; + } + drv->flags = ifr.ifr_flags; ++ ++ ++ if (enable) { ++ if (ifr.ifr_flags & IFF_UP) ++ goto nochange; ++ ifr.ifr_flags |= IFF_UP; ++ } else { ++ if (!(ifr.ifr_flags & IFF_UP)) ++ goto nochange; ++ ifr.ifr_flags &= ~IFF_UP; ++ } ++ ++ if (ioctl(drv->global->sock, SIOCSIFFLAGS, &ifr) < 0) { ++ wpa_printf(MSG_ERROR, "ioctl[SIOCSIFFLAGS]: %s", ++ strerror(errno)); ++ return -1; ++ } ++ ++ wpa_printf(MSG_DEBUG, "%s: if %s (changed) enable %d IFF_UP %d ", ++ __func__, drv->ifname, enable, ((ifr.ifr_flags & IFF_UP) != 0)); ++ ++ drv->flags = ifr.ifr_flags; + return 0; ++ ++nochange: ++ wpa_printf(MSG_DEBUG, "%s: if %s (no change) enable %d IFF_UP %d ", ++ __func__, drv->ifname, enable, ((ifr.ifr_flags & IFF_UP) != 0)); ++ return 0; + } + + static int +@@ -525,7 +554,7 @@ + __func__); + return -1; + } +- return 0; ++ return bsd_ctrl_iface(priv, 1); + } + + static void +@@ -853,14 +882,18 @@ drv = bsd_get_drvindex(global, ifm->ifm_index); if (drv == NULL) return; @@ -30,7 +85,32 @@ wpa_printf(MSG_DEBUG, "RTM_IFINFO: Interface '%s' UP", drv->ifname); wpa_supplicant_event(drv->ctx, EVENT_INTERFACE_ENABLED, -@@ -1197,13 +1202,41 @@ +@@ -1025,7 +1058,8 @@ + if (l2_packet_get_own_addr(drv->sock_xmit, params->own_addr)) + goto bad; + +- if (bsd_get_iface_flags(drv) < 0) ++ /* mark down during setup */ ++ if (bsd_ctrl_iface(drv, 0) < 0) + goto bad; + + if (bsd_set_mediaopt(drv, IFM_OMASK, IFM_IEEE80211_HOSTAP) < 0) { +@@ -1050,12 +1084,13 @@ + { + struct bsd_driver_data *drv = priv; + ++ if (drv->ifindex != 0) ++ bsd_ctrl_iface(drv, 0); + if (drv->sock_xmit != NULL) + l2_packet_deinit(drv->sock_xmit); + os_free(drv); + } + +- + static int + bsd_set_sta_authorized(void *priv, const u8 *addr, + unsigned int total_flags, unsigned int flags_or, +@@ -1197,13 +1232,41 @@ } static int @@ -73,7 +153,7 @@ wpa_printf(MSG_DEBUG, "%s: ssid '%.*s' wpa ie len %u pairwise %u group %u key mgmt %u" -@@ -1220,7 +1253,10 @@ +@@ -1220,7 +1283,10 @@ mode = 0 /* STA */; break; case IEEE80211_MODE_IBSS: @@ -84,7 +164,7 @@ break; case IEEE80211_MODE_AP: mode = IFM_IEEE80211_HOSTAP; -@@ -1249,24 +1285,33 @@ +@@ -1249,24 +1315,33 @@ ret = -1; if (wpa_driver_bsd_set_auth_alg(drv, params->auth_alg) < 0) ret = -1; @@ -121,7 +201,7 @@ + * NB: interface must be marked UP for association + * or scanning (ap_scan=2) + */ -+ if (bsd_get_iface_flags(drv) < 0) ++ if (bsd_ctrl_iface(drv, 1) < 0) return -1; - if (params->wpa_ie_len && @@ -132,7 +212,20 @@ os_memset(&mlme, 0, sizeof(mlme)); mlme.im_op = IEEE80211_MLME_ASSOC; if (params->ssid != NULL) -@@ -1485,6 +1530,17 @@ +@@ -1309,11 +1384,8 @@ + } + + /* NB: interface must be marked UP to do a scan */ +- if (!(drv->flags & IFF_UP)) { +- wpa_printf(MSG_DEBUG, "%s: interface is not up, cannot scan", +- __func__); ++ if (bsd_ctrl_iface(drv, 1) < 0) + return -1; +- } + + #ifdef IEEE80211_IOC_SCAN_MAX_SSID + os_memset(&sr, 0, sizeof(sr)); +@@ -1485,6 +1557,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; @@ -150,7 +243,7 @@ if (devcaps.dc_cryptocaps & IEEE80211_CRYPTO_WEP) drv->capa.enc |= WPA_DRIVER_CAPA_ENC_WEP40 | -@@ -1493,6 +1549,7 @@ +@@ -1493,6 +1576,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; @@ -158,7 +251,7 @@ if (devcaps.dc_drivercaps & IEEE80211_C_HOSTAP) drv->capa.flags |= WPA_DRIVER_FLAGS_AP; -@@ -1545,6 +1602,8 @@ +@@ -1545,6 +1629,8 @@ } if (ifmr.ifm_current & IFM_IEEE80211_HOSTAP) return IEEE80211_M_HOSTAP; @@ -167,3 +260,22 @@ if (ifmr.ifm_current & IFM_IEEE80211_MONITOR) return IEEE80211_M_MONITOR; #ifdef IEEE80211_M_MBSS +@@ -1605,7 +1691,7 @@ + drv->capa.key_mgmt_iftype[i] = drv->capa.key_mgmt; + + /* Down interface during setup. */ +- if (bsd_get_iface_flags(drv) < 0) ++ if (bsd_ctrl_iface(drv, 0) < 0) + goto fail; + + /* Proven to work, lets go! */ +@@ -1628,6 +1714,9 @@ + + if (drv->ifindex != 0 && !drv->if_removed) { + wpa_driver_bsd_set_wpa(drv, 0); ++ ++ /* NB: mark interface down */ ++ bsd_ctrl_iface(drv, 0); + + wpa_driver_bsd_set_wpa_internal(drv, drv->prev_wpa, + drv->prev_privacy);