diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2017-04-11 16:20:15 +0200 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2017-04-11 16:39:31 +0200 |
commit | 023417292339e34dd07e5b902576c1472ff0c3dd (patch) | |
tree | 13c71f3862efb4882f9ef80b4c370e775de4e83a | |
parent | 2c4e991abae3bd92064d62d5ffe951d2564d68c9 (diff) | |
download | NetworkManager-023417292339e34dd07e5b902576c1472ff0c3dd.tar.gz |
wifi: only attempt to set the scan MAC address when it actually changes
The address change involves setting the link down which causes the supplicant
interface to change state and in turn another scan attempt. This could lead to
a loop in case of broken drivers that are not able to change the MAC address
iff the MAC address is attempted at each scan request.
https://bugzilla.redhat.com/show_bug.cgi?id=1382741
-rw-r--r-- | src/devices/wifi/nm-device-wifi.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c index 1ebefd9074..7cc7ceb2fa 100644 --- a/src/devices/wifi/nm-device-wifi.c +++ b/src/devices/wifi/nm-device-wifi.c @@ -119,7 +119,6 @@ typedef struct { NMDeviceWifiCapabilities capabilities; gint32 hw_addr_scan_expire; - char *hw_addr_scan; } NMDeviceWifiPrivate; struct _NMDeviceWifi @@ -1138,7 +1137,9 @@ _hw_addr_set_scanning (NMDeviceWifi *self, gboolean do_reset) TRUE, TRUE); if (!randomize) { - g_clear_pointer (&priv->hw_addr_scan, g_free); + /* expire the temporary MAC address used during scanning */ + priv->hw_addr_scan_expire = 0; + if (do_reset) nm_device_hw_addr_reset (device, "scanning"); return; @@ -1146,9 +1147,9 @@ _hw_addr_set_scanning (NMDeviceWifi *self, gboolean do_reset) now = nm_utils_get_monotonic_timestamp_s (); - if ( !priv->hw_addr_scan - || now >= priv->hw_addr_scan_expire) { + if (now >= priv->hw_addr_scan_expire) { gs_free char *generate_mac_address_mask = NULL; + gs_free char *hw_addr_scan = NULL; /* the random MAC address for scanning expires after a while. * @@ -1162,12 +1163,10 @@ _hw_addr_set_scanning (NMDeviceWifi *self, gboolean do_reset) device, NULL); - g_free (priv->hw_addr_scan); - priv->hw_addr_scan = nm_utils_hw_addr_gen_random_eth (nm_device_get_initial_hw_address (device), - generate_mac_address_mask); + hw_addr_scan = nm_utils_hw_addr_gen_random_eth (nm_device_get_initial_hw_address (device), + generate_mac_address_mask); + nm_device_hw_addr_set (device, hw_addr_scan, "scanning", TRUE); } - - nm_device_hw_addr_set (device, priv->hw_addr_scan, "scanning", TRUE); } static void @@ -2454,8 +2453,8 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason) return NM_ACT_STAGE_RETURN_FAILURE; } - /* forget the temporary MAC address used during scanning */ - g_clear_pointer (&priv->hw_addr_scan, g_free); + /* expire the temporary MAC address used during scanning */ + priv->hw_addr_scan_expire = 0; /* Set spoof MAC to the interface */ if (!nm_device_hw_addr_set_cloned (device, connection, TRUE)) @@ -3221,8 +3220,6 @@ finalize (GObject *object) g_hash_table_unref (priv->aps); - g_free (priv->hw_addr_scan); - G_OBJECT_CLASS (nm_device_wifi_parent_class)->finalize (object); } |