diff options
Diffstat (limited to 'src/core/devices/wifi')
| -rw-r--r-- | src/core/devices/wifi/nm-device-wifi.c | 71 | ||||
| -rw-r--r-- | src/core/devices/wifi/nm-iwd-manager.c | 2 | ||||
| -rw-r--r-- | src/core/devices/wifi/tests/test-devices-wifi.c | 34 |
3 files changed, 72 insertions, 35 deletions
diff --git a/src/core/devices/wifi/nm-device-wifi.c b/src/core/devices/wifi/nm-device-wifi.c index 2572213c..39c68d77 100644 --- a/src/core/devices/wifi/nm-device-wifi.c +++ b/src/core/devices/wifi/nm-device-wifi.c @@ -86,6 +86,7 @@ typedef struct { GCancellable *scan_request_cancellable; GSource *scan_request_delay_source; + GSource *roam_supplicant_wait_source; NMWifiAP *current_ap; @@ -939,6 +940,7 @@ deactivate(NMDevice *device) int ifindex = nm_device_get_ifindex(device); nm_clear_g_source(&priv->periodic_update_id); + nm_clear_g_source_inst(&priv->roam_supplicant_wait_source); cleanup_association_attempt(self, TRUE); @@ -2512,8 +2514,15 @@ supplicant_iface_state(NMDeviceWifi *self, : "Connected to wireless network", (ssid_str = _nm_utils_ssid_to_string_gbytes(ssid))); nm_device_activate_schedule_stage3_ip_config(device, FALSE); - } else if (devstate == NM_DEVICE_STATE_ACTIVATED) + } else if (devstate == NM_DEVICE_STATE_ACTIVATED) { periodic_update(self); + if (priv->roam_supplicant_wait_source) { + _LOGD(LOGD_WIFI, + "supplicant state settled after roaming, renew dynamic IP configuration"); + nm_clear_g_source_inst(&priv->roam_supplicant_wait_source); + nm_device_update_dynamic_ip_setup(device); + } + } break; case NM_SUPPLICANT_INTERFACE_STATE_DISCONNECTED: if ((devstate == NM_DEVICE_STATE_ACTIVATED) || nm_device_is_activating(device)) { @@ -2584,6 +2593,21 @@ supplicant_iface_assoc_cb(NMSupplicantInterface *iface, GError *error, gpointer } } +static gboolean +roam_supplicant_wait_timeout(gpointer user_data) +{ + NMDeviceWifi *self = NM_DEVICE_WIFI(user_data); + NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self); + + _LOGD(LOGD_WIFI, "timeout waiting for supplicant to settle after roaming"); + + /* Eventually we still want to restart DHCP when the supplicant + * becomes ready */ + nm_clear_g_source_inst(&priv->roam_supplicant_wait_source); + priv->roam_supplicant_wait_source = g_source_ref(nm_g_source_sentinel_get(0)); + return G_SOURCE_CONTINUE; +} + static void supplicant_iface_notify_current_bss(NMSupplicantInterface *iface, GParamSpec *pspec, @@ -2636,7 +2660,19 @@ supplicant_iface_notify_current_bss(NMSupplicantInterface *iface, * Also, some APs (e.g. Cisco) can be configured to drop * all traffic until DHCP completes. To support such * cases, renew the lease when roaming to a new AP. */ - nm_device_update_dynamic_ip_setup(NM_DEVICE(self)); + + if (nm_supplicant_interface_get_state(priv->sup_iface) + == NM_SUPPLICANT_INTERFACE_STATE_COMPLETED) { + nm_device_update_dynamic_ip_setup(NM_DEVICE(self)); + } else { + /* Wait that the authentication to new the AP completes before + * trying to renew, otherwise the DHCP REQUEST could be lost + * and the client will fall back to a DISCOVER, potentially + * getting a different address. */ + nm_clear_g_source_inst(&priv->roam_supplicant_wait_source); + priv->roam_supplicant_wait_source = + nm_g_timeout_add_source(10000, roam_supplicant_wait_timeout, self); + } } set_current_ap(self, new_ap, TRUE); @@ -3144,21 +3180,21 @@ ensure_hotspot_frequency(NMDeviceWifi *self, NMSettingWireless *s_wifi, NMWifiAP gsize ssid_len; const guint8 *ssid_data; const guint8 random_seed[16] = {0x9a, - 0xdc, - 0x86, - 0x9a, - 0xa8, - 0xa2, - 0x07, - 0x97, - 0xbe, - 0x6d, - 0xe6, - 0x99, - 0x9f, - 0xa8, - 0x09, - 0x2b}; + 0xdc, + 0x86, + 0x9a, + 0xa8, + 0xa2, + 0x07, + 0x97, + 0xbe, + 0x6d, + 0xe6, + 0x99, + 0x9f, + 0xa8, + 0x09, + 0x2b}; /* Calculate a stable "random" number based on the SSID. */ ssid = nm_setting_wireless_get_ssid(s_wifi); @@ -3743,6 +3779,7 @@ dispose(GObject *object) nm_assert(c_list_is_empty(&priv->scanning_prohibited_lst_head)); nm_clear_g_source(&priv->periodic_update_id); + nm_clear_g_source_inst(&priv->roam_supplicant_wait_source); wifi_secrets_cancel(self); diff --git a/src/core/devices/wifi/nm-iwd-manager.c b/src/core/devices/wifi/nm-iwd-manager.c index 27222aae..2e0d51e5 100644 --- a/src/core/devices/wifi/nm-iwd-manager.c +++ b/src/core/devices/wifi/nm-iwd-manager.c @@ -306,7 +306,7 @@ iwd_agent_export(GDBusConnection *connection, gpointer user_data, char **agent_p unsigned int rnd; guint id; - nm_utils_random_bytes(&rnd, sizeof(rnd)); + nm_random_get_bytes(&rnd, sizeof(rnd)); nm_sprintf_buf(path, "/agent/%u", rnd); diff --git a/src/core/devices/wifi/tests/test-devices-wifi.c b/src/core/devices/wifi/tests/test-devices-wifi.c index 69d365e3..a52696ea 100644 --- a/src/core/devices/wifi/tests/test-devices-wifi.c +++ b/src/core/devices/wifi/tests/test-devices-wifi.c @@ -412,8 +412,8 @@ test_ap_wpa_psk_connection_base(const char *key_mgmt, const char *ssid = "blahblah"; const char *bssid = "01:02:03:04:05:06"; const KeyData exp_wifi[] = {{NM_SETTING_WIRELESS_SSID, ssid, 0}, - {NM_SETTING_WIRELESS_MODE, "infrastructure", 0}, - {NULL}}; + {NM_SETTING_WIRELESS_MODE, "infrastructure", 0}, + {NULL}}; const KeyData both_wsec[] = {{NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, key_mgmt, 0}, {NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, auth_alg, 0}, {NM_SETTING_WIRELESS_SECURITY_PSK, "asdfasdfasdfasdfasdfafs", 0}, @@ -541,8 +541,8 @@ test_ap_wpa_eap_connection_base(const char *key_mgmt, const char *bssid = "01:02:03:04:05:06"; const KeyData src_empty[] = {{NULL}}; const KeyData src_wsec[] = {{NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, key_mgmt, 0}, - {NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, auth_alg, 0}, - {NULL}}; + {NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, auth_alg, 0}, + {NULL}}; gboolean success; GError *error = NULL; @@ -778,12 +778,12 @@ test_priv_ap_leap_connection_1(gconstpointer add_wifi) const char *bssid = "01:02:03:04:05:06"; const char *leap_username = "Bill Smith"; const KeyData src_wsec[] = {{NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0}, - {NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME, leap_username, 0}, - {NULL}}; + {NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME, leap_username, 0}, + {NULL}}; const KeyData exp_wsec[] = {{NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0}, - {NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "leap", 0}, - {NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME, leap_username, 0}, - {NULL}}; + {NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "leap", 0}, + {NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME, leap_username, 0}, + {NULL}}; gboolean success; GError *error = NULL; @@ -862,15 +862,15 @@ test_priv_ap_dynamic_wep_1(void) const char *ssid = "blahblah"; const char *bssid = "01:02:03:04:05:06"; const KeyData src_wsec[] = {{NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0}, - {NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", 0}, - {NULL}}; + {NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", 0}, + {NULL}}; const KeyData both_8021x[] = {{NM_SETTING_802_1X_EAP, "peap", 0}, {NM_SETTING_802_1X_IDENTITY, "Bill Smith", 0}, {NM_SETTING_802_1X_PHASE2_AUTH, "mschapv2", 0}, {NULL}}; const KeyData exp_wsec[] = {{NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0}, - {NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", 0}, - {NULL}}; + {NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", 0}, + {NULL}}; gboolean success; GError *error = NULL; @@ -917,8 +917,8 @@ test_priv_ap_dynamic_wep_2(void) {NM_SETTING_802_1X_PHASE2_AUTH, "mschapv2", 0}, {NULL}}; const KeyData exp_wsec[] = {{NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0}, - {NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", 0}, - {NULL}}; + {NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", 0}, + {NULL}}; gboolean success; GError *error = NULL; @@ -1130,8 +1130,8 @@ test_wpa_ap_leap_connection_1(gconstpointer data) const char *bssid = "01:02:03:04:05:06"; const char *leap_username = "Bill Smith"; const KeyData src_wsec[] = {{NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0}, - {NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME, leap_username, 0}, - {NULL}}; + {NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME, leap_username, 0}, + {NULL}}; gboolean success; GError *error = NULL; |