From patchwork Thu Sep 3 20:33:00 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junyu Lai X-Patchwork-Id: 2300072 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=dPrS900R; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20251104 header.b=lvOxuKN2; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) 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=patchwork.ozlabs.org) 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 (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hf1Xn25sRz1y1Q for ; Tue, 08 Sep 2026 08:12:57 +1000 (AEST) 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:To:Subject:Message-ID:Date:From: MIME-Version:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=r12wNPkRBbaqJ8Zg5KQ8yNTaQea7CDlsMFWzOrZUsiE=; b=dPr S900RUWl1vvVj6wlkLlaDFjnL/gTzczxfNYgZg5EuP5S77zcWDNLqfQHEMw57BhnEXKDfPZualaYt WxgPc4OxJ673heS6GbyYuT8xElhcmiaHOAuY0ry4hhnbtFd8WvVRk+ENBecjqEoXwq/uGHhGvf4kj RaD1H1WtI7Y5T+8meVKk5Ml0cQqyeJiEfaKnlQzI8tBwbOQVAX4Oxow5jtHoSP+siyNVBL4yE3l2r n7rxNc+dV40ApDOu3q1IfzAmqgEd2yKzqao7PDImS4v9m0+rURp3Irg8L35i3VuWI676COWS+ENPv T8Es4/A061iXKlz51bZaqpfW4yucnKw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1x3hOy-00000007naF-0Hhn; Mon, 07 Sep 2026 22:01:20 +0000 Received: from mail-pj2-x10.google.com ([2607:f8b0:4864:39::10]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1x2NU0-000000018ou-2HC8 for hostap@lists.infradead.org; Fri, 04 Sep 2026 06:33:05 +0000 Received: by mail-pj2-x10.google.com with SMTP id d9443c01a7336-2d6ff390a6cso40405ad.1 for ; Thu, 03 Sep 2026 23:33:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1788503583; cv=none; d=google.com; s=arc-20260327; b=Rwp9urOW6pBEbAsXZnKzgrF12xgUq8f1t6gd7Xu9xrbBDhnv5OKwBqSUzX7jQ1dlS6 BSjnjQ16LRA9k2jtN37imYk5IIqGg1INlxWRAUGHlym+ShV45KE9v9hzbD7NZOBKKN2j NGO22l3tkaaMFLXqh+xQgY2xz5lqOoSvCtO38J8FWe7gZg9ttvzV+HPRSio9AR+cshVB t8ijDahgR89SAL+IYD5+PQ1TAHAXQ73C7bEc9b/bJ/wtuJll/C7fE2cC6duMwBbhjS3J XxA2+eyWgnMyDvbI5ucxw398ca8/etQBPxgKgEMScFlEEU0ec3BBxsW1QlXWHSjggsIP DQpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=to:subject:message-id:date:from:mime-version:dkim-signature; bh=l2tBleK9UMOt0ySWneSCiY3yBks4s85PFLqNaY8TrtI=; fh=RepBDIVbUTRsjfbrO/5AjcaOU1JdnBduCNdRP0Vpu7Q=; b=Hg+xAIx82mdHlJ//TJGl/XJw+Cd84+DuHTrEZfa9aysJAo5nZYdGvyQht9l6Wi8ont YdiAurROpUTzDRwr1rgAy2J+6d8CWofhT3QXl6qcyVml10Y1IJSFwxctRtfEWPJDeQgt 0dmntnhpx6+tFTBtD+2Oc2m+s7+iIEuuzRnvVOxsMWzTHQTQyHNREbEAN3e+16G0KbCw xrSs3B12ybzBAjH+r2v56JbKJjWcEYo1eQL4QabMpcvpFrnAiE03XBIFPBZjwF5vz7MM 0px63mFOBTUj09rBBdv2srWtZ4H87wC7VyEXYuZGnEn6SCOua9KSH/lbEqoMExZrxxT8 j1OA==; darn=lists.infradead.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1788503583; x=1789108383; darn=lists.infradead.org; h=content-type:to:subject:message-id:date:from:mime-version:from:to :cc:subject:date:message-id:reply-to:content-type; bh=l2tBleK9UMOt0ySWneSCiY3yBks4s85PFLqNaY8TrtI=; b=lvOxuKN2Rs2XEYzFn7jUCHuIJAwzzmicbCFdCRSygi0hwimtxYz1yZU9aqRUAWbvuK DFA5cWKKwF0QNnGuYV2av35YgmJ0bPwpgo13AfKP05ApgYF9AawtUa/sMQFfYmnq1z+O 29uNpkcg7cRLv9+5cpmES/Qxarm837Bay0d+LsdIZsI57gPLDBZfajV/LmUySZGikT2Z tal2/lb+iyIZua0aTSy9bXks0SotBGZSYGS36t2OV5d6En+C8SjsDtOlSH6TdkYBtNUJ YeK/M7RX6HA9iVCqqvSlODf7X6i52f+2fEe+AuhJD6RCCFidhHIZPPkD8TI8YvnJjlyZ I+wQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788503583; x=1789108383; h=content-type:to:subject:message-id:date:from:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=l2tBleK9UMOt0ySWneSCiY3yBks4s85PFLqNaY8TrtI=; b=aEkdCoDBqk7VCeaHbWzP2Vc0+NCaozIKVqlrt0tai38HAgQmVrFPSKqjwALB4KId7h 4VS+nTNec30jETpbkU4bpdsl8gSvkhKJDa19Idp5itAmtC5X0CBECLuSTd6d7QtwweC6 S3nJw/xjQ2a6mPMl5s4iL8KKULrDNSjt8DFtwegUX9CxXfLT+f0Ll2eSBzOsibDkD8uR Vf0etq8j4SJcjVhNDmoTEgoOyDljfUjErsaFyTGzH7UqjIoq8q3cb4bPlWyEoV6t/ETU XLC4Udif++VYlspPmwWD3lYyAitvqbBHckLhmy9FnF8bDKFrAj7uCZU+2xh79p+H4IUS G4dA== X-Gm-Message-State: AFuF++kTdbqH+WUshEzSC0jhng/hVtg5IxLfMssSQLy/qLCK9T4RNT83 PCC+DZp1uRRREUITkEDuu6oFMp9wQGeURXnk9waISA/OrAPMUKC1npDN81ce9eZMCCUCyD2jtiK frbSu8g4Wj9Sn3WzorsU1AdkfnK8bRQBUeprgW1+fyew6s9fbq2y3b4o4 X-Gm-Gg: AYBFou3Yv/JE0Pa7M6/RhAt8YETnOPJ2yb/LA8PzzK14Xq5hZ+tEoRwCrQptEmtgBro Jl57jKKnxLKrTn0Z4GUB0zjrHjMatWN2hr3E8xr7XbvnojKGNT6R1JaQhObc0avXKYG37Cvktn9 BL4b/sRcY1XihMw9dPmmQ8k43SnYrPAAlPTI4VC9MswwC3jr2zh6AMScsWzRSz9oep4S6tpIOiR ybs9db2qPa+VLllloNAH9Zce3mY7XKxj7IzGBlL+X74XRFGrPcX8Dvl0bxWAr3wZnFbww5uaSIn eGShdERFeS0C4NI0UxrssuboDTrnViczF1E6R/1nfkwDW+w35UYrNgD3YA5sqjBBdxsFbl9PSUl igPGrqz9ePLNP7AjLbkXc1wKmati5VDGV4UYqVflNYLUc2qadqNp2tg== X-Received: by 2002:a17:902:c948:b0:2c0:defb:557e with SMTP id d9443c01a7336-2db16b4ff3amr2510585ad.1.1788503581839; Thu, 03 Sep 2026 23:33:01 -0700 (PDT) Received: from 913411032810 named unknown by gmailapi.google.com with HTTPREST; Thu, 3 Sep 2026 23:33:00 -0700 Received: from 913411032810 named unknown by gmailapi.google.com with HTTPREST; Thu, 3 Sep 2026 23:33:00 -0700 MIME-Version: 1.0 From: Junyu Lai Date: Thu, 3 Sep 2026 23:33:00 -0700 X-Gm-Features: AcwNN1UxjOgc95Zd3MTKDSoox7X3riXwarGzejFd4fm2z1CHulDduV0aPTwFzKE Message-ID: Subject: [PATCH] P2P: Cap client bandwidth to GO BSS operating bandwidth at association To: hostap@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260903_233304_630087_B69293D3 X-CRM114-Status: GOOD ( 19.72 ) X-Spam-Score: -17.6 (-----------------) 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: When a P2P client associates with the GO, the GO's wpa_supplicant historically parsed the client's VHT/HE capabilities to determine the link bandwidth, but failed to cap it by the actual operating ban [...] Content analysis details: (-17.6 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -7.5 USER_IN_DEF_DKIM_WL From: address is in the default DKIM welcome-list 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -7.5 USER_IN_DEF_SPF_WL From: address is in the default SPF welcome-list -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.5 ENV_AND_HDR_SPF_MATCH Env and Hdr From used in default SPF WL Match -0.0 DMARC_PASS DMARC pass policy X-Mailman-Approved-At: Mon, 07 Sep 2026 15:01:18 -0700 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 When a P2P client associates with the GO, the GO's wpa_supplicant historically parsed the client's VHT/HE capabilities to determine the link bandwidth, but failed to cap it by the actual operating bandwidth of the GO BSS. This caused wpa_supplicant to report the client's maximum supported bandwidth even if the GO was operating at a lower bandwidth (e.g., 20 MHz). Fix this by: 1. Adding chan_width_to_mhz() in src/common/defs.h to convert enum chan_width to bandwidth in MHz for proper magnitude comparisons, since enum chan_width is not numerically ordered (60 GHz EDMG values were placed before 320 MHz). 2. Adding get_oper_chan_width callback to struct p2p_group_config and implementing wpas_p2p_get_oper_chan_width() to query the GO BSS operating channel width, taking into account HT/VHT/HE/EHT channel widths as well as legacy non-HT mode (CHAN_WIDTH_20_NOHT). 3. Capping the client's bandwidth in p2p_group_notif_assoc() against the GO BSS operating bandwidth using chan_width_to_mhz(). Signed-off-by: Junyu Lai --- src/common/defs.h | 39 ++++++++++++++++++++ src/p2p/p2p.h | 7 ++++ src/p2p/p2p_group.c | 20 ++++++++++- wpa_supplicant/p2p_supplicant.c | 64 +++++++++++++++++++++++++++++++++ 4 files changed, 129 insertions(+), 1 deletion(-) cfg->p2p2 = wpa_s->p2p2; diff --git a/src/common/defs.h b/src/common/defs.h index f28106cc..e98aca0f 100644 --- a/src/common/defs.h +++ b/src/common/defs.h @@ -496,6 +496,45 @@ enum chan_width { CHAN_WIDTH_UNKNOWN }; +/** + * chan_width_to_mhz - Convert enum chan_width to bandwidth in MHz + * @width: Channel width enum value + * Returns: Bandwidth in MHz, or 0 for unknown/non-comparable widths + * + * Note: enum chan_width is NOT numerically ordered by bandwidth (60 GHz EDMG + * values 2160/4320/6480/8640 MHz were inserted before 320 MHz), so direct + * integer comparison of enum values must not be used to compare bandwidths. + * Use this function whenever bandwidth magnitude comparisons are needed. + */ +static inline unsigned int chan_width_to_mhz(enum chan_width width) +{ + switch (width) { + case CHAN_WIDTH_20_NOHT: + case CHAN_WIDTH_20: + return 20; + case CHAN_WIDTH_40: + return 40; + case CHAN_WIDTH_80: + case CHAN_WIDTH_80P80: + return 80; + case CHAN_WIDTH_160: + return 160; + case CHAN_WIDTH_320: + return 320; + case CHAN_WIDTH_2160: + return 2160; + case CHAN_WIDTH_4320: + return 4320; + case CHAN_WIDTH_6480: + return 6480; + case CHAN_WIDTH_8640: + return 8640; + case CHAN_WIDTH_UNKNOWN: + default: + return 0; + } +} + /* VHT/EDMG/etc. channel widths * Note: The first four values are used in hostapd.conf and as such, must * maintain their defined values. Other values are used internally. */ diff --git a/src/p2p/p2p.h b/src/p2p/p2p.h index 83476be0..b711b0a4 100644 --- a/src/p2p/p2p.h +++ b/src/p2p/p2p.h @@ -2113,6 +2113,13 @@ struct p2p_group_config { * @idle: Whether the group is idle (no associated stations) */ void (*idle_update)(void *ctx, int idle); + + /** + * get_oper_chan_width - Query GO BSS operating channel width + * @ctx: Callback context from cb_ctx + * Returns: Operating channel width of the BSS + */ + enum chan_width (*get_oper_chan_width)(void *ctx); }; /** diff --git a/src/p2p/p2p_group.c b/src/p2p/p2p_group.c index 4ba9096a..b6b9def9 100644 --- a/src/p2p/p2p_group.c +++ b/src/p2p/p2p_group.c @@ -653,7 +653,7 @@ int p2p_group_notif_assoc(struct p2p_group *group, struct sta_info *sta, int ht = sta->ht_capabilities ? 1 : 0; int vht = sta->vht_capabilities ? 1 : 0; int he = sta->he_capab ? 1 : 0; - int bw = CHAN_WIDTH_20; + enum chan_width bw = CHAN_WIDTH_20; if (ht && (sta->ht_capabilities->ht_capabilities_info & HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET)) { bw = CHAN_WIDTH_40; @@ -670,6 +670,24 @@ int p2p_group_notif_assoc(struct p2p_group *group, struct sta_info *sta, } #endif + /* + * Cap the client's bandwidth by the GO BSS operating bandwidth. + * This prevents reporting client capability bandwidth when it exceeds + * the actual channel width of the BSS. + * + * Use chan_width_to_mhz() for the comparison rather than comparing enum + * values directly: enum chan_width is not numerically ordered by + * bandwidth (60 GHz EDMG values 2160/4320/6480/8640 MHz were inserted + * before CHAN_WIDTH_320 = 320 MHz), so a raw integer comparison would + * produce incorrect results for those widths. + */ + if (group->cfg && group->cfg->get_oper_chan_width) { + enum chan_width max_bw = + group->cfg->get_oper_chan_width(group->cfg->cb_ctx); + if (chan_width_to_mhz(bw) > chan_width_to_mhz(max_bw)) + bw = max_bw; + } + p2p_add_device(group->p2p, sta->addr, 0, NULL, 0, ie, len, 0); m = os_zalloc(sizeof(*m)); diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index cb4f821b..6e761a3b 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -8636,6 +8636,69 @@ static void wpas_p2p_idle_update(void *ctx, int idle) } +/* + * Query the GO BSS operating channel width. + * Maps hostapd's enum oper_chan_width to supplicant's enum chan_width. + * + * For CONF_OPER_CHWIDTH_USE_HT (802.11n HT mode), the actual channel width + * (HT40 vs HT20) is determined by secondary_channel != 0 rather than + * oper_chan_width itself. When ieee80211n is not set at all (legacy non-HT + * BSS), CHAN_WIDTH_20_NOHT is returned to accurately reflect the absence of + * HT. This distinction matters for the capping comparison in + * p2p_group_notif_assoc(): chan_width_to_mhz(CHAN_WIDTH_20_NOHT) == 20 MHz, + * so the cap still works correctly, and the returned value faithfully + * represents the BSS mode. + */ +static enum chan_width wpas_p2p_get_oper_chan_width(void *ctx) +{ + struct wpa_supplicant *wpa_s = ctx; + enum oper_chan_width oper_width; + + if (!wpa_s || !wpa_s->ap_iface || !wpa_s->ap_iface->bss || + !wpa_s->ap_iface->bss[0]) + return CHAN_WIDTH_20; + + oper_width = hostapd_get_oper_chan_width_of_bss(wpa_s->ap_iface->bss[0]); + + switch (oper_width) { + case CONF_OPER_CHWIDTH_80MHZ: + return CHAN_WIDTH_80; + case CONF_OPER_CHWIDTH_80P80MHZ: + return CHAN_WIDTH_80P80; + case CONF_OPER_CHWIDTH_160MHZ: + return CHAN_WIDTH_160; + case CONF_OPER_CHWIDTH_320MHZ: + return CHAN_WIDTH_320; + case CONF_OPER_CHWIDTH_2160MHZ: + return CHAN_WIDTH_2160; + case CONF_OPER_CHWIDTH_4320MHZ: + return CHAN_WIDTH_4320; + case CONF_OPER_CHWIDTH_6480MHZ: + return CHAN_WIDTH_6480; + case CONF_OPER_CHWIDTH_8640MHZ: + return CHAN_WIDTH_8640; + case CONF_OPER_CHWIDTH_40MHZ_6GHZ: + return CHAN_WIDTH_40; + case CONF_OPER_CHWIDTH_USE_HT: + default: + /* + * For 802.11n HT mode, channel width (HT40 vs HT20) is + * determined by secondary_channel != 0 rather than + * oper_chan_width. When ieee80211n is not set (legacy non-HT + * BSS), return CHAN_WIDTH_20_NOHT to accurately reflect the + * absence of HT. + */ + if (wpa_s->ap_iface->conf && + wpa_s->ap_iface->conf->ieee80211n) { + if (wpa_s->ap_iface->conf->secondary_channel != 0) + return CHAN_WIDTH_40; + return CHAN_WIDTH_20; + } + return CHAN_WIDTH_20_NOHT; + } +} + + struct p2p_group * wpas_p2p_group_init(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid) { @@ -8666,6 +8729,7 @@ struct p2p_group * wpas_p2p_group_init(struct wpa_supplicant *wpa_s, cfg->cb_ctx = wpa_s; cfg->ie_update = wpas_p2p_ie_update; cfg->idle_update = wpas_p2p_idle_update; + cfg->get_oper_chan_width = wpas_p2p_get_oper_chan_width; cfg->ip_addr_alloc = WPA_GET_BE32(wpa_s->p2pdev->conf->ip_addr_start) != 0;