Skip to content

network(iwd): follow the Wi-Fi device when iwd recreates it - #3707

Merged
bbedward merged 1 commit into
duxlabs-dev:masterfrom
Pedroj-64:fix/iwd-recreated-device
Oct 6, 2026
Merged

bbedward merged 1 commit into
duxlabs-dev:masterfrom
Pedroj-64:fix/iwd-recreated-device

Conversation

@Pedroj-64

Copy link
Copy Markdown
Contributor

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 wlan0 under a new D-Bus object path when it restarts (new ifindex). The backend only reacted to the Station interface on InterfacesAdded, so:

  1. handleStationAdded updated stationPath, but devicePath kept pointing at the object that no longer exists.
  2. No PropertiesChanged match was registered for the new device path, so later Powered changes were never seen.
  3. updateState() reads Powered from devicePath, which failed silently, so WiFiEnabled stayed false (it is set to false by handleStationRemoved when the old station disappears).
  4. SetWiFiEnabled called Properties.Set on the dead object, which is the No matching method found error from the report.

Change

backend_iwd_signals.go / backend_iwd.go:

  • InterfacesAdded now also handles the Device interface (before Station, since handleStationAdded → updateState reads Powered from devicePath). The new handleDeviceAdded moves devicePath to the new object, moves the PropertiesChanged signal match over (removing the old one), and takes Name/Powered from the signal body.
  • InterfacesRemoved now handles Device too (handleDeviceRemoved): clears devicePath and marks Wi-Fi disabled, so SetWiFiEnabled returns the clear no WiFi device available instead of a raw D-Bus error while iwd is down.
  • The InterfacesRemoved loop no longer breaks after the first matching interface, so a signal listing both Device and Station for the same object handles both.
  • The Name/Powered parsing in applyManagedObjects is moved into applyDeviceProps so initial discovery and the new signal path share it. No behaviour change there.
  • The D-Bus-free parts (setDevice, clearDevice) are separate from the match registration so they can be unit tested.

Testing

  • New tests in backend_iwd_test.go cover: 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, and clearDevice ignoring unrelated paths and SetWiFiEnabled returning no WiFi device available afterwards.
  • go test ./... in core passes; go test -race ./internal/server/network/ passes; gofmt and go vet are clean.
  • The signal handler glue (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 wlan0 being 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. Hence Refs rather than Fixes; please keep the issue open for that part if it still reproduces after this change.

No UI change, so no screenshots.

Refs #3495

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
@bbedward

bbedward commented Oct 6, 2026

Copy link
Copy Markdown
Member

/claude review

@claude

claude Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Claude review

No issues found.
Checked: Device/Station ordering in InterfacesAdded, device match add/remove against the identical station match on the shared object path, clearDevice/setDevice with same and new paths, InterfacesRemoved loop without break, updateState/SetWiFiEnabled behaviour with an empty devicePath, and the new tests. Model: claude-opus-5-5.

@bbedward
bbedward merged commit ff50b49 into duxlabs-dev:master Oct 6, 2026
3 checks passed
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)
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.

2 participants