From ca3bbede746a7d7031ba6a011c69ad7adb1dca3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alfonso=20S=C3=A1nchez-Beato?= Date: Fri, 25 May 2018 17:46:33 +0200 Subject: [PATCH] core: don't shutdown interfaces if they have wowlan enabled This is to support the S5 case, where usually the NM process is stopped. If we are stopping and WoWLAN is set for the interface, we do not deconfigure it and keep the connection alive so we can receive packages that will potentially wake up the system. Note that for this work, wpa_supplicant needs to be modified too so it does not deconfigure the wireless interface either when stopped. The needed patches for wpa_supplicant can be found in http://lists.infradead.org/pipermail/hostap/2018-June/038644.html --- src/nm-manager.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/nm-manager.c b/src/nm-manager.c index c594f9b745..c6d82c9d40 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -1558,6 +1558,12 @@ again: } } +static gboolean +device_is_wake_on_lan (NMPlatform *platform, NMDevice *device) +{ + return nm_platform_link_get_wake_on_lan (platform, nm_device_get_ip_ifindex (device)); +} + static void remove_device (NMManager *self, NMDevice *device, @@ -1567,14 +1573,19 @@ remove_device (NMManager *self, NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self); gboolean unmanage = FALSE; - _LOG2D (LOGD_DEVICE, device, "removing device (allow_unmanage %d, managed %d)", - allow_unmanage, nm_device_get_managed (device, FALSE)); + _LOG2D (LOGD_DEVICE, device, "removing device (allow_unmanage %d, managed %d, wol %d)", + allow_unmanage, nm_device_get_managed (device, FALSE), + device_is_wake_on_lan (priv->platform, device)); if (allow_unmanage && nm_device_get_managed (device, FALSE)) { - if (quitting) - unmanage = nm_device_unmanage_on_quit (device); - else { + if (quitting) { + /* Leave configured if wo(w)lan and quitting */ + if (device_is_wake_on_lan (priv->platform, device)) + unmanage = FALSE; + else + unmanage = nm_device_unmanage_on_quit (device); + } else { /* the device is already gone. Unmanage it. */ unmanage = TRUE; } @@ -5138,12 +5149,6 @@ done: g_clear_object (&subject); } -static gboolean -device_is_wake_on_lan (NMPlatform *platform, NMDevice *device) -{ - return nm_platform_link_get_wake_on_lan (platform, nm_device_get_ip_ifindex (device)); -} - static gboolean sleep_devices_add (NMManager *self, NMDevice *device, gboolean suspending) {