wifi: remove supplicant-forgotten current AP from list on disconnect

NM never removes the current AP from the AP list, to prevent NM from
indicating that it's connected, but to nothing.  But the supplicant
can remove that AP from its list at any time (out of range, turned off,
etc), leading to a priv->current_ap that is no longer known to the
supplicant but still exists in the NM AP list.  Since the supplicant
has forgotten it, NM will never receive a removal signal for it.

To ensure that a supplicant-forgotten priv->current_ap is removed
from the NM AP list when priv->current_ap is cleared or changed, mark
any AP removed by the supplicant as 'fake'.  It will then always be
removed in set_current_ap() and not linger in the AP list forever like
a zombie.
This commit is contained in:
Dan Williams 2015-04-20 10:18:32 -05:00
parent 910c62d8c7
commit e482f853f6
2 changed files with 17 additions and 5 deletions

View file

@ -1600,11 +1600,20 @@ supplicant_iface_bss_removed_cb (NMSupplicantInterface *iface,
priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
ap = get_ap_by_supplicant_path (self, object_path);
if (ap && ap != priv->current_ap) {
nm_ap_dump (ap, "removed ", nm_device_get_iface (NM_DEVICE (self)));
emit_ap_added_removed (self, ACCESS_POINT_REMOVED, ap, TRUE);
g_hash_table_remove (priv->aps, nm_ap_get_dbus_path (ap));
schedule_ap_list_dump (self);
if (ap) {
if (ap == priv->current_ap) {
/* The current AP cannot be removed (to prevent NM indicating that
* it is connected, but to nothing), but it must be removed later
* when the current AP is changed or cleared. Set 'fake' to
* indicate that this AP is now unknown to the supplicant.
*/
nm_ap_set_fake (ap, TRUE);
} else {
nm_ap_dump (ap, "removed ", nm_device_get_iface (NM_DEVICE (self)));
emit_ap_added_removed (self, ACCESS_POINT_REMOVED, ap, TRUE);
g_hash_table_remove (priv->aps, nm_ap_get_dbus_path (ap));
schedule_ap_list_dump (self);
}
}
}

View file

@ -388,6 +388,7 @@ nm_ap_update_from_properties (NMAccessPoint *ap,
const char *supplicant_path,
GVariant *properties)
{
NMAccessPointPrivate *priv;
char *addr;
const guint8 *bytes;
GVariant *v;
@ -399,6 +400,7 @@ nm_ap_update_from_properties (NMAccessPoint *ap,
g_return_if_fail (ap != NULL);
g_return_if_fail (properties != NULL);
priv = NM_AP_GET_PRIVATE (ap);
g_object_freeze_notify (G_OBJECT (ap));
@ -475,6 +477,7 @@ nm_ap_update_from_properties (NMAccessPoint *ap,
nm_ap_set_supplicant_path (ap, supplicant_path);
nm_ap_set_last_seen (ap, nm_utils_get_monotonic_timestamp_s ());
priv->fake = FALSE;
g_object_thaw_notify (G_OBJECT (ap));
}