wifi: ensure wake-on-wlan restore only acts once

- in wake_on_wlan_restore(), if we decide that there is something
  to restore, also clear priv->wowlan_restore by setting it to
  IGNORE. That way, we are sure to only try resetting the value
  once after setting it.

- from nm_platform_wifi_get_wake_on_wlan(), return IGNORE if
  the value cannot be read. If we could not read the value
  we should not restore NONE, but don't restore.
This commit is contained in:
Thomas Haller 2018-06-22 14:03:47 +02:00
parent c6e40215ef
commit a3289400d3
3 changed files with 23 additions and 18 deletions

View file

@ -121,6 +121,7 @@ typedef struct {
gint32 hw_addr_scan_expire;
guint wps_timeout_id;
NMSettingWirelessWakeOnWLan wowlan_restore;
} NMDeviceWifiPrivate;
@ -513,13 +514,16 @@ static gboolean
wake_on_wlan_restore (NMDeviceWifi *self)
{
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
NMSettingWirelessWakeOnWLan w;
if (priv->wowlan_restore == NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE)
w = priv->wowlan_restore;
if (w == NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE)
return TRUE;
priv->wowlan_restore = NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE;
return nm_platform_wifi_set_wake_on_wlan (NM_PLATFORM_GET,
nm_device_get_ifindex (NM_DEVICE (self)),
priv->wowlan_restore);
w);
}
static void
@ -2479,16 +2483,15 @@ wake_on_wlan_enable (NMDeviceWifi *self)
goto found;
}
wowl = NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE;
found:
if (wowl == NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE) {
priv->wowlan_restore = wowl;
return TRUE;
}
/* Save current wowlan value to restore it when dropping the connection */
priv->wowlan_restore =
nm_platform_wifi_get_wake_on_wlan (NM_PLATFORM_GET,
nm_device_get_ifindex (NM_DEVICE (self)));
priv->wowlan_restore = nm_platform_wifi_get_wake_on_wlan (NM_PLATFORM_GET,
nm_device_get_ifindex (NM_DEVICE (self)));
return nm_platform_wifi_set_wake_on_wlan (NM_PLATFORM_GET,
nm_device_get_ifindex (NM_DEVICE (self)),

View file

@ -274,7 +274,7 @@ nla_put_failure:
static int
nl80211_get_wake_on_wlan_handler (struct nl_msg *msg, void *arg)
{
NMSettingWirelessWakeOnWLan* wowl = arg;
NMSettingWirelessWakeOnWLan *wowl = arg;
struct nlattr *attrs[NL80211_ATTR_MAX + 1];
struct nlattr *trig[NUM_NL80211_WOWLAN_TRIG];
struct genlmsghdr *gnlh = nlmsg_data (nlmsg_hdr (msg));
@ -290,22 +290,23 @@ nl80211_get_wake_on_wlan_handler (struct nl_msg *msg, void *arg)
nla_len (attrs[NL80211_ATTR_WOWLAN_TRIGGERS]),
NULL);
*wowl = NM_SETTING_WIRELESS_WAKE_ON_WLAN_NONE;
if (trig[NL80211_WOWLAN_TRIG_ANY])
*wowl = NM_FLAGS_SET (*wowl, NM_SETTING_WIRELESS_WAKE_ON_WLAN_ANY);
*wowl |= NM_SETTING_WIRELESS_WAKE_ON_WLAN_ANY;
if (trig[NL80211_WOWLAN_TRIG_DISCONNECT])
*wowl = NM_FLAGS_SET (*wowl, NM_SETTING_WIRELESS_WAKE_ON_WLAN_DISCONNECT);
*wowl |= NM_SETTING_WIRELESS_WAKE_ON_WLAN_DISCONNECT;
if (trig[NL80211_WOWLAN_TRIG_MAGIC_PKT])
*wowl = NM_FLAGS_SET (*wowl, NM_SETTING_WIRELESS_WAKE_ON_WLAN_MAGIC);
*wowl |= NM_SETTING_WIRELESS_WAKE_ON_WLAN_MAGIC;
if (trig[NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE])
*wowl = NM_FLAGS_SET (*wowl, NM_SETTING_WIRELESS_WAKE_ON_WLAN_GTK_REKEY_FAILURE);
*wowl |= NM_SETTING_WIRELESS_WAKE_ON_WLAN_GTK_REKEY_FAILURE;
if (trig[NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST])
*wowl = NM_FLAGS_SET (*wowl, NM_SETTING_WIRELESS_WAKE_ON_WLAN_EAP_IDENTITY_REQUEST);
*wowl |= NM_SETTING_WIRELESS_WAKE_ON_WLAN_EAP_IDENTITY_REQUEST;
if (trig[NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE])
*wowl = NM_FLAGS_SET (*wowl, NM_SETTING_WIRELESS_WAKE_ON_WLAN_4WAY_HANDSHAKE);
*wowl |= NM_SETTING_WIRELESS_WAKE_ON_WLAN_4WAY_HANDSHAKE;
if (trig[NL80211_WOWLAN_TRIG_RFKILL_RELEASE])
*wowl = NM_FLAGS_SET (*wowl, NM_SETTING_WIRELESS_WAKE_ON_WLAN_RFKILL_RELEASE);
*wowl |= NM_SETTING_WIRELESS_WAKE_ON_WLAN_RFKILL_RELEASE;
if (trig[NL80211_WOWLAN_TRIG_TCP_CONNECTION])
*wowl = NM_FLAGS_SET (*wowl, NM_SETTING_WIRELESS_WAKE_ON_WLAN_TCP);
*wowl |= NM_SETTING_WIRELESS_WAKE_ON_WLAN_TCP;
return NL_SKIP;
}
@ -314,7 +315,7 @@ static NMSettingWirelessWakeOnWLan
wifi_nl80211_get_wake_on_wlan (WifiData *data)
{
WifiDataNl80211 *nl80211 = (WifiDataNl80211 *) data;
NMSettingWirelessWakeOnWLan wowl = NM_SETTING_WIRELESS_WAKE_ON_WLAN_NONE;
NMSettingWirelessWakeOnWLan wowl = NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE;
nm_auto_nlmsg struct nl_msg *msg = NULL;
msg = nl80211_alloc_msg (nl80211, NL80211_CMD_GET_WOWLAN, 0);

View file

@ -117,8 +117,9 @@ wifi_utils_get_wake_on_wlan (WifiData *data)
{
g_return_val_if_fail (data != NULL, FALSE);
return data->klass->get_wake_on_wlan ?
data->klass->get_wake_on_wlan (data) : NM_SETTING_WIRELESS_WAKE_ON_WLAN_NONE;
return data->klass->get_wake_on_wlan
? data->klass->get_wake_on_wlan (data)
: NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE;
}
gboolean