wifi: add SSID_NOT_FOUND reason and use it when we can
When the supplicant starts connecting, or gets disconnected, track whether it ever starts talking to an AP. Then if the connection fails as a result of an initial connection timeout or a link timeout, we can use SSID_NOT_FOUND when we're reasonably sure the AP doesn't exist. Clients can use this to show better error messages. Note that SSID_NOT_FOUND may only be reported when using nl80211 drivers, as WEXT drivers don't provide the status necessary to determine whether the network exists or not.
This commit is contained in:
@@ -495,6 +495,9 @@ typedef enum {
|
|||||||
/* ModemManager not running */
|
/* ModemManager not running */
|
||||||
NM_DEVICE_STATE_REASON_MODEM_MANAGER_UNAVAILABLE = 52,
|
NM_DEVICE_STATE_REASON_MODEM_MANAGER_UNAVAILABLE = 52,
|
||||||
|
|
||||||
|
/* The WiFi network could not be found */
|
||||||
|
NM_DEVICE_STATE_REASON_SSID_NOT_FOUND = 53,
|
||||||
|
|
||||||
/* Unused */
|
/* Unused */
|
||||||
NM_DEVICE_STATE_REASON_LAST = 0xFFFF
|
NM_DEVICE_STATE_REASON_LAST = 0xFFFF
|
||||||
} NMDeviceStateReason;
|
} NMDeviceStateReason;
|
||||||
|
@@ -564,6 +564,11 @@
|
|||||||
ModemManager was not running or quit unexpectedly.
|
ModemManager was not running or quit unexpectedly.
|
||||||
</tp:docstring>
|
</tp:docstring>
|
||||||
</tp:enumvalue>
|
</tp:enumvalue>
|
||||||
|
<tp:enumvalue suffix="SSID_NOT_FOUND" value="53">
|
||||||
|
<tp:docstring>
|
||||||
|
The 802.11 Wi-Fi network could not be found.
|
||||||
|
</tp:docstring>
|
||||||
|
</tp:enumvalue>
|
||||||
</tp:enum>
|
</tp:enum>
|
||||||
|
|
||||||
<tp:struct name="NM_DEVICE_STATE_REASON_STRUCT">
|
<tp:struct name="NM_DEVICE_STATE_REASON_STRUCT">
|
||||||
|
@@ -150,6 +150,7 @@ struct _NMDeviceWifiPrivate {
|
|||||||
|
|
||||||
Supplicant supplicant;
|
Supplicant supplicant;
|
||||||
WifiData * wifi_data;
|
WifiData * wifi_data;
|
||||||
|
gboolean ssid_found;
|
||||||
|
|
||||||
guint32 failed_link_count;
|
guint32 failed_link_count;
|
||||||
guint periodic_source_id;
|
guint periodic_source_id;
|
||||||
@@ -2208,7 +2209,8 @@ link_timeout_cb (gpointer user_data)
|
|||||||
|
|
||||||
nm_device_state_changed (dev,
|
nm_device_state_changed (dev,
|
||||||
NM_DEVICE_STATE_FAILED,
|
NM_DEVICE_STATE_FAILED,
|
||||||
NM_DEVICE_STATE_REASON_SUPPLICANT_TIMEOUT);
|
priv->ssid_found ? NM_DEVICE_STATE_REASON_SUPPLICANT_TIMEOUT :
|
||||||
|
NM_DEVICE_STATE_REASON_SSID_NOT_FOUND);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2302,6 +2304,11 @@ supplicant_iface_state_cb (NMSupplicantInterface *iface,
|
|||||||
devstate = nm_device_get_state (device);
|
devstate = nm_device_get_state (device);
|
||||||
scanning = nm_supplicant_interface_get_scanning (iface);
|
scanning = nm_supplicant_interface_get_scanning (iface);
|
||||||
|
|
||||||
|
/* In these states we know the supplicant is actually talking to something */
|
||||||
|
if ( new_state >= NM_SUPPLICANT_INTERFACE_STATE_ASSOCIATING
|
||||||
|
&& new_state <= NM_SUPPLICANT_INTERFACE_STATE_COMPLETED)
|
||||||
|
priv->ssid_found = TRUE;
|
||||||
|
|
||||||
switch (new_state) {
|
switch (new_state) {
|
||||||
case NM_SUPPLICANT_INTERFACE_STATE_READY:
|
case NM_SUPPLICANT_INTERFACE_STATE_READY:
|
||||||
priv->scan_interval = SCAN_INTERVAL_MIN;
|
priv->scan_interval = SCAN_INTERVAL_MIN;
|
||||||
@@ -2360,8 +2367,10 @@ supplicant_iface_state_cb (NMSupplicantInterface *iface,
|
|||||||
* the scan but will be re-established when the scan is done.
|
* the scan but will be re-established when the scan is done.
|
||||||
*/
|
*/
|
||||||
if (devstate == NM_DEVICE_STATE_ACTIVATED) {
|
if (devstate == NM_DEVICE_STATE_ACTIVATED) {
|
||||||
if (priv->link_timeout_id == 0)
|
if (priv->link_timeout_id == 0) {
|
||||||
priv->link_timeout_id = g_timeout_add_seconds (scanning ? 30 : 15, link_timeout_cb, self);
|
priv->link_timeout_id = g_timeout_add_seconds (scanning ? 30 : 15, link_timeout_cb, self);
|
||||||
|
priv->ssid_found = FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NM_SUPPLICANT_INTERFACE_STATE_DOWN:
|
case NM_SUPPLICANT_INTERFACE_STATE_DOWN:
|
||||||
@@ -2564,6 +2573,7 @@ supplicant_connection_timeout_cb (gpointer user_data)
|
|||||||
{
|
{
|
||||||
NMDevice *dev = NM_DEVICE (user_data);
|
NMDevice *dev = NM_DEVICE (user_data);
|
||||||
NMDeviceWifi *self = NM_DEVICE_WIFI (user_data);
|
NMDeviceWifi *self = NM_DEVICE_WIFI (user_data);
|
||||||
|
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
|
||||||
NMAccessPoint *ap;
|
NMAccessPoint *ap;
|
||||||
NMActRequest *req;
|
NMActRequest *req;
|
||||||
NMConnection *connection;
|
NMConnection *connection;
|
||||||
@@ -2602,7 +2612,7 @@ supplicant_connection_timeout_cb (gpointer user_data)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_encrypted (ap, connection)) {
|
if (priv->ssid_found && is_encrypted (ap, connection)) {
|
||||||
guint64 timestamp = 0;
|
guint64 timestamp = 0;
|
||||||
gboolean new_secrets = TRUE;
|
gboolean new_secrets = TRUE;
|
||||||
|
|
||||||
@@ -2635,7 +2645,8 @@ supplicant_connection_timeout_cb (gpointer user_data)
|
|||||||
"failing activation.",
|
"failing activation.",
|
||||||
nm_device_get_iface (dev));
|
nm_device_get_iface (dev));
|
||||||
nm_device_state_changed (dev, NM_DEVICE_STATE_FAILED,
|
nm_device_state_changed (dev, NM_DEVICE_STATE_FAILED,
|
||||||
NM_DEVICE_STATE_REASON_SUPPLICANT_TIMEOUT);
|
priv->ssid_found ? NM_DEVICE_STATE_REASON_SUPPLICANT_TIMEOUT :
|
||||||
|
NM_DEVICE_STATE_REASON_SSID_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -2990,6 +3001,8 @@ real_act_stage2_config (NMDevice *dev, NMDeviceStateReason *reason)
|
|||||||
iface, nm_connection_get_id (connection));
|
iface, nm_connection_get_id (connection));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
priv->ssid_found = FALSE;
|
||||||
|
|
||||||
config = build_supplicant_config (self, connection, ap);
|
config = build_supplicant_config (self, connection, ap);
|
||||||
if (config == NULL) {
|
if (config == NULL) {
|
||||||
nm_log_err (LOGD_DEVICE | LOGD_WIFI,
|
nm_log_err (LOGD_DEVICE | LOGD_WIFI,
|
||||||
|
@@ -4510,6 +4510,8 @@ reason_to_string (NMDeviceStateReason reason)
|
|||||||
return "br2684-bridge-failed";
|
return "br2684-bridge-failed";
|
||||||
case NM_DEVICE_STATE_REASON_MODEM_MANAGER_UNAVAILABLE:
|
case NM_DEVICE_STATE_REASON_MODEM_MANAGER_UNAVAILABLE:
|
||||||
return "modem-manager-unavailable";
|
return "modem-manager-unavailable";
|
||||||
|
case NM_DEVICE_STATE_REASON_SSID_NOT_FOUND:
|
||||||
|
return "SSID not found";
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user