summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-06-23 16:01:10 +0200
committerThomas Haller <thaller@redhat.com>2016-06-28 18:46:12 +0200
commitce1fe7febf16751af029597f5ff7828d1de32e79 (patch)
tree9234597c0ac7f247af0a1f9b30fc91bb9e78b587
parent6a4d102e95bfbaf42fa9d85cc5dcf72d12c156fb (diff)
downloadNetworkManager-th/device-inital-mac-addr-bgo708820.tar.gz
device: don't regenerate MAC address on multiple _set_cloned() callsth/device-inital-mac-addr-bgo708820
Wi-Fi device first have a state-transition "disconnected -> prepare" on which they run activate_stage1_device_prepare() and set the MAC address the first time. Later, after getting secrets, they have a state transition "need-auth -> prepare" and end up calling nm_device_hw_addr_set_cloned() again. In this case, we must not regenerate a new MAC address but bail out. There is a small uncertainty there, because we are not sure that the previously generated connection really entailed the same settings. But since we always call nm_device_hw_addr_reset() during device deactivation, this cannot be a left-over from a previous activation and is thus the same activation request.
-rw-r--r--src/devices/nm-device.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index fb15f0fdc4..76133bfb9e 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -11748,6 +11748,12 @@ nm_device_hw_addr_set_cloned (NMDevice *self, NMConnection *connection, gboolean
return FALSE;
priv->hw_addr_type = HW_ADDR_TYPE_PERMANENT;
} else if (NM_IN_STRSET (addr, NM_CLONED_MAC_RANDOM)) {
+ if (priv->hw_addr_type == HW_ADDR_TYPE_GENERATED) {
+ /* hm, we already use a generate MAC address. Most certainly, that is from the same
+ * activation request, so we should not create a new random address, instead keep
+ * the current. */
+ return TRUE;
+ }
hw_addr_generated = nm_utils_hw_addr_gen_random_eth (nm_device_get_initial_hw_address (self),
_get_generate_mac_address_mask_setting (self, connection, is_wifi, &generate_mac_address_mask_tmp));
if (!hw_addr_generated) {
@@ -11760,6 +11766,12 @@ nm_device_hw_addr_set_cloned (NMDevice *self, NMConnection *connection, gboolean
NMUtilsStableType stable_type;
const char *stable_id;
+ if (priv->hw_addr_type == HW_ADDR_TYPE_GENERATED) {
+ /* hm, we already use a generate MAC address. Most certainly, that is from the same
+ * activation request, so let's skip creating the stable address anew. */
+ return TRUE;
+ }
+
stable_id = _get_stable_id (connection, &stable_type);
if (stable_id) {
hw_addr_generated = nm_utils_hw_addr_gen_stable_eth (stable_type, stable_id,