From patchwork Wed Mar 29 13:44:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?UmFwaGHDq2wgTcOpbG90dGU=?= X-Patchwork-Id: 1762765 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=A33PhoDl; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=mind.be header.i=@mind.be header.a=rsa-sha256 header.s=google header.b=LsjauYRj; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Pmnrm6qKCz1yYv for ; Thu, 30 Mar 2023 00:46:16 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Klbii7ufyWRBrXId1tOrb0c07gnpI1k19woOfOWQk0Y=; b=A33PhoDlAFCkNh oWg/FZxpiO7b0anJY/RMYYarUT4c7fjnyQq3uMAULBGXqoENPyJXXUhdc8U09kWt2stBcT1fmUo2W nuczH9unepsl/Zx/pIae582g1j8ChFqjofffvx6R5Qo1lff7Hx3dEgeTx/E3yO0jJbK+eMHOmndLA Pa8ECFpg/mBVe6gM4XK4NwwP7m0AbUuK4r+1ge7TkFzScolpJQMmYNtF9+H1Aq8ip2pvovphhI9jr kzW7dJVSvATLBucV+PAzC3qzcrhkW2ny3u0c6Fs84CaRwnPOwFXq8exsqjz5vBUdhQhYxTBcnv8g0 UePrLV9WcesZD76F3xkg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1phW79-000SDj-1Q; Wed, 29 Mar 2023 13:45:23 +0000 Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1phW77-000SBS-1H for hostap@lists.infradead.org; Wed, 29 Mar 2023 13:45:22 +0000 Received: by mail-ed1-x533.google.com with SMTP id w9so63587340edc.3 for ; Wed, 29 Mar 2023 06:45:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mind.be; s=google; t=1680097512; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DM69nBReN9PbMkyQR5ZGYBH02Jau3l0gjn0gIeYQonA=; b=LsjauYRjKYtvdEjtIKgWmw+jELHNHmZkuf4DcjM9+XPT/zSjyknWGjJ3HFFKCeXVBd H+B8Xd0XuAzUrsmZRuaBNB6afrAeAoummS1fVwPbzK2mzQidnRXPmF3+CuB7vf4/N2Lo aCAhVrIpHkIHmX+L0u+7cxy2G//bxFnvExF9394g4DpO7b7KmFPrXOdTW0sNB55qJ7Oc wJ/5qr7HZ2LpbHgImvnesaJ9z5xEIs7pWY4zq9hBcWHeRtqPXHFw/bLfTowBsgkfeyRJ k1NrlaKHfNlR+eqcvxN9GOS8PZmq9OEzANNwn6njc9mg5BTq31UAc8FqHmxID7RItfSQ aMPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680097512; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DM69nBReN9PbMkyQR5ZGYBH02Jau3l0gjn0gIeYQonA=; b=3Vgt2hox2zUyFC3BhZz1ySxpiX7igl+lPSuX3JAcDU5A61ZYDF83MvhFUDk+gN5EaE wvYxGcFoD+swh8Sx55XZDy8NU/KwKz/gtJTdWP+HAhiebThxPeZMshmi627fjV1fDCg/ qtvxPIEO5mBRLv8qRU9izI4huBvmypdwNBo7LJJLc8iV0cQE6mDzdwML9wJnMgJwzWS3 ygZCvEOpc9s663a2k/UDnT/lNIdzHttmpg0aVuxqo5cM1dB2SR7EQsmhIQsvhuDYi6L+ PqKmekr8GrA8ejCcZCBk0r0c0FGP7Z1pp+llOX305Ym6YZpZwYw1tuLtqzqfiekx8H9h f/lw== X-Gm-Message-State: AAQBX9d90lZknnKsZVcjeRZbHc5940v3I7wh5NldQ5M1LSMBIgev7scW b50qHmWAzhFc2KsKAY9VGm5+pvKFl25LnC2edzqPDg== X-Google-Smtp-Source: AKy350YB5cKw1cFnemlbM5a7mU5Lawt/1Wx/67iAK338ME2k64kk3AhABiJ7w20BqKehJ4J2r+RKoA== X-Received: by 2002:a17:906:e99:b0:930:8590:95ef with SMTP id p25-20020a1709060e9900b00930859095efmr2311586ejf.18.1680097512051; Wed, 29 Mar 2023 06:45:12 -0700 (PDT) Received: from localhost.localdomain (ip-188-118-3-185.reverse.destiny.be. [188.118.3.185]) by smtp.gmail.com with ESMTPSA id y94-20020a50bb67000000b004be11e97ca2sm17057389ede.90.2023.03.29.06.45.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Mar 2023 06:45:11 -0700 (PDT) From: =?utf-8?b?UmFwaGHDq2wgTcOpbG90dGU=?= To: hostap@lists.infradead.org Cc: nbd@nbd.name, arnout@mind.be, raphael.melotte@mind.be, Abhilash.Tuse@imgtec.com Subject: [PATCH 3/4] hostapd_reload_config: allow update of mode and frequency Date: Wed, 29 Mar 2023 15:44:54 +0200 Message-Id: <20230329134455.4019868-4-raphael.melotte@mind.be> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230329134455.4019868-1-raphael.melotte@mind.be> References: <20230329134455.4019868-1-raphael.melotte@mind.be> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230329_064521_432735_E657164D X-CRM114-Status: GOOD ( 19.05 ) X-Spam-Score: 0.1 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Felix Fietkau In commit 513dcec6562948e9f2dc3348923833c8d659eaf2, hostapd_reload_config was changed to no longer reload the channel information. However, we really do want to be able to switch channels, change mode [...] Content analysis details: (0.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:533 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Felix Fietkau In commit 513dcec6562948e9f2dc3348923833c8d659eaf2, hostapd_reload_config was changed to no longer reload the channel information. However, we really do want to be able to switch channels, change mode, etc. when changing the configuration. Therefore, revert that commit. Instead, make sure that the changed mode and channel is correctly taken into account. Use hostapd_set_freq to update the internal data structures and the driver. Use hostapd_hw_get_freq to get the frequency from the selected mode and channel. The new frequency may also be in another band. Update the current_mode structure based on the configured hw_mode and prepare rates table after frequency selection. Signed-off-by: Felix Fietkau [cleanup, patch refresh] [Abhilash Tuse: add support for switching bands] Signed-off-by: Abhilash Tuse [Arnout: add commit message, adapt to current mainline] Signed-off-by: Arnout Vandecappelle --- src/ap/hostapd.c | 50 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c index 141c77f4b..cd9d1e6f0 100644 --- a/src/ap/hostapd.c +++ b/src/ap/hostapd.c @@ -142,6 +142,29 @@ static void hostapd_reload_bss(struct hostapd_data *hapd) #endif /* CONFIG_NO_RADIUS */ ssid = &hapd->conf->ssid; + + hostapd_set_freq(hapd, hapd->iconf->hw_mode, hapd->iface->freq, + hapd->iconf->channel, + hapd->iconf->enable_edmg, + hapd->iconf->edmg_channel, + hapd->iconf->ieee80211n, + hapd->iconf->ieee80211ac, + hapd->iconf->ieee80211ax, + hapd->iconf->ieee80211be, + hapd->iconf->secondary_channel, + hostapd_get_oper_chwidth(hapd->iconf), + hostapd_get_oper_centr_freq_seg0_idx(hapd->iconf), + hostapd_get_oper_centr_freq_seg1_idx(hapd->iconf)); + + if (hapd->iface->current_mode) { + if (hostapd_prepare_rates(hapd->iface, hapd->iface->current_mode)) { + wpa_printf(MSG_ERROR, "Failed to prepare rates table."); + hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211, + HOSTAPD_LEVEL_WARNING, + "Failed to prepare rates table."); + } + } + if (!ssid->wpa_psk_set && ssid->wpa_psk && !ssid->wpa_psk->next && ssid->wpa_passphrase_set && ssid->wpa_passphrase) { /* @@ -250,6 +273,7 @@ int hostapd_reload_config(struct hostapd_iface *iface) struct hostapd_data *hapd = iface->bss[0]; struct hostapd_config *newconf, *oldconf; size_t j; + int i; if (iface->config_fname == NULL) { /* Only in-memory config in use - assume it has been updated */ @@ -300,6 +324,17 @@ int hostapd_reload_config(struct hostapd_iface *iface) } iface->conf = newconf; + for (i = 0; i < iface->num_hw_features; i++) { + struct hostapd_hw_modes *mode = &iface->hw_features[i]; + if (mode->mode == iface->conf->hw_mode) { + iface->current_mode = mode; + break; + } + } + + if (iface->conf->channel) + iface->freq = hostapd_hw_get_freq(hapd, iface->conf->channel); + for (j = 0; j < iface->num_bss; j++) { hapd = iface->bss[j]; if (!hapd->conf->config_id || !newconf->bss[j]->config_id || @@ -307,21 +342,6 @@ int hostapd_reload_config(struct hostapd_iface *iface) newconf->bss[j]->config_id) != 0) hostapd_clear_old_bss(hapd); hapd->iconf = newconf; - hapd->iconf->channel = oldconf->channel; - hapd->iconf->acs = oldconf->acs; - hapd->iconf->secondary_channel = oldconf->secondary_channel; - hapd->iconf->ieee80211n = oldconf->ieee80211n; - hapd->iconf->ieee80211ac = oldconf->ieee80211ac; - hapd->iconf->ht_capab = oldconf->ht_capab; - hapd->iconf->vht_capab = oldconf->vht_capab; - hostapd_set_oper_chwidth(hapd->iconf, - hostapd_get_oper_chwidth(oldconf)); - hostapd_set_oper_centr_freq_seg0_idx( - hapd->iconf, - hostapd_get_oper_centr_freq_seg0_idx(oldconf)); - hostapd_set_oper_centr_freq_seg1_idx( - hapd->iconf, - hostapd_get_oper_centr_freq_seg1_idx(oldconf)); hapd->conf = newconf->bss[j]; hostapd_reload_bss(hapd); }