QubesOS / qubes-issues

The Qubes OS Project issue tracker
https://www.qubes-os.org/doc/issue-tracking/
539 stars 48 forks source link

iwd does not work after waking from suspend #6570

Open qtpies opened 3 years ago

qtpies commented 3 years ago

Qubes OS version 4.0

Affected component(s) or functionality Wifi, when replacing wpa_supplicant with iwd

Brief summary source: "iNet Wireless Daemon (iwd) project aims to provide a comprehensive Wi-Fi connectivity solution for Linux based devices. The core goal of the project is to optimize resource utilization: storage, runtime memory and link-time costs. This is accomplished by not depending on any external libraries and utilizes features provided by the Linux Kernel to the maximum extent possible. The result is a self-contained environment that only depends on the Linux Kernel and the runtime C library. "

Currently, multiple Linux distributions are looking into replacing the wpa_supplicant wifi daemon with iwd, and it seems fair to assume that Qubes at some point will therefore have to work with iwd. On a non-Qubes system iwd is already very mature, fast and stable. However, on a Qubes system, there is an issue that I can't fix: waking up after suspend.

How Reproducible On my hardware, always

To Reproduce

Steps to reproduce the behavior:

  1. Replace wpa_supplicant with iwd < this guide worked for Fedora, for other guides, see below.
  2. Connect to wifi
  3. Suspend
  4. Wake up

Expected behavior iwd should still see the hardware. Networkmanager should still see iwd. Wifi should automatically reconnect.

Actual behavior Sometimes, iwd itself still works (check with iwctl), but NetworkManager doesn't 'see' iwd anymore. Sometimes, iwd doesn't 'see' the wifi hardware anymore (check with iwctl)

Sometimes, a restart of the iwd daemon fixes things, at other times all that remains is a full restart of sys-net (the appvm where all this happens).

Solutions you've tried I have tried iwd under sys-net with Fedora, Debian stable and unstable, to rule out OS issues and to use versions of iwd and networkmanager where possibly related bugs have been fixed.

I think this is a Qubes issue: maybe iwd does not work well with Xen or virtual machines in general? But of course it might be related to bugs in either networkmanager or iwd, or to my particular hardware (Lenovo T470 with default intel WiFi).

Suggestions for where to go from here are welcome, and I am also curious about other peoples experiences with Qubes and iwd.

Relevant documentation you've consulted https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/101 debian guide more elaborate arch guide

Related, non-duplicate issues https://github.com/QubesOS/qubes-issues/issues/6510

DemiMarie commented 3 years ago

Recent Intel and AMD processors (anything supporting Microsoft’s Modern Standby) are not compatible with Qubes OS suspend.

marmarek commented 3 years ago

Recent Intel and AMD processors (anything supporting Microsoft’s Modern Standby) are not compatible with Qubes OS suspend.

Based on the description above, the system woke up from the suspend. So, that's a different issue.

DemiMarie commented 3 years ago

Recent Intel and AMD processors (anything supporting Microsoft’s Modern Standby) are not compatible with Qubes OS suspend.

Based on the description above, the system woke up from the suspend. So, that's a different issue.

Good point, sorry. I tried to get iwd to work in sys-net with no success. @qtpies how did you get iwd to work at all?

qtpies commented 3 years ago

Recent Intel and AMD processors (anything supporting Microsoft’s Modern Standby) are not compatible with Qubes OS suspend.

Based on the description above, the system woke up from the suspend. So, that's a different issue.

Good point, sorry. I tried to get iwd to work in sys-net with no success. @qtpies how did you get iwd to work at all?

@DemiMarie I found the original guide I used. This is written for Ubuntu, but it worked for Fedora.

Additionally (my memory might fail me here) I did:

qtpies commented 3 years ago

With regard to the 'iwd doesn't see hardware': it just happened again, and I checked. In lspci the wireless device is visible. In iwctl (the controller of iwd) is is not. In iw list it is also not visible. After a reboot of sys-net, the device is visible again in iw list and iwctl.

iw is a lower-level tool than iwd. How can removing wpa_supplicant and/or installing iwd cause this issue? How can I debug further?

balrog-kun commented 3 years ago

There's some interface creation/removal dance that IWD does on start. Since it triggers code paths in drivers that are not used by wpa_supplicant, it sometimes triggers bugs. You can add the following to your /etc/iwd/main.conf to disable that and see if it changes anything...

[General]
UseDefaultInterface=true
qtpies commented 3 years ago

There's some interface creation/removal dance that IWD does on start. Since it triggers code paths in drivers that are not used by wpa_supplicant, it sometimes triggers bugs. You can add the following to your /etc/iwd/main.conf to disable that and see if it changes anything...

[General]
UseDefaultInterface=true

Thanks¸I tried it, after a susped/wakeup I still have to systemctl restart iwd though. That is better than a reboot, but I could be only incidental. What is really needed is more people trying iwd, to rule out issues with my particular hardware or configuration.

qtpies commented 3 years ago

This issue is still current with an up to date debian 11 sys-net. For others encountering this, the workaround I use after suspend is as follows:

[user@dom0 ~]$ timeout 5 qvm-run sys-net "systemctl restart iwd; systemctl restart NetworkManager.service; pkill nm-applet; nm-applet";

You should now see wifi networks again in NetworkManager. I'm doing this from dom0 since I have to do it often, and this is the most efficient way.

zenmrod commented 1 year ago

I got sys-net working with iwd including waking from suspend.

Template

fedora-37-minimal

Packages

pciutils less gnome-keyring qubes-core-agent-networking qubes-core-agent-network-manager NatworkManager-wifi network-manager-applet notification-daemon polkit iwd

Configuration files

  1. Configure iwd to don't rename devices. Optionally activate MAC address randomization (deterministic based on SSID) with /etc/iwd/main.conf. Content:
    
    UseDefaultInterface=true
    AddressRandomization=network

[Network] EnableIPv6=true


2. Configure NetworkManager to use iwd and let it handle auto-connection with `/etc/NetworkManager/conf.d/iwd.conf`. Content:

[device] wifi.backend=iwd wifi.iwd.autoconnect=yes


#### Hardware configuration (this is specific of your wifi card if any. In my case Atheros)
Reload kernel modules with `/rs/config/suspend-module-blacklist`. Content:

ath9k ath9k_hw ath



That's all you need. Don't touch anything in systemd.
andrewdavidwong commented 1 year ago

Is this still a problem in 4.1?

zenmrod commented 1 year ago

Yes @andrewdavidwong , I use 4.1 and I had to do the changes above to have a fully working sys-net with iwd including wake up from suspension.