]>
Commit | Line | Data |
---|---|---|
236c23f6 JR |
1 | From c52f385566e558ee3edc98d20225155b362d212f Mon Sep 17 00:00:00 2001 |
2 | From: Thomas Haller <thaller@redhat.com> | |
3 | Date: Sun, 28 Aug 2016 13:52:32 +0200 | |
4 | Subject: [PATCH 1/4] platform: split processing result from do_change_link() | |
5 | ||
6 | (cherry picked from commit 3dc09446771a3434ed948bdd5e6ca9f6ef9a9e76) | |
7 | (cherry picked from commit 471521ca84187cd32afcd20aebe5a369fe7368dc) | |
8 | --- | |
9 | src/platform/nm-linux-platform.c | 35 +++++++++++++++++++++++++++-------- | |
10 | 1 file changed, 27 insertions(+), 8 deletions(-) | |
11 | ||
12 | diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c | |
13 | index 98c4e46..eeb24ca 100644 | |
14 | --- a/src/platform/nm-linux-platform.c | |
15 | +++ b/src/platform/nm-linux-platform.c | |
16 | @@ -4060,18 +4060,14 @@ out: | |
17 | return !!nmp_cache_lookup_obj (priv->cache, obj_id); | |
18 | } | |
19 | ||
20 | -static NMPlatformError | |
21 | -do_change_link (NMPlatform *platform, | |
22 | - int ifindex, | |
23 | - struct nl_msg *nlmsg) | |
24 | +static WaitForNlResponseResult | |
25 | +do_change_link_request (NMPlatform *platform, | |
26 | + int ifindex, | |
27 | + struct nl_msg *nlmsg) | |
28 | { | |
29 | nm_auto_pop_netns NMPNetns *netns = NULL; | |
30 | WaitForNlResponseResult seq_result = WAIT_FOR_NL_RESPONSE_RESULT_UNKNOWN; | |
31 | int nle; | |
32 | - char s_buf[256]; | |
33 | - NMPlatformError result = NM_PLATFORM_ERROR_SUCCESS; | |
34 | - NMLogLevel log_level = LOGL_DEBUG; | |
35 | - const char *log_result = "failure", *log_detail = ""; | |
36 | ||
37 | if (!nm_platform_netns_push (platform, &netns)) | |
38 | return NM_PLATFORM_ERROR_UNSPECIFIED; | |
39 | @@ -4098,6 +4094,18 @@ retry: | |
40 | nlmsg_hdr (nlmsg)->nlmsg_type = RTM_SETLINK; | |
41 | goto retry; | |
42 | } | |
43 | + return seq_result; | |
44 | +} | |
45 | + | |
46 | +static NMPlatformError | |
47 | +do_change_link_result (NMPlatform *platform, | |
48 | + int ifindex, | |
49 | + WaitForNlResponseResult seq_result) | |
50 | +{ | |
51 | + char s_buf[256]; | |
52 | + NMPlatformError result = NM_PLATFORM_ERROR_SUCCESS; | |
53 | + NMLogLevel log_level = LOGL_DEBUG; | |
54 | + const char *log_result = "failure", *log_detail = ""; | |
55 | ||
56 | if (seq_result == WAIT_FOR_NL_RESPONSE_RESULT_RESPONSE_OK) { | |
57 | log_result = "success"; | |
58 | @@ -4123,6 +4131,17 @@ retry: | |
59 | return result; | |
60 | } | |
61 | ||
62 | +static NMPlatformError | |
63 | +do_change_link (NMPlatform *platform, | |
64 | + int ifindex, | |
65 | + struct nl_msg *nlmsg) | |
66 | +{ | |
67 | + WaitForNlResponseResult seq_result; | |
68 | + | |
69 | + seq_result = do_change_link_request (platform, ifindex, nlmsg); | |
70 | + return do_change_link_result (platform, ifindex, seq_result); | |
71 | +} | |
72 | + | |
73 | static gboolean | |
74 | link_add (NMPlatform *platform, | |
75 | const char *name, | |
76 | -- | |
77 | 2.7.4 | |
78 | ||
79 | ||
80 | From 559ed361a30650f263668aadb86233fb405f0b29 Mon Sep 17 00:00:00 2001 | |
81 | From: Thomas Haller <thaller@redhat.com> | |
82 | Date: Sun, 28 Aug 2016 14:08:42 +0200 | |
83 | Subject: [PATCH 2/4] platform: workaround kernel wrongly returning ENFILE when | |
84 | changing MAC address | |
85 | ||
86 | https://bugzilla.gnome.org/show_bug.cgi?id=770456 | |
87 | (cherry picked from commit 2bef71611bd9fd2e333a7522205f0262ac25680f) | |
88 | (cherry picked from commit 06d1679aa9867682297316e7b2cfac6fc8f67c2a) | |
89 | --- | |
90 | src/platform/nm-linux-platform.c | 27 ++++++++++++++++++++++++++- | |
91 | 1 file changed, 26 insertions(+), 1 deletion(-) | |
92 | ||
93 | diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c | |
94 | index eeb24ca..c36e967 100644 | |
95 | --- a/src/platform/nm-linux-platform.c | |
96 | +++ b/src/platform/nm-linux-platform.c | |
97 | @@ -4449,6 +4449,8 @@ link_set_address (NMPlatform *platform, int ifindex, gconstpointer address, size | |
98 | { | |
99 | nm_auto_nlmsg struct nl_msg *nlmsg = NULL; | |
100 | gs_free char *mac = NULL; | |
101 | + WaitForNlResponseResult seq_result; | |
102 | + char s_buf[256]; | |
103 | ||
104 | if (!address || !length) | |
105 | g_return_val_if_reached (NM_PLATFORM_ERROR_BUG); | |
106 | @@ -4468,7 +4470,30 @@ link_set_address (NMPlatform *platform, int ifindex, gconstpointer address, size | |
107 | ||
108 | NLA_PUT (nlmsg, IFLA_ADDRESS, length, address); | |
109 | ||
110 | - return do_change_link (platform, ifindex, nlmsg); | |
111 | + seq_result = do_change_link_request (platform, ifindex, nlmsg); | |
112 | + | |
113 | + if (NM_IN_SET (-((int) seq_result), ENFILE)) { | |
114 | + const NMPObject *obj_cache; | |
115 | + | |
116 | + /* workaround ENFILE which may be wrongly returned (bgo #770456). | |
117 | + * If the MAC address is as expected, assume success? */ | |
118 | + | |
119 | + obj_cache = nmp_cache_lookup_link (NM_LINUX_PLATFORM_GET_PRIVATE (platform)->cache, ifindex); | |
120 | + if ( obj_cache | |
121 | + && obj_cache->link.addr.len == length | |
122 | + && memcmp (obj_cache->link.addr.data, address, length) == 0) { | |
123 | + _NMLOG (LOGL_DEBUG, | |
124 | + "do-change-link[%d]: %s changing link: %s%s", | |
125 | + ifindex, | |
126 | + "success", | |
127 | + wait_for_nl_response_to_string (seq_result, s_buf, sizeof (s_buf)), | |
128 | + " (assume success changing address)"); | |
129 | + return NM_PLATFORM_ERROR_SUCCESS; | |
130 | + } | |
131 | + } | |
132 | + | |
133 | + return do_change_link_result (platform, ifindex, seq_result); | |
134 | + | |
135 | nla_put_failure: | |
136 | g_return_val_if_reached (NM_PLATFORM_ERROR_UNSPECIFIED); | |
137 | } | |
138 | -- | |
139 | 2.7.4 | |
140 | ||
141 | ||
142 | From afe1a15516f0a5024f161e3ff1046afdfb7e58b8 Mon Sep 17 00:00:00 2001 | |
143 | From: Thomas Haller <thaller@redhat.com> | |
144 | Date: Mon, 29 Aug 2016 17:14:04 +0200 | |
145 | Subject: [PATCH 3/4] device: fix spelling in logging | |
146 | ||
147 | (cherry picked from commit d51f2c2a4e99799739e2adbeaf578144b556c4b9) | |
148 | (cherry picked from commit b1f5d3d798498c53fe65257490b2df3e3f71e364) | |
149 | --- | |
150 | src/devices/nm-device.c | 2 +- | |
151 | 1 file changed, 1 insertion(+), 1 deletion(-) | |
152 | ||
153 | diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c | |
154 | index 199acc6..305a1bb 100644 | |
155 | --- a/src/devices/nm-device.c | |
156 | +++ b/src/devices/nm-device.c | |
157 | @@ -11820,7 +11820,7 @@ _hw_addr_set (NMDevice *self, | |
158 | operation, addr, detail); | |
159 | } else { | |
160 | _LOGW (LOGD_DEVICE, | |
161 | - "set-hw-addr: new MAC address %s not successfully set to %s (%s)", | |
162 | + "set-hw-addr: new MAC address %s not successfully %s (%s)", | |
163 | addr, operation, detail); | |
164 | success = FALSE; | |
165 | } | |
166 | -- | |
167 | 2.7.4 | |
168 | ||
169 | ||
170 | From ac81b54da92c569db110407a63142565d69963f4 Mon Sep 17 00:00:00 2001 | |
171 | From: Thomas Haller <thaller@redhat.com> | |
172 | Date: Mon, 29 Aug 2016 18:28:34 +0200 | |
173 | Subject: [PATCH 4/4] device: add hack to wait after changing MAC address | |
174 | ||
175 | It seems some drivers return success for nm_platform_link_set_address(), | |
176 | but at that point the address did not yet actually change *sigh*. | |
177 | It changes a bit later, possibly after setting the device up. | |
178 | ||
179 | Add a workaround to retry reading the MAC address when platform indicates | |
180 | success but the address still differs at first. | |
181 | ||
182 | https://bugzilla.gnome.org/show_bug.cgi?id=770456 | |
183 | (cherry picked from commit 67b685235847ac49712d77023e23ef5c38e82a9e) | |
184 | (cherry picked from commit 3b51959f48f2b40a4d85e1d36fd69a46548369cb) | |
185 | --- | |
186 | src/devices/nm-device.c | 28 +++++++++++++++++++++++++--- | |
187 | 1 file changed, 25 insertions(+), 3 deletions(-) | |
188 | ||
189 | diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c | |
190 | index 305a1bb..6939332 100644 | |
191 | --- a/src/devices/nm-device.c | |
192 | +++ b/src/devices/nm-device.c | |
193 | @@ -11774,6 +11774,7 @@ _hw_addr_set (NMDevice *self, | |
194 | { | |
195 | NMDevicePrivate *priv; | |
196 | gboolean success = FALSE; | |
197 | + gboolean needs_refresh = FALSE; | |
198 | NMPlatformError plerr; | |
199 | const char *cur_addr; | |
200 | guint8 addr_bytes[NM_UTILS_HWADDR_LEN_MAX]; | |
201 | @@ -11819,10 +11820,10 @@ _hw_addr_set (NMDevice *self, | |
202 | _LOGI (LOGD_DEVICE, "set-hw-addr: %s MAC address to %s (%s)", | |
203 | operation, addr, detail); | |
204 | } else { | |
205 | - _LOGW (LOGD_DEVICE, | |
206 | - "set-hw-addr: new MAC address %s not successfully %s (%s)", | |
207 | + _LOGD (LOGD_DEVICE, | |
208 | + "set-hw-addr: new MAC address %s not successfully %s (%s) (refresh link)", | |
209 | addr, operation, detail); | |
210 | - success = FALSE; | |
211 | + needs_refresh = TRUE; | |
212 | } | |
213 | } else { | |
214 | _NMLOG (plerr == NM_PLATFORM_ERROR_NOT_FOUND ? LOGL_DEBUG : LOGL_WARN, | |
215 | @@ -11836,6 +11837,27 @@ _hw_addr_set (NMDevice *self, | |
216 | return FALSE; | |
217 | } | |
218 | ||
219 | + if (needs_refresh) { | |
220 | + /* The platform call indicated success, however the address is not | |
221 | + * as expected. May be a kernel issue and the MAC address takes | |
222 | + * a moment to change (bgo#770456). | |
223 | + * | |
224 | + * Try to reload the link and check again. */ | |
225 | + nm_platform_link_refresh (NM_PLATFORM_GET, nm_device_get_ip_ifindex (self)); | |
226 | + | |
227 | + nm_device_update_hw_address (self); | |
228 | + cur_addr = nm_device_get_hw_address (self); | |
229 | + if (cur_addr && nm_utils_hwaddr_matches (cur_addr, -1, addr, -1)) { | |
230 | + _LOGI (LOGD_DEVICE, "set-hw-addr: %s MAC address to %s (%s)", | |
231 | + operation, addr, detail); | |
232 | + } else { | |
233 | + _LOGW (LOGD_DEVICE, | |
234 | + "set-hw-addr: new MAC address %s not successfully %s (%s)", | |
235 | + addr, operation, detail); | |
236 | + return FALSE; | |
237 | + } | |
238 | + } | |
239 | + | |
240 | return success; | |
241 | } | |
242 | ||
243 | -- | |
244 | 2.7.4 | |
245 |