Skip to content

feat(linux-host): keep Wi-Fi from power saving under systemd-networkd - #174

Merged
Mearman merged 1 commit into
mainfrom
feat/wifi-powersave-networkd
Nov 2, 2026
Merged

Mearman merged 1 commit into
mainfrom
feat/wifi-powersave-networkd

Conversation

@Mearman

@Mearman Mearman commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

github_runner_linux_host_wifi_powersave_off: true failed on any host without NetworkManager, because it read the Wi-Fi devices with nmcli. It now reads the stack from the host: NetworkManager when nmcli lists a Wi-Fi device that is not unmanaged (unchanged path), else systemd-networkd when it is running and the kernel has a Wi-Fi network device (a phy80211 link under /sys/class/net). A host where neither manages one still fails, and a host with no Wi-Fi device and an answering stack is still left alone.

systemd 259's systemd.network and systemd.link have no power save setting (the only wireless options are matching ones), nor does netplan, so there is nothing to configure in networkd. The role installs iw with apt and writes a udev rule plus a oneshot unit template: the rule adds SYSTEMD_WANTS=github-runner-wifi-powersave@$name.service for each DEVTYPE=wlan interface, and the unit runs iw dev %i set power_save off, bound to and ordered after sys-subsystem-net-devices-%i.device (the pattern wpa_supplicant@.service uses). Using $name keeps it right after a .link rename, and the rule covers a Wi-Fi adapter plugged in later. brcmfmac stores the preference in its own state and applies it whenever it brings the firmware up, so it holds across reconnects. The radio is also switched off now, and on this path an iw that cannot read an interface fails the run.

The NetworkManager tasks moved into wifi_powersave_networkmanager.yml and behave as before on a host where it manages a Wi-Fi device; the radio read and set is shared in wifi_powersave_radio.yml. The one difference there is that a Wi-Fi device nmcli lists as unmanaged no longer counts as NetworkManager's.

Tested against the usual stand-ins in tests/unit/test_linux_host.py (a networkd host with a wifi0 interface, idempotence, --check, iw already installed, a non-apt host, an unreadable radio, NM with an unmanaged device, neither stack). Not run against a real host. Breaking the rule's DEVTYPE match makes the networkd test fail.

The Wi-Fi power save step only knew NetworkManager and failed on a host
without it. The stack is now read from the host: NetworkManager when it
lists a Wi-Fi device it manages, else systemd-networkd when it is running
and the kernel has a Wi-Fi network device.

Neither systemd.network, systemd.link nor netplan has a power save
setting, so a udev rule has systemd start a oneshot unit that runs
`iw dev <interface> set power_save off` when each Wi-Fi interface
appears, ordered after the interface's device unit. iw is installed with
apt and the radio is also switched off now. A host where neither stack
manages a Wi-Fi device still fails.
@Mearman
Mearman marked this pull request as ready for review November 2, 2026 23:51
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ⚠️ Failed 2026-11-02T23:51:08.889113Z
We couldn’t complete this review. Comment @codex security review to try again.
3406244 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

This security review couldn’t start because the paying account has exhausted its Codex allowance and has insufficient available credits. The payer can check their balance and add credits in the Codex usage dashboard, then try again. If you do not manage the paying account, contact this repository's admins.

@Mearman
Mearman merged commit 5355db6 into main Nov 2, 2026
14 checks passed
@Mearman
Mearman deleted the feat/wifi-powersave-networkd branch November 2, 2026 23:51
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 2.20.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant