Linux Wireless之WiFi Beacon Hint 流程分析
Linux Wireless之WiFi Beacon Hint 流程分析 | DDNotesLinux Wireless之WiFi Beacon Hint 流程分析背景及概述最近遇到了个问题机器在使用无线的时候wpa_supplicant 报了如下日志 Jun 4 15:25:29 3-5-pc wpa_supplicant[26279]: nl80211: Event message available Jun 4 15:25:29 3-5-pc wpa_supplicanthttps://notes.z-dd.online/2026/06/10/Linux%20Wireless%E4%B9%8BWiFi%20Beacon%20Hint%20%E6%B5%81%E7%A8%8B%E5%88%86%E6%9E%90/Linux Wireless之WiFi Beacon Hint 流程分析背景及概述最近遇到了个问题机器在使用无线的时候wpa_supplicant 报了如下日志LOGJun 4 15:25:29 3-5-pc wpa_supplicant[26279]: nl80211: Event message availableJun 4 15:25:29 3-5-pc wpa_supplicant[26279]: nl80211: Drv Event 42 (NL80211_CMD_REG_BEACON_HINT) received for wlo4Jun 4 15:25:29 3-5-pc wpa_supplicant[26279]: nl80211: Regulatory beacon hintJun 4 15:25:29 3-5-pc wpa_supplicant[26279]: nl80211: Channel (before): freq5180 max_tx_power2000 no-IRJun 4 15:25:29 3-5-pc wpa_supplicant[26279]: nl80211: Channel (after): freq5180 max_tx_power2000Jun 4 15:25:29 3-5-pc wpa_supplicant[26279]: wlo4: Event CHANNEL_LIST_CHANGED (27) receivedJun 4 15:25:29 3-5-pc wpa_supplicant[26279]: wlo4: CTRL-EVENT-REGDOM-CHANGE initBEACON_HINT typeUNKNOWNJun 4 15:25:29 3-5-pc wpa_supplicant[26279]: wlo4: Updating hw modeJun 4 15:25:29 3-5-pc wpa_supplicant[26279]: nl80211: Regulatory information - country00Jun 4 15:25:29 3-5-pc wpa_supplicant[26279]: nl80211: 2402-2472 40 MHz 20 mBmJun 4 15:25:29 3-5-pc wpa_supplicant[26279]: nl80211: 2457-2482 20 MHz 20 mBm (no IR)Jun 4 15:25:29 3-5-pc wpa_supplicant[26279]: nl80211: 2474-2494 20 MHz 20 mBm (no OFDM) (no IR)Jun 4 15:25:29 3-5-pc wpa_supplicant[26279]: nl80211: 5170-5250 80 MHz 20 mBm (no IR)Jun 4 15:25:29 3-5-pc wpa_supplicant[26279]: nl80211: 5250-5330 80 MHz 20 mBm (DFS) (no IR)Jun 4 15:25:29 3-5-pc wpa_supplicant[26279]: nl80211: 5490-5730 160 MHz 20 mBm (DFS) (no IR)Jun 4 15:25:29 3-5-pc wpa_supplicant[26279]: nl80211: 5735-5835 80 MHz 20 mBm (no IR)Jun 4 15:25:29 3-5-pc wpa_supplicant[26279]: nl80211: 57240-63720 2160 MHz 0 mBmJun 4 15:25:29 3-5-pc wpa_supplicant[26279]: nl80211: Added 802.11b mode based on 802.11g informationJun 4 15:25:29 3-5-pc wpa_supplicant[26279]: nl80211: Mode IEEE 802.11g: 2412 2417 2422 2427 2432 2437 2442 2447 2452 2457 2462 2467[NO_IR] 2472[NO_IR] 2484[NO_IR]Jun 4 15:25:29 3-5-pc wpa_supplicant[26279]: nl80211: Mode IEEE 802.11a: 5180 5200[NO_IR] 5220[NO_IR] 5240[NO_IR] 5260[NO_IR][RADAR] 5280[NO_IR][RADAR] 5300[NO_IR][RADAR] 5320[NO_IR][RADAR] 5500[NO_IR][RADAR] 5520[NO_IR][RADAR] 5540[NO_IR][RADAR] 5560[NO_IR][RADAR]Jun 4 15:25:29 3-5-pc wpa_supplicant[26279]: nl80211: Mode IEEE 802.11b: 2412 2417 2422 2427 2432 2437 2442 2447 2452 2457 2462 2467[NO_IR] 2472[NO_IR] 2484[NO_IR]Jun 4 15:25:29 3-5-pc wpa_supplicant[26279]: wlo4: Determining shared radio frequencies (max len 1)Jun 4 15:25:29 3-5-pc wpa_supplicant[26279]: wlo4: Shared frequencies (len0): completed iterationJun 4 15:25:29 3-5-pc wpa_supplicant[26279]: P2P: Add operating class 81Jun 4 15:25:29 3-5-pc wpa_supplicant[26279]: P2P: Channels - hexdump(len11): 01 02 03 04 05 06 07 08 09 0a 0bJun 4 15:25:29 3-5-pc wpa_supplicant[26279]: P2P: Add operating class 115Jun 4 15:25:29 3-5-pc wpa_supplicant[26279]: P2P: Channels - hexdump(len1): 24Jun 4 15:25:29 3-5-pc wpa_supplicant[26279]: P2P: Add operating class 130Jun 4 15:25:29 3-5-pc wpa_supplicant[26279]: P2P: Channels - hexdump(len1): 24Jun 4 15:25:29 3-5-pc wpa_supplicant[26279]: P2P: Update channel listJun 4 15:25:29 3-5-pc wpa_supplicant[26279]: P2P: channels: 81:1,2,3,4,5,6,7,8,9,10,11 115:36 130:36Jun 4 15:25:29 3-5-pc wpa_supplicant[26279]: P2P: cli_channels:Jun 4 15:25:29 3-5-pc wpa_supplicant[26279]: wlo4: Already scanning - Reschedule the incoming scan reqJun 4 15:25:29 3-5-pc wpa_supplicant[26279]: wlo4: Setting scan request: 1.000000 sec触发了 Beacon Hint 机制今天就来看看 Beacon Hint 机制及其流程。Beacon Hint 是 Linux 内核无线子系统 (cfg80211) 的一种机制用于在 World Roaming 模式下通过扫描发现 AP 的 Beacon 帧自动解锁受限信道 (如 2.4GHz ch12-13 或 5GHz 非 DFS 信道)。它其实属于无线监管域( Regulatory Domain )处理的一部分在前面分析监管域处理流程的时候也有提到https://mp.weixin.qq.com/s/pycGds6vCYfKgHWmQkliYghttps://notes.z-dd.online/2026/06/08/Linux%20Wireless%E4%B9%8BWIFI%E7%9B%91%E7%AE%A1%E5%9F%9F%E5%A4%84%E7%90%86%E6%B5%81%E7%A8%8B/Beacon Hint 完整流程CODE┌─────────────────────────────────────────────────────────────────────────────┐│ Beacon Hint 完整流程 │└─────────────────────────────────────────────────────────────────────────────┘[扫描阶段]│├─ WiFi 驱动执行扫描│├─ 发现 BSS (Beacon 帧)│ ││ └─ 调用 regulatory_hint_found_beacon()│ ││ ├─ 过滤: 已发现/雷达/2.4G ch1-11│ ││ └─ 加入 reg_pending_beacons 列表│└─ 调度 reg_work 工作队列[处理阶段]│├─ reg_todo() 工作函数│ ││ └─ reg_process_pending_beacon_hints()│ ││ └─ 遍历所有 wiphy│ ││ └─ handle_reg_beacon()│ ││ ├─ 检查 World Roaming│ ││ ├─ 移除 NO_IR 标志│ ││ └─ 发送 Netlink 事件│└─ Realtek 驱动处理驱动私有处理│├─ rtw_process_beacon_hint()│ ││ └─ 移除 RTW_CHF_NO_IR│└─ rtw_beacon_hint_ch_change_notifier()│└─ 更新 regulatory 并通知[过期阶段]驱动私有处理│└─ rtw_beacon_hint_expire()│└─ 恢复 NO_IR 标志MERMAIDflowchart TDA[扫描发现 BSS] -- B{是否已发现 beacon?}B --|是| C[跳过]B --|否| D{是雷达信道?}D --|是| CD --|否| E{2.4G ch1-11?}E --|是| CE --|否| F[regulatory_hint_found_beacon]F -- G{已在 pending 列表?}G --|是| CG --|否| H[分配 reg_beacon]H -- I[加入 reg_pending_beacons]I -- J[调度 reg_work 工作队列]J -- K[reg_todo]K -- L[reg_process_pending_beacon_hints]L -- M[遍历所有 wiphy]M -- N[wiphy_update_new_beacon]N -- O[handle_reg_beacon]O -- P{信道匹配?}P --|否| CP --|是| Q{beacon_found?}Q --|是| CQ --|否| R[设置 beacon_found true]R -- S{World Roaming?}S --|否| CS --|是| T{DISABLE_BEACON_HINTS?}T --|是| CT --|否| U{有 NO_IR 标志?}U --|否| CU --|是| V[移除 NO_IR 标志]V -- W[nl80211_send_beacon_hint_event]W -- X[通知用户空间]关键函数说明内核 cfg80211 层函数 文件 说明regulatory_hint_found_beacon() reg.c:3666 入口函数扫描发现 beacon 时调用reg_process_pending_beacon_hints() reg.c:3138 处理待处理的 beacon hintshandle_reg_beacon() reg.c:2187 处理单个 beacon移除 NO_IRwiphy_update_new_beacon() reg.c:2231 更新 wiphy 的 beacon 信息reg_is_world_roaming() reg.c:2164 判断是否 world roaming 模式is_world_regdom() reg.c:369 判断 alpha2 是否为 “00”nl80211_send_beacon_hint_event() nl80211.c:18663 发送 netlink 事件World Roaming 判断条件判断流程作者: Shell链接: https://notes.z-dd.online/2026/06/10/Linux%20Wireless%E4%B9%8BWiFi%20Beacon%20Hint%20%E6%B5%81%E7%A8%8B%E5%88%86%E6%9E%90/来源: DDNotes著作权归作者所有。商业转载请联系作者获得授权非商业转载请注明出处。。。。 。。。更多请关注我的博客https://notes.z-dd.online/或我的