From 702e8eec9e543b2c26b5d07d83b4f12db768b7b6 Mon Sep 17 00:00:00 2001
From: Thomas Haller <thaller@redhat.com>
Date: Sun, 11 Sep 2016 09:48:56 +0200
Subject: [PATCH 1/1] device: wait for MAC address change to complete before
setting interface up
Some drivers (brcmfmac) don't change the MAC address right away.
NetworkManager works around that by waiting synchronously until
the address changes (commit 1a85103765d4eaa0acab6b03658a4f9cfe684a64).
wpa_supplicant on the other hand, only re-reads the MAC address
when changing state from DISABLED to ENABLED, which happens when
the interface comes up.
That is a bug in wpa_supplicant and the driver, but we can work-around by
waiting until the MAC address actually changed before setting the interface
IFF_UP. Also note, that there is still a race in wpa_supplicant which might
miss a change to DISABLED state altogether.
https://bugzilla.gnome.org/show_bug.cgi?id=770504
https://bugzilla.redhat.com/show_bug.cgi?id=1374023
(cherry picked from commit 32f7c1d4b9aba597a99128631f07c2985149f303)
(cherry picked from commit cd8f2ecc617a896d8007e6fe825c676a626a3b8d)
---
src/devices/nm-device.c | 27 ++++++++++++++++-----------
1 file changed, 16 insertions(+), 11 deletions(-)
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 240e590..d5e1f95 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -11834,12 +11834,8 @@ _hw_addr_set (NMDevice *self,
nm_platform_error_to_string (plerr));
}
- if (was_up) {
- if (!nm_device_bring_up (self, TRUE, NULL))
- return FALSE;
- }
-
if (needs_refresh) {
+ success = TRUE;
if (_hw_addr_matches (self, addr)) {
/* the MAC address already changed during nm_device_bring_up() above. */
} else {
@@ -11876,15 +11872,24 @@ handle_wait:
continue;
}
handle_fail:
- _LOGW (LOGD_DEVICE,
- "set-hw-addr: new MAC address %s not successfully %s (%s)",
- addr, operation, detail);
- return FALSE;
+ success = FALSE;
+ break;
}
}
- _LOGI (LOGD_DEVICE, "set-hw-addr: %s MAC address to %s (%s)",
- operation, addr, detail);
+ if (success) {
+ _LOGI (LOGD_DEVICE, "set-hw-addr: %s MAC address to %s (%s)",
+ operation, addr, detail);
+ } else {
+ _LOGW (LOGD_DEVICE,
+ "set-hw-addr: new MAC address %s not successfully %s (%s)",
+ addr, operation, detail);
+ }
+ }
+
+ if (was_up) {
+ if (!nm_device_bring_up (self, TRUE, NULL))
+ return FALSE;
}
return success;
--
2.7.4