Skip to content

mt7915: set NO_VIRTUAL_MONITOR - #1162

Open
paoloantinori wants to merge 2 commits into
openwrt:masterfrom
paoloantinori:mt7915-no-virtual-monitor
Open

paoloantinori wants to merge 2 commits into
openwrt:masterfrom
paoloantinori:mt7915-no-virtual-monitor

Conversation

@paoloantinori

Copy link
Copy Markdown

mt7915 sets WANT_MONITOR_VIF but not NO_VIRTUAL_MONITOR, unlike mt7996 and ath12k (#1161).

Without the flag, mac80211 routes a born-active monitor's set_channel to the virtual monitor sdata. The virtual monitor never exists alongside a driver-registered monitor vif, so the command returns 0 while the vif never gets a channel binding. That is the mechanism behind the second finding in #1159.

With the flag, a monitor vif created with the nl80211 active flag holds its own channel binding through the standard path. Verified on MT7981 (GL.iNet Beryl AX, OpenWrt 25.12, kernel 6.12) with the mac80211 notification hook described in #1159: the assign callback fires for the born-active monitor, iw shows the channel, and the PHY tunes to the requested frequency.

The change is one line in mt7915/init.c, the same shape as mt7996.

Also submitted to the openwrt mailing list.

mt7915 sets WANT_MONITOR_VIF but not NO_VIRTUAL_MONITOR, unlike
mt7996 and ath12k. Without the flag, mac80211 routes a born-active
monitor's set_channel to the virtual monitor sdata, which never
exists alongside a driver-registered monitor: the command returns 0
while the vif never gets a channel (the symptom in openwrt#1159, the
mechanism in openwrt#1161).

With the flag, a monitor vif created with the nl80211 active flag
holds its own channel binding through the standard path. Verified
on MT7981 (GL.iNet Beryl AX, OpenWrt 25.12, kernel 6.12) with the
mac80211 notification hook from openwrt#1159: the assign callback fires
for the born-active monitor, iw shows the channel, and the PHY tunes.

Signed-off-by: Paolo Antinori <pantinor@redhat.com>
With NO_VIRTUAL_MONITOR the zero-address virtual monitor is never
created, so the is_zero_ether_addr guard left phy->monitor_vif NULL
and the testmode paths dereferenced it unconditionally. Record any
monitor vif instead; the virtual monitor still matches first when it
exists, and user-created monitors are a safe fallback.

Found by adversarial code review of the NO_VIRTUAL_MONITOR PR.

Signed-off-by: Paolo Antinori <pantinor@redhat.com>
@paoloantinori

Copy link
Copy Markdown
Author

The second commit fixes a regression the first commit alone would have introduced. The code review found that with NO_VIRTUAL_MONITOR, the zero-address virtual monitor is never created, so the is_zero_ether_addr guard in mt7915_add_interface leaves phy->monitor_vif NULL. The testmode paths (mt7915_tm_init, mt7915_tm_set) pass phy->monitor_vif into mt7915_mcu_add_bss_info which dereferences it without checking, so mt76-test on a monitor-only phy would hit a NULL dereference.

The companion commit records any monitor vif as phy->monitor_vif instead. The virtual monitor still matches first when it exists (it has a zero address and is added first). A user-created monitor fills the slot otherwise. This keeps the testmode path working regardless of which flag combination the driver uses.

@paoloantinori

Copy link
Copy Markdown
Author

@nbd168 answering your second question here, where it belongs (the first one was answered on the wifi-scripts PR). The motivation is not the wiphy layout: it is the monitor channel-context starvation. Without the flag, ieee80211_set_monitor_channel routes the request to monitor_sdata (the virtual monitor singleton). While a born-active monitor holds the wiphy that sdata never exists, so the call stores monitor_chanreq, returns 0, and the PHY never tunes (the family of #839 and finding 2 of #1159). With the flag, the request operates on the monitor dev sdata: validated live on mt7915 (assign_vif_chanctx fires, iw shows the channel, the PHY tunes, an on-channel capture sees frames). AP plus active monitor on one wiphy hits this regardless of how many wiphys the driver registers. That said, you know the driver's assumptions behind WANT_MONITOR_VIF far better than I do (I already had to add a companion commit because testmode dereferences phy->monitor_vif when the zero-address virtual monitor is never created). Is the flag the right layer here, or would you prefer the mac80211-side shape proposed on #1159? Happy to drop this PR and work on whichever layer you think is correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant