Repository navigation
network: re-track devices after NetworkManager restarts - #4112
Conversation
When NetworkManager restarts it emits DeviceAdded for every device before it owns org.freedesktop.NetworkManager again (about 180 ms earlier on the machine this was captured on). handleDeviceAdded looks the device up through the well-known name, the call fails with ServiceUnknown, and the device is dropped. Wi-Fi recovers through refreshWiFiDevices, but an ethernet device stays missing until the shell restarts, so the bar shows the Wi-Fi icon while traffic goes over the wire. Watch NameOwnerChanged for org.freedesktop.NetworkManager and, once the name has a new owner, replay handleDeviceAdded for devices that are not tracked. The device constructors become backend fields so a test can reproduce the failed lookup.
|
/claude review |
Claude reviewThe fix works for devices that were never tracked, but devices from the dead NetworkManager instance stay tracked, so wired actions can hit a dead object path.
|
A NetworkManager that dies emits no DeviceRemoved. If the restarted daemon gives an interface a new object path, the device map gets the new entry, but ethernetDevice and cellularDevice keep pointing at the dead path, so wired and cellular actions call a dead object and the old PropertiesChanged match leaks. resyncDevices now diffs the tracked paths against GetDevices(): paths that are gone go through handleDeviceRemoved, which reselects the device and removes the match; new paths go through handleDeviceAdded as before.
|
/claude review |
Claude reviewNo issues found. The earlier finding is fixed: |
port 2.1 (cherry picked from commit 784afec)
After NetworkManager restarts (for example during a system configuration switch, or by running
systemctl restart NetworkManagerdirectly), switching to a wired connection does not update the DMS icon. It only recovers after restarting DMS.I hit this on my own machine and have been running the fix locally since. When I first started using DMS, the maintainers patiently helped me with several issues (#217, #243, #286, #493, #523), so I wanted to contribute this back in case it's useful. Happy to adjust anything.
Fix: once NetworkManager is back online, DMS syncs its devices again.
The code was written with AI assistance. I have read it and verified it by applying it as a patch on my own NixOS.
D-Bus signals captured during
systemctl restart NetworkManager:Tests:
make fmtclean,make testpasses,go mod tidyclean.TestNetworkManagerBackend_EthernetDeviceSurvivesNetworkManagerRestartfails without the fix.make vetfails onmock_NetworkManager.go:2106(MarshalJSON), same on master.Type of change