Repository navigation
network(iwd): follow the Wi-Fi device when iwd recreates it - #3707
Merged
Merged
Conversation
When iwd restarts it recreates wlan0 under a new D-Bus path. Only the Station interface was tracked on InterfacesAdded, so devicePath kept pointing at the dead object: the PropertiesChanged match for the new device was never registered, updateState() read Powered from the old path, and SetWiFiEnabled() failed with "No matching method found". WiFiEnabled stayed false after handleStationRemoved() until DMS was restarted. Handle the Device interface on InterfacesAdded/InterfacesRemoved: move devicePath and its signal match to the new object and take Name and Powered from the signal. Process every interface in an InterfacesRemoved signal instead of stopping at the first match. Refs duxlabs-dev#3495
Member
|
/claude review |
Contributor
Claude reviewNo issues found. |
bbedward
pushed a commit
that referenced
this pull request
Oct 7, 2026
When iwd restarts it recreates wlan0 under a new D-Bus path. Only the Station interface was tracked on InterfacesAdded, so devicePath kept pointing at the dead object: the PropertiesChanged match for the new device was never registered, updateState() read Powered from the old path, and SetWiFiEnabled() failed with "No matching method found". WiFiEnabled stayed false after handleStationRemoved() until DMS was restarted. Handle the Device interface on InterfacesAdded/InterfacesRemoved: move devicePath and its signal match to the new object and take Name and Powered from the signal. Process every interface in an InterfacesRemoved signal instead of stopping at the first match. Refs #3495 (cherry picked from commit ff50b49)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
With the iwd backend (including iwd + systemd-networkd), restarting iwd while DMS keeps running leaves Wi-Fi shown as disabled, and the Wi-Fi switch fails with
failed to set WiFi enabled: No matching method found, until DMS itself is restarted (#3495).iwd recreates
wlan0under a new D-Bus object path when it restarts (new ifindex). The backend only reacted to theStationinterface onInterfacesAdded, so:handleStationAddedupdatedstationPath, butdevicePathkept pointing at the object that no longer exists.PropertiesChangedmatch was registered for the new device path, so laterPoweredchanges were never seen.updateState()readsPoweredfromdevicePath, which failed silently, soWiFiEnabledstayedfalse(it is set tofalsebyhandleStationRemovedwhen the old station disappears).SetWiFiEnabledcalledProperties.Seton the dead object, which is theNo matching method founderror from the report.Change
backend_iwd_signals.go/backend_iwd.go:InterfacesAddednow also handles theDeviceinterface (beforeStation, sincehandleStationAdded→updateStatereadsPoweredfromdevicePath). The newhandleDeviceAddedmovesdevicePathto the new object, moves thePropertiesChangedsignal match over (removing the old one), and takesName/Poweredfrom the signal body.InterfacesRemovednow handlesDevicetoo (handleDeviceRemoved): clearsdevicePathand marks Wi-Fi disabled, soSetWiFiEnabledreturns the clearno WiFi device availableinstead of a raw D-Bus error while iwd is down.InterfacesRemovedloop no longerbreaks after the first matching interface, so a signal listing bothDeviceandStationfor the same object handles both.Name/Poweredparsing inapplyManagedObjectsis moved intoapplyDevicePropsso initial discovery and the new signal path share it. No behaviour change there.setDevice,clearDevice) are separate from the match registration so they can be unit tested.Testing
backend_iwd_test.gocover: following a device recreated at a new path after station/device removal (Wi-Fi enabled again), replacing the path when no removal signal was delivered, same-path and empty-path being no-ops, andclearDeviceignoring unrelated paths andSetWiFiEnabledreturningno WiFi device availableafterwards.go test ./...incorepasses;go test -race ./internal/server/network/passes;gofmtandgo vetare clean.handleDeviceAdded/handleDeviceRemoved, which talk to the bus) is not unit tested and I have not run this against a real iwd restart. It is a small wrapper over the tested functions.Not covered
The report also shows
wlan0being classified as Ethernet by the networkd side. The reporter says that part is unverified and I could not establish a cause from the code, so this PR does not touch it. HenceRefsrather thanFixes; please keep the issue open for that part if it still reproduces after this change.No UI change, so no screenshots.
Refs #3495