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 1a85103765).

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 32f7c1d4b9)
This commit is contained in:
Thomas Haller 2016-09-11 09:48:56 +02:00
parent ee3d814f11
commit cd8f2ecc61

View file

@ -11835,12 +11835,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 {
@ -11877,15 +11873,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;