device/wifi: don't reset the SSID of a NMWifiAP to unknown

For hidden networks, we usually don't have an SSID. We try to match
and fill the SSID based on the profiles that we have:

  <debug> [1603798852.9918] device[6b383dca267b6878] (wlp2s0): matched hidden AP AA:BB:CC:DD:EE:FF => "SSID"

However, we should not clear that value again on the next update:

  <trace> [1603798856.5724] sup-iface[66c1a0883a262394,0,wlp2s0]: BSS /fi/w1/wpa_supplicant1/Interfaces/0/BSSs/3 updated
  <debug> [1603798856.5726] device[6b383dca267b6878] (wlp2s0): wifi-ap: updated AA:BB:CC:DD:EE:FF (none)

Once we have a SSID, we can only update it to a better value,
but not clear it.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/438

Fixes: b83f07916a ('supplicant: large rework of wpa_supplicant handling')
(cherry picked from commit eb36380335)
This commit is contained in:
Thomas Haller 2020-10-27 13:44:08 +01:00
parent d28133ad0d
commit 40edd49025
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -113,22 +113,26 @@ nm_wifi_ap_set_ssid(NMWifiAP *ap, GBytes *ssid)
g_return_val_if_fail(NM_IS_WIFI_AP(ap), FALSE);
if (ssid) {
l = g_bytes_get_size(ssid);
if (l == 0 || l > 32)
g_return_val_if_reached(FALSE);
if (!ssid) {
/* we don't clear the SSID, once we have it. We can only update
* it by a better value. */
return FALSE;
}
l = g_bytes_get_size(ssid);
if (l == 0 || l > 32)
g_return_val_if_reached(FALSE);
priv = NM_WIFI_AP_GET_PRIVATE(ap);
if (ssid == priv->ssid)
return FALSE;
if (ssid && priv->ssid && g_bytes_equal(ssid, priv->ssid))
if (priv->ssid && g_bytes_equal(ssid, priv->ssid))
return FALSE;
g_bytes_ref(ssid);
nm_clear_pointer(&priv->ssid, g_bytes_unref);
if (ssid)
priv->ssid = g_bytes_ref(ssid);
priv->ssid = ssid;
_notify(ap, PROP_SSID);
return TRUE;