1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
From: Thomas Haller <thaller@redhat.com>
Date: Mon, 29 Aug 2016 18:28:34 +0200
Subject: device: add hack to wait after changing MAC address
It seems some drivers return success for nm_platform_link_set_address(),
but at that point the address did not yet actually change *sigh*.
It changes a bit later, possibly after setting the device up.
Add a workaround to retry reading the MAC address when platform indicates
success but the address still differs at first.
https://bugzilla.gnome.org/show_bug.cgi?id=770456
(cherry picked from commit 67b685235847ac49712d77023e23ef5c38e82a9e)
(cherry picked from commit 3b51959f48f2b40a4d85e1d36fd69a46548369cb)
---
src/devices/nm-device.c | 28 +++++++++++++++++++++++++---
1 file changed, 25 insertions(+), 3 deletions(-)
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 305a1bb..6939332 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -11774,6 +11774,7 @@ _hw_addr_set (NMDevice *self,
{
NMDevicePrivate *priv;
gboolean success = FALSE;
+ gboolean needs_refresh = FALSE;
NMPlatformError plerr;
const char *cur_addr;
guint8 addr_bytes[NM_UTILS_HWADDR_LEN_MAX];
@@ -11819,10 +11820,10 @@ _hw_addr_set (NMDevice *self,
_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)",
+ _LOGD (LOGD_DEVICE,
+ "set-hw-addr: new MAC address %s not successfully %s (%s) (refresh link)",
addr, operation, detail);
- success = FALSE;
+ needs_refresh = TRUE;
}
} else {
_NMLOG (plerr == NM_PLATFORM_ERROR_NOT_FOUND ? LOGL_DEBUG : LOGL_WARN,
@@ -11836,6 +11837,27 @@ _hw_addr_set (NMDevice *self,
return FALSE;
}
+ if (needs_refresh) {
+ /* The platform call indicated success, however the address is not
+ * as expected. May be a kernel issue and the MAC address takes
+ * a moment to change (bgo#770456).
+ *
+ * Try to reload the link and check again. */
+ nm_platform_link_refresh (NM_PLATFORM_GET, nm_device_get_ip_ifindex (self));
+
+ nm_device_update_hw_address (self);
+ cur_addr = nm_device_get_hw_address (self);
+ if (cur_addr && nm_utils_hwaddr_matches (cur_addr, -1, addr, -1)) {
+ _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);
+ return FALSE;
+ }
+ }
+
return success;
}
|