From nobody Fri Aug 29 13:19:02 2025 X-Original-To: dev-commits-src-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 4cCzPL6GvMz65W8J; Fri, 29 Aug 2025 13:19: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 "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cCzPL3rlJz3V8w; Fri, 29 Aug 2025 13:19:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1756473542; 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=H3G14Agl4uOIuBDtU2TArzf02bz1Tmjdh4w0wvyd3Ic=; b=tjZLcMVUdiq3ZvbzNfL0uMS3kx0MLmnnR7fhiPLAA9TB+YRGORcnQCoNbtcTP43MjtjuiS 6ww2e+ncogos2AyBwucMqDUBCS6pfblzTmejOfyKkMFVLlL7iibBzQ5+PrKmJI6kKwDL7v WiAOV+aKwJ/UIYvHFaUZoAmlgb7lkoLZzW3O8qionIYBnXjggNvs4HiGMmb2g3BrtPqwKE 2Rj94Tiwrn5SCCw1Evl3oD0BSC+a3pfGzImQeFbMcMKfS+XpxxjoLhdQ0gOyf6lC6OEFpZ 0xwSi1JpoqFxJBBE9ii3SHIWR3hIs93Qq1WBN98cfRUeb8Vf/RK1X76pc+xKTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1756473542; 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=H3G14Agl4uOIuBDtU2TArzf02bz1Tmjdh4w0wvyd3Ic=; b=l3rLEiU+gXsXVtQpyNH5F8QMknZDRDqEguPsOVL0Anneo2Nn0YHDTMGkyE+1eV83U/tffC K8m9xVyRVUXrt9nta+ny3l3EBjgEkPRHJrQDrCnKdEhpQyauGdMDRMQpGvjaaKDTRc1MZg WTiibOyruqrrzyfKyWjZISztZ8bRdODreEtDI7R1jhHYOf4Cxqj4zABpHtS8+W120jyJrw CHVMSajK1pX5wBddLrb2LXRY+hbkvZ6JdVwDqQz9BX2MzSu9tDaasZ6vOWtftUbr5AfndX yAuKEvapqH1BJ7T2u/dQV5MHAkTO/KvQmkeHLrYAAjKUrsl/kG+bzNHijHPXfg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1756473542; a=rsa-sha256; cv=none; b=DIiFI/U0swHKo1OC2h7EWm33mnL6fChO/a2AZzsQSoGxgeVn9WW7bHWBHU4ZZmBxuhViQb IoZjWRYq179QuXY5J2N/4X5pc7qziJpLvdgOFGEH3PQazFn06HVXk/FmRR+9d0HpSqAM2A 8fIE2ACAOSY4B2z976NNpplZf8GgncMbvDiKcTJzm8v7GwgMSIFJyUC0RXk5O40F5zrQjn O+TcT/WPU6Aq63fQMY2RUyZ13+K1I0mIpqMojrfi0kZU/Jq5j3xbeZt704IfRkZ2Js4H/L NLPnS/X99wTpDklrbXUFPxkZZs4F5X2a9WTM8RLG+Q1nOAMtmkDgKX2Lxngc+Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4cCzPL39Ydzgtl; Fri, 29 Aug 2025 13:19:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 57TDJ2ma072322; Fri, 29 Aug 2025 13:19:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 57TDJ2CX072319; Fri, 29 Aug 2025 13:19:02 GMT (envelope-from git) Date: Fri, 29 Aug 2025 13:19:02 GMT Message-Id: <202508291319.57TDJ2CX072319@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: eb4722614a93 - main - LinuxKPI: 802.11: improve scan/beacon tracing in RX path List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: eb4722614a933c331afe02f6a6870303d7f7bb22 Auto-Submitted: auto-generated The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=eb4722614a933c331afe02f6a6870303d7f7bb22 commit eb4722614a933c331afe02f6a6870303d7f7bb22 Author: Bjoern A. Zeeb AuthorDate: 2025-08-27 07:25:55 +0000 Commit: Bjoern A. Zeeb CommitDate: 2025-08-29 13:18:42 +0000 LinuxKPI: 802.11: improve scan/beacon tracing in RX path In one of my setups I am sometimes seeing "ghost beacons" (beacons from a BSSID on a 2nd channel where it is not sending beacons; also checked with a monitor node to be sure). In order to rule out later processing errors I added debugging early on in the LinuxKPI 802.11 RX path. This will at least help us (users) to debug possible problems more easily by turning on scan debugging (either here, or using wlandebug +scan to get the net80211 view on it, or both). Sponsored by: The FreeBSD Foundation MFC after: 3 days --- sys/compat/linuxkpi/common/src/linux_80211.c | 74 +++++++++++++++++++++++++--- 1 file changed, 67 insertions(+), 7 deletions(-) diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c index 4ac2482e4138..55d84789e05a 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211.c +++ b/sys/compat/linuxkpi/common/src/linux_80211.c @@ -7243,6 +7243,63 @@ lkpi_convert_rx_status(struct ieee80211_hw *hw, struct lkpi_sta *lsta, } } +#ifdef LINUXKPI_DEBUG_80211 +static void +lkpi_rx_log_beacon(struct mbuf *m, struct lkpi_hw *lhw, + struct ieee80211_rx_status *rx_status) +{ + struct ieee80211_mgmt *f; + uint8_t *e; + char ssid[IEEE80211_NWID_LEN * 4 + 1]; + + memset(ssid, '\0', sizeof(ssid)); + + f = mtod(m, struct ieee80211_mgmt *); + e = f->u.beacon.variable; + /* + * Usually SSID is right after the fixed part and for debugging we will + * be fine should we miss it if it is not. + */ + while ((e - (uint8_t *)f) < m->m_len) { + if (*e == IEEE80211_ELEMID_SSID) + break; + e += (2 + *(e + 1)); + } + if (*e == IEEE80211_ELEMID_SSID) { + int i, len; + char *p; + + p = ssid; + len = m->m_len - ((e + 2) - (uint8_t *)f); + if (len > *(e + 1)) + len = *(e + 1); + e += 2; + for (i = 0; i < len; i++) { + /* Printable character? */ + if (*e >= 0x20 && *e < 0x7f) { + *p++ = *e++; + } else { + snprintf(p, 5, "%#04x", *e++); + p += 4; + } + } + *p = '\0'; + } + + /* We print skb, skb->data, m as we are seeing 'ghost beacons'. */ + TRACE_SCAN(lhw->ic, "Beacon: scan_flags %b, band %s freq %u chan %-4d " + "len %d { %#06x %#06x %6D %6D %6D %#06x %ju %u %#06x SSID '%s' }", + lhw->scan_flags, LKPI_LHW_SCAN_BITS, + lkpi_nl80211_band_name(rx_status->band), rx_status->freq, + linuxkpi_ieee80211_frequency_to_channel(rx_status->freq, 0), + m->m_pkthdr.len, f->frame_control, f->duration_id, + f->da, ":", f->sa, ":", f->bssid, ":", f->seq_ctrl, + (uintmax_t)le64_to_cpu(f->u.beacon.timestamp), + le16_to_cpu(f->u.beacon.beacon_int), + le16_to_cpu(f->u.beacon.capab_info), ssid); +} +#endif + /* For %list see comment towards the end of the function. */ void linuxkpi_ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb, @@ -7299,13 +7356,15 @@ linuxkpi_ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb, is_beacon = ieee80211_is_beacon(hdr->frame_control); #ifdef LINUXKPI_DEBUG_80211 - if (is_beacon) - TRACE_SCAN(ic, "Beacon: scan_flags %b, band %s freq %u chan %d", - lhw->scan_flags, LKPI_LHW_SCAN_BITS, - lkpi_nl80211_band_name(rx_status->band), rx_status->freq, - linuxkpi_ieee80211_frequency_to_channel(rx_status->freq, 0)); + /* + * We use the mbuf here as otherwise the variable part might + * be in skb frags. + */ + if (is_beacon && ((linuxkpi_debug_80211 & D80211_SCAN) != 0)) + lkpi_rx_log_beacon(m, lhw, rx_status); - if (is_beacon && (linuxkpi_debug_80211 & D80211_TRACE_RX_BEACONS) == 0) + if (is_beacon && (linuxkpi_debug_80211 & D80211_TRACE_RX_BEACONS) == 0 && + (linuxkpi_debug_80211 & D80211_SCAN) == 0) goto no_trace_beacons; if (linuxkpi_debug_80211 & D80211_TRACE_RX) @@ -7320,7 +7379,8 @@ linuxkpi_ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb, hexdump(mtod(m, const void *), m->m_len, "RX (raw) ", 0); /* Implement a dump_rxcb() !!! */ - if (linuxkpi_debug_80211 & D80211_TRACE_RX) + if ((linuxkpi_debug_80211 & D80211_TRACE_RX) != 0 || + (linuxkpi_debug_80211 & D80211_SCAN) != 0) printf("TRACE-RX: %s: RXCB: %ju %ju %u, %b, %u, %#0x, %#0x, " "%u band %u, %u { %d %d %d %d }, %d, %#x %#x %#x %#x %u %u %u\n", __func__,