summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2015-04-06 12:58:47 -0500
committerDan Williams <dcbw@redhat.com>2015-04-10 10:17:45 -0500
commit85aac315c042914a333a99b841095318c1a81e7f (patch)
tree56ffe63ab8a862e2330302276a7b7647b8bd5eb0
parentf191e204ace3bb5ebcadd03e275e919561e6680a (diff)
downloadNetworkManager-85aac315c042914a333a99b841095318c1a81e7f.tar.gz
wifi: always strict-match access points when merging
The only reason to allow lazy matching was to update a fake current AP when its real scan result comes in. Now that NM tracks the current AP based on the the supplicant's current BSS, a fake current AP will be replaced when the real scan result arrives. So it's pointless to update the fake one when it'll just be removed soon.
-rw-r--r--src/devices/wifi/nm-device-wifi.c46
-rw-r--r--src/devices/wifi/nm-wifi-ap.c50
-rw-r--r--src/devices/wifi/nm-wifi-ap.h4
3 files changed, 15 insertions, 85 deletions
diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c
index c90f054409..ae3c91bbd7 100644
--- a/src/devices/wifi/nm-device-wifi.c
+++ b/src/devices/wifi/nm-device-wifi.c
@@ -1483,27 +1483,16 @@ try_fill_ssid_for_hidden_ap (NMAccessPoint *ap)
}
}
-/*
- * merge_scanned_ap
- *
- * If there is already an entry that matches the BSSID and ESSID of the
- * AP to merge, replace that entry with the scanned AP. Otherwise, add
- * the scanned AP to the list.
- *
- * TODO: possibly need to differentiate entries based on security too; i.e. if
- * there are two scan results with the same BSSID and SSID but different
- * security options?
- *
- */
static void
merge_scanned_ap (NMDeviceWifi *self,
- NMAccessPoint *merge_ap)
+ NMAccessPoint *merge_ap,
+ const char *supplicant_path,
+ GVariant *properties)
{
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
NMAccessPoint *found_ap = NULL;
const GByteArray *ssid;
const char *bssid;
- gboolean strict_match = TRUE;
/* Let the manager try to fill in the SSID from seen-bssids lists */
bssid = nm_ap_get_address (merge_ap);
@@ -1525,18 +1514,9 @@ merge_scanned_ap (NMDeviceWifi *self,
}
}
- /* If the incoming scan result matches the hidden AP that NM is currently
- * connected to but hasn't been seen in the scan list yet, don't use
- * strict matching. Because the capabilities of the fake AP have to be
- * constructed from the NMConnection of the activation request, they won't
- * always be the same as the capabilities of the real AP from the scan.
- */
- if (priv->current_ap && nm_ap_get_fake (priv->current_ap))
- strict_match = FALSE;
-
- found_ap = get_ap_by_supplicant_path (self, nm_ap_get_supplicant_path (merge_ap));
+ found_ap = get_ap_by_supplicant_path (self, supplicant_path);
if (!found_ap)
- found_ap = nm_ap_match_in_hash (merge_ap, priv->aps, strict_match);
+ found_ap = nm_ap_match_in_hash (merge_ap, priv->aps);
if (found_ap) {
_LOGD (LOGD_WIFI_SCAN, "merging AP '%s' %s (%p) with existing (%p)",
ssid ? nm_utils_escape_ssid (ssid->data, ssid->len) : "(none)",
@@ -1544,19 +1524,7 @@ merge_scanned_ap (NMDeviceWifi *self,
merge_ap,
found_ap);
- nm_ap_set_supplicant_path (found_ap, nm_ap_get_supplicant_path (merge_ap));
- nm_ap_set_flags (found_ap, nm_ap_get_flags (merge_ap));
- nm_ap_set_wpa_flags (found_ap, nm_ap_get_wpa_flags (merge_ap));
- nm_ap_set_rsn_flags (found_ap, nm_ap_get_rsn_flags (merge_ap));
- nm_ap_set_strength (found_ap, nm_ap_get_strength (merge_ap));
- nm_ap_set_last_seen (found_ap, nm_ap_get_last_seen (merge_ap));
- nm_ap_set_broadcast (found_ap, nm_ap_get_broadcast (merge_ap));
- nm_ap_set_freq (found_ap, nm_ap_get_freq (merge_ap));
- nm_ap_set_max_bitrate (found_ap, nm_ap_get_max_bitrate (merge_ap));
-
- /* If the AP is noticed in a scan, it's automatically no longer
- * fake, since it clearly exists somewhere.
- */
+ nm_ap_update_from_properties (found_ap, supplicant_path, properties);
nm_ap_set_fake (found_ap, FALSE);
g_object_set_data (G_OBJECT (found_ap), WPAS_REMOVED_TAG, NULL);
} else {
@@ -1673,7 +1641,7 @@ supplicant_iface_new_bss_cb (NMSupplicantInterface *iface,
nm_ap_dump (ap, "New AP: ");
/* Add the AP to the device's AP list */
- merge_scanned_ap (self, ap);
+ merge_scanned_ap (self, ap, object_path, properties);
g_object_unref (ap);
/* Update the current AP if the supplicant notified a current BSS change
diff --git a/src/devices/wifi/nm-wifi-ap.c b/src/devices/wifi/nm-wifi-ap.c
index ae318b0197..107cac77ed 100644
--- a/src/devices/wifi/nm-wifi-ap.c
+++ b/src/devices/wifi/nm-wifi-ap.c
@@ -1190,31 +1190,8 @@ nm_ap_complete_connection (NMAccessPoint *self,
error);
}
-static gboolean
-capabilities_compatible (NM80211ApSecurityFlags a_flags, NM80211ApSecurityFlags b_flags)
-{
- if (a_flags == b_flags)
- return TRUE;
-
- /* Make sure there's a common key management method */
- if (!((a_flags & 0x300) & (b_flags & 0x300)))
- return FALSE;
-
- /* Ensure common pairwise ciphers */
- if (!((a_flags & 0xF) & (b_flags & 0xF)))
- return FALSE;
-
- /* Ensure common group ciphers */
- if (!((a_flags & 0xF0) & (b_flags & 0xF0)))
- return FALSE;
-
- return TRUE;
-}
-
NMAccessPoint *
-nm_ap_match_in_hash (NMAccessPoint *find_ap,
- GHashTable *hash,
- gboolean strict_match)
+nm_ap_match_in_hash (NMAccessPoint *find_ap, GHashTable *hash)
{
GHashTableIter iter;
NMAccessPoint *list_ap;
@@ -1243,8 +1220,7 @@ nm_ap_match_in_hash (NMAccessPoint *find_ap,
continue;
/* BSSID match */
- if ( (strict_match || nm_ethernet_address_is_valid (find_addr, -1))
- && nm_ethernet_address_is_valid (list_addr, -1)
+ if ( nm_ethernet_address_is_valid (list_addr, -1)
&& !nm_utils_hwaddr_matches (list_addr, -1, find_addr, -1))
continue;
@@ -1260,23 +1236,11 @@ nm_ap_match_in_hash (NMAccessPoint *find_ap,
if (nm_ap_get_flags (list_ap) != nm_ap_get_flags (find_ap))
continue;
- if (strict_match) {
- if (nm_ap_get_wpa_flags (list_ap) != nm_ap_get_wpa_flags (find_ap))
- continue;
-
- if (nm_ap_get_rsn_flags (list_ap) != nm_ap_get_rsn_flags (find_ap))
- continue;
- } else {
- NM80211ApSecurityFlags list_wpa_flags = nm_ap_get_wpa_flags (list_ap);
- NM80211ApSecurityFlags find_wpa_flags = nm_ap_get_wpa_flags (find_ap);
- NM80211ApSecurityFlags list_rsn_flags = nm_ap_get_rsn_flags (list_ap);
- NM80211ApSecurityFlags find_rsn_flags = nm_ap_get_rsn_flags (find_ap);
-
- /* Just ensure that there is overlap in the capabilities */
- if ( !capabilities_compatible (list_wpa_flags, find_wpa_flags)
- && !capabilities_compatible (list_rsn_flags, find_rsn_flags))
- continue;
- }
+ if (nm_ap_get_wpa_flags (list_ap) != nm_ap_get_wpa_flags (find_ap))
+ continue;
+
+ if (nm_ap_get_rsn_flags (list_ap) != nm_ap_get_rsn_flags (find_ap))
+ continue;
return list_ap;
}
diff --git a/src/devices/wifi/nm-wifi-ap.h b/src/devices/wifi/nm-wifi-ap.h
index 01a104d669..84e5fa34e3 100644
--- a/src/devices/wifi/nm-wifi-ap.h
+++ b/src/devices/wifi/nm-wifi-ap.h
@@ -118,9 +118,7 @@ gboolean nm_ap_complete_connection (NMAccessPoint *self,
gboolean lock_bssid,
GError **error);
-NMAccessPoint * nm_ap_match_in_hash (NMAccessPoint *find_ap,
- GHashTable *hash,
- gboolean strict_match);
+NMAccessPoint * nm_ap_match_in_hash (NMAccessPoint *find_ap, GHashTable *hash);
void nm_ap_dump (NMAccessPoint *ap, const char *prefix);