|
|
a85faa |
From c01db59a7cc5d13f2305e0d44c97e1c7af028752 Mon Sep 17 00:00:00 2001
|
|
|
a85faa |
From: Thomas Haller <thaller@redhat.com>
|
|
|
a85faa |
Date: Sun, 28 Aug 2016 13:52:32 +0200
|
|
|
a85faa |
Subject: [PATCH 1/6] platform: split processing result from do_change_link()
|
|
|
a85faa |
|
|
|
a85faa |
(cherry picked from commit 3dc09446771a3434ed948bdd5e6ca9f6ef9a9e76)
|
|
|
a85faa |
(cherry picked from commit 471521ca84187cd32afcd20aebe5a369fe7368dc)
|
|
|
a85faa |
---
|
|
|
a85faa |
src/platform/nm-linux-platform.c | 35 +++++++++++++++++++++++++++--------
|
|
|
a85faa |
1 file changed, 27 insertions(+), 8 deletions(-)
|
|
|
a85faa |
|
|
|
a85faa |
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c
|
|
|
a85faa |
index 98c4e46..eeb24ca 100644
|
|
|
a85faa |
--- a/src/platform/nm-linux-platform.c
|
|
|
a85faa |
+++ b/src/platform/nm-linux-platform.c
|
|
|
a85faa |
@@ -4060,18 +4060,14 @@ out:
|
|
|
a85faa |
return !!nmp_cache_lookup_obj (priv->cache, obj_id);
|
|
|
a85faa |
}
|
|
|
a85faa |
|
|
|
a85faa |
-static NMPlatformError
|
|
|
a85faa |
-do_change_link (NMPlatform *platform,
|
|
|
a85faa |
- int ifindex,
|
|
|
a85faa |
- struct nl_msg *nlmsg)
|
|
|
a85faa |
+static WaitForNlResponseResult
|
|
|
a85faa |
+do_change_link_request (NMPlatform *platform,
|
|
|
a85faa |
+ int ifindex,
|
|
|
a85faa |
+ struct nl_msg *nlmsg)
|
|
|
a85faa |
{
|
|
|
a85faa |
nm_auto_pop_netns NMPNetns *netns = NULL;
|
|
|
a85faa |
WaitForNlResponseResult seq_result = WAIT_FOR_NL_RESPONSE_RESULT_UNKNOWN;
|
|
|
a85faa |
int nle;
|
|
|
a85faa |
- char s_buf[256];
|
|
|
a85faa |
- NMPlatformError result = NM_PLATFORM_ERROR_SUCCESS;
|
|
|
a85faa |
- NMLogLevel log_level = LOGL_DEBUG;
|
|
|
a85faa |
- const char *log_result = "failure", *log_detail = "";
|
|
|
a85faa |
|
|
|
a85faa |
if (!nm_platform_netns_push (platform, &netns))
|
|
|
a85faa |
return NM_PLATFORM_ERROR_UNSPECIFIED;
|
|
|
a85faa |
@@ -4098,6 +4094,18 @@ retry:
|
|
|
a85faa |
nlmsg_hdr (nlmsg)->nlmsg_type = RTM_SETLINK;
|
|
|
a85faa |
goto retry;
|
|
|
a85faa |
}
|
|
|
a85faa |
+ return seq_result;
|
|
|
a85faa |
+}
|
|
|
a85faa |
+
|
|
|
a85faa |
+static NMPlatformError
|
|
|
a85faa |
+do_change_link_result (NMPlatform *platform,
|
|
|
a85faa |
+ int ifindex,
|
|
|
a85faa |
+ WaitForNlResponseResult seq_result)
|
|
|
a85faa |
+{
|
|
|
a85faa |
+ char s_buf[256];
|
|
|
a85faa |
+ NMPlatformError result = NM_PLATFORM_ERROR_SUCCESS;
|
|
|
a85faa |
+ NMLogLevel log_level = LOGL_DEBUG;
|
|
|
a85faa |
+ const char *log_result = "failure", *log_detail = "";
|
|
|
a85faa |
|
|
|
a85faa |
if (seq_result == WAIT_FOR_NL_RESPONSE_RESULT_RESPONSE_OK) {
|
|
|
a85faa |
log_result = "success";
|
|
|
a85faa |
@@ -4123,6 +4131,17 @@ retry:
|
|
|
a85faa |
return result;
|
|
|
a85faa |
}
|
|
|
a85faa |
|
|
|
a85faa |
+static NMPlatformError
|
|
|
a85faa |
+do_change_link (NMPlatform *platform,
|
|
|
a85faa |
+ int ifindex,
|
|
|
a85faa |
+ struct nl_msg *nlmsg)
|
|
|
a85faa |
+{
|
|
|
a85faa |
+ WaitForNlResponseResult seq_result;
|
|
|
a85faa |
+
|
|
|
a85faa |
+ seq_result = do_change_link_request (platform, ifindex, nlmsg);
|
|
|
a85faa |
+ return do_change_link_result (platform, ifindex, seq_result);
|
|
|
a85faa |
+}
|
|
|
a85faa |
+
|
|
|
a85faa |
static gboolean
|
|
|
a85faa |
link_add (NMPlatform *platform,
|
|
|
a85faa |
const char *name,
|
|
|
a85faa |
--
|
|
|
a85faa |
2.7.4
|
|
|
a85faa |
|
|
|
a85faa |
|
|
|
a85faa |
From b2fcc8f414aefd1e6caf64e45a9ff1ba543f5b09 Mon Sep 17 00:00:00 2001
|
|
|
a85faa |
From: Thomas Haller <thaller@redhat.com>
|
|
|
a85faa |
Date: Sun, 28 Aug 2016 14:08:42 +0200
|
|
|
a85faa |
Subject: [PATCH 2/6] platform: workaround kernel wrongly returning ENFILE when
|
|
|
a85faa |
changing MAC address
|
|
|
a85faa |
|
|
|
a85faa |
https://bugzilla.gnome.org/show_bug.cgi?id=770456
|
|
|
a85faa |
(cherry picked from commit 2bef71611bd9fd2e333a7522205f0262ac25680f)
|
|
|
a85faa |
(cherry picked from commit 06d1679aa9867682297316e7b2cfac6fc8f67c2a)
|
|
|
a85faa |
---
|
|
|
a85faa |
src/platform/nm-linux-platform.c | 27 ++++++++++++++++++++++++++-
|
|
|
a85faa |
1 file changed, 26 insertions(+), 1 deletion(-)
|
|
|
a85faa |
|
|
|
a85faa |
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c
|
|
|
a85faa |
index eeb24ca..c36e967 100644
|
|
|
a85faa |
--- a/src/platform/nm-linux-platform.c
|
|
|
a85faa |
+++ b/src/platform/nm-linux-platform.c
|
|
|
a85faa |
@@ -4449,6 +4449,8 @@ link_set_address (NMPlatform *platform, int ifindex, gconstpointer address, size
|
|
|
a85faa |
{
|
|
|
a85faa |
nm_auto_nlmsg struct nl_msg *nlmsg = NULL;
|
|
|
a85faa |
gs_free char *mac = NULL;
|
|
|
a85faa |
+ WaitForNlResponseResult seq_result;
|
|
|
a85faa |
+ char s_buf[256];
|
|
|
a85faa |
|
|
|
a85faa |
if (!address || !length)
|
|
|
a85faa |
g_return_val_if_reached (NM_PLATFORM_ERROR_BUG);
|
|
|
a85faa |
@@ -4468,7 +4470,30 @@ link_set_address (NMPlatform *platform, int ifindex, gconstpointer address, size
|
|
|
a85faa |
|
|
|
a85faa |
NLA_PUT (nlmsg, IFLA_ADDRESS, length, address);
|
|
|
a85faa |
|
|
|
a85faa |
- return do_change_link (platform, ifindex, nlmsg);
|
|
|
a85faa |
+ seq_result = do_change_link_request (platform, ifindex, nlmsg);
|
|
|
a85faa |
+
|
|
|
a85faa |
+ if (NM_IN_SET (-((int) seq_result), ENFILE)) {
|
|
|
a85faa |
+ const NMPObject *obj_cache;
|
|
|
a85faa |
+
|
|
|
a85faa |
+ /* workaround ENFILE which may be wrongly returned (bgo #770456).
|
|
|
a85faa |
+ * If the MAC address is as expected, assume success? */
|
|
|
a85faa |
+
|
|
|
a85faa |
+ obj_cache = nmp_cache_lookup_link (NM_LINUX_PLATFORM_GET_PRIVATE (platform)->cache, ifindex);
|
|
|
a85faa |
+ if ( obj_cache
|
|
|
a85faa |
+ && obj_cache->link.addr.len == length
|
|
|
a85faa |
+ && memcmp (obj_cache->link.addr.data, address, length) == 0) {
|
|
|
a85faa |
+ _NMLOG (LOGL_DEBUG,
|
|
|
a85faa |
+ "do-change-link[%d]: %s changing link: %s%s",
|
|
|
a85faa |
+ ifindex,
|
|
|
a85faa |
+ "success",
|
|
|
a85faa |
+ wait_for_nl_response_to_string (seq_result, s_buf, sizeof (s_buf)),
|
|
|
a85faa |
+ " (assume success changing address)");
|
|
|
a85faa |
+ return NM_PLATFORM_ERROR_SUCCESS;
|
|
|
a85faa |
+ }
|
|
|
a85faa |
+ }
|
|
|
a85faa |
+
|
|
|
a85faa |
+ return do_change_link_result (platform, ifindex, seq_result);
|
|
|
a85faa |
+
|
|
|
a85faa |
nla_put_failure:
|
|
|
a85faa |
g_return_val_if_reached (NM_PLATFORM_ERROR_UNSPECIFIED);
|
|
|
a85faa |
}
|
|
|
a85faa |
--
|
|
|
a85faa |
2.7.4
|
|
|
a85faa |
|
|
|
a85faa |
|
|
|
a85faa |
From aa0bc143376d7d4a50d45909a9776e161ee60b37 Mon Sep 17 00:00:00 2001
|
|
|
a85faa |
From: Thomas Haller <thaller@redhat.com>
|
|
|
a85faa |
Date: Mon, 29 Aug 2016 17:14:04 +0200
|
|
|
a85faa |
Subject: [PATCH 3/6] device: fix spelling in logging
|
|
|
a85faa |
|
|
|
a85faa |
(cherry picked from commit d51f2c2a4e99799739e2adbeaf578144b556c4b9)
|
|
|
a85faa |
(cherry picked from commit b1f5d3d798498c53fe65257490b2df3e3f71e364)
|
|
|
a85faa |
---
|
|
|
a85faa |
src/devices/nm-device.c | 2 +-
|
|
|
a85faa |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
a85faa |
|
|
|
a85faa |
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
|
|
|
a85faa |
index 199acc6..305a1bb 100644
|
|
|
a85faa |
--- a/src/devices/nm-device.c
|
|
|
a85faa |
+++ b/src/devices/nm-device.c
|
|
|
a85faa |
@@ -11820,7 +11820,7 @@ _hw_addr_set (NMDevice *self,
|
|
|
a85faa |
operation, addr, detail);
|
|
|
a85faa |
} else {
|
|
|
a85faa |
_LOGW (LOGD_DEVICE,
|
|
|
a85faa |
- "set-hw-addr: new MAC address %s not successfully set to %s (%s)",
|
|
|
a85faa |
+ "set-hw-addr: new MAC address %s not successfully %s (%s)",
|
|
|
a85faa |
addr, operation, detail);
|
|
|
a85faa |
success = FALSE;
|
|
|
a85faa |
}
|
|
|
a85faa |
--
|
|
|
a85faa |
2.7.4
|
|
|
a85faa |
|
|
|
a85faa |
|
|
|
a85faa |
From 9e3e5bbd0d0f36a117115783457caec359b763a7 Mon Sep 17 00:00:00 2001
|
|
|
a85faa |
From: Thomas Haller <thaller@redhat.com>
|
|
|
a85faa |
Date: Mon, 29 Aug 2016 18:28:34 +0200
|
|
|
a85faa |
Subject: [PATCH 4/6] device: add hack to wait after changing MAC address
|
|
|
a85faa |
|
|
|
a85faa |
It seems some drivers return success for nm_platform_link_set_address(),
|
|
|
a85faa |
but at that point the address did not yet actually change *sigh*.
|
|
|
a85faa |
It changes a bit later, possibly after setting the device up.
|
|
|
a85faa |
|
|
|
a85faa |
Add a workaround to retry reading the MAC address when platform indicates
|
|
|
a85faa |
success but the address still differs at first.
|
|
|
a85faa |
|
|
|
a85faa |
https://bugzilla.gnome.org/show_bug.cgi?id=770456
|
|
|
a85faa |
(cherry picked from commit 67b685235847ac49712d77023e23ef5c38e82a9e)
|
|
|
a85faa |
(cherry picked from commit 3b51959f48f2b40a4d85e1d36fd69a46548369cb)
|
|
|
a85faa |
---
|
|
|
a85faa |
src/devices/nm-device.c | 28 +++++++++++++++++++++++++---
|
|
|
a85faa |
1 file changed, 25 insertions(+), 3 deletions(-)
|
|
|
a85faa |
|
|
|
a85faa |
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
|
|
|
a85faa |
index 305a1bb..6939332 100644
|
|
|
a85faa |
--- a/src/devices/nm-device.c
|
|
|
a85faa |
+++ b/src/devices/nm-device.c
|
|
|
a85faa |
@@ -11774,6 +11774,7 @@ _hw_addr_set (NMDevice *self,
|
|
|
a85faa |
{
|
|
|
a85faa |
NMDevicePrivate *priv;
|
|
|
a85faa |
gboolean success = FALSE;
|
|
|
a85faa |
+ gboolean needs_refresh = FALSE;
|
|
|
a85faa |
NMPlatformError plerr;
|
|
|
a85faa |
const char *cur_addr;
|
|
|
a85faa |
guint8 addr_bytes[NM_UTILS_HWADDR_LEN_MAX];
|
|
|
a85faa |
@@ -11819,10 +11820,10 @@ _hw_addr_set (NMDevice *self,
|
|
|
a85faa |
_LOGI (LOGD_DEVICE, "set-hw-addr: %s MAC address to %s (%s)",
|
|
|
a85faa |
operation, addr, detail);
|
|
|
a85faa |
} else {
|
|
|
a85faa |
- _LOGW (LOGD_DEVICE,
|
|
|
a85faa |
- "set-hw-addr: new MAC address %s not successfully %s (%s)",
|
|
|
a85faa |
+ _LOGD (LOGD_DEVICE,
|
|
|
a85faa |
+ "set-hw-addr: new MAC address %s not successfully %s (%s) (refresh link)",
|
|
|
a85faa |
addr, operation, detail);
|
|
|
a85faa |
- success = FALSE;
|
|
|
a85faa |
+ needs_refresh = TRUE;
|
|
|
a85faa |
}
|
|
|
a85faa |
} else {
|
|
|
a85faa |
_NMLOG (plerr == NM_PLATFORM_ERROR_NOT_FOUND ? LOGL_DEBUG : LOGL_WARN,
|
|
|
a85faa |
@@ -11836,6 +11837,27 @@ _hw_addr_set (NMDevice *self,
|
|
|
a85faa |
return FALSE;
|
|
|
a85faa |
}
|
|
|
a85faa |
|
|
|
a85faa |
+ if (needs_refresh) {
|
|
|
a85faa |
+ /* The platform call indicated success, however the address is not
|
|
|
a85faa |
+ * as expected. May be a kernel issue and the MAC address takes
|
|
|
a85faa |
+ * a moment to change (bgo#770456).
|
|
|
a85faa |
+ *
|
|
|
a85faa |
+ * Try to reload the link and check again. */
|
|
|
a85faa |
+ nm_platform_link_refresh (NM_PLATFORM_GET, nm_device_get_ip_ifindex (self));
|
|
|
a85faa |
+
|
|
|
a85faa |
+ nm_device_update_hw_address (self);
|
|
|
a85faa |
+ cur_addr = nm_device_get_hw_address (self);
|
|
|
a85faa |
+ if (cur_addr && nm_utils_hwaddr_matches (cur_addr, -1, addr, -1)) {
|
|
|
a85faa |
+ _LOGI (LOGD_DEVICE, "set-hw-addr: %s MAC address to %s (%s)",
|
|
|
a85faa |
+ operation, addr, detail);
|
|
|
a85faa |
+ } else {
|
|
|
a85faa |
+ _LOGW (LOGD_DEVICE,
|
|
|
a85faa |
+ "set-hw-addr: new MAC address %s not successfully %s (%s)",
|
|
|
a85faa |
+ addr, operation, detail);
|
|
|
a85faa |
+ return FALSE;
|
|
|
a85faa |
+ }
|
|
|
a85faa |
+ }
|
|
|
a85faa |
+
|
|
|
a85faa |
return success;
|
|
|
a85faa |
}
|
|
|
a85faa |
|
|
|
a85faa |
--
|
|
|
a85faa |
2.7.4
|
|
|
a85faa |
|
|
|
a85faa |
|
|
|
a85faa |
From fb4ca54a6dc66ca14e5c085cdb390959ebbc861e Mon Sep 17 00:00:00 2001
|
|
|
a85faa |
From: Lubomir Rintel <lkundrak@v3.sk>
|
|
|
a85faa |
Date: Tue, 30 Aug 2016 15:05:39 +0200
|
|
|
a85faa |
Subject: [PATCH 5/6] platform: fix build
|
|
|
a85faa |
|
|
|
a85faa |
Fixes: 471521ca84187cd32afcd20aebe5a369fe7368dc
|
|
|
a85faa |
(cherry picked from commit 02fb3eff481f79d3caa67fdde20b2ae7aa5e640b)
|
|
|
a85faa |
(cherry picked from commit 4cf61eeafd62f7c0ac9cd71b8526577d1262e152)
|
|
|
a85faa |
---
|
|
|
a85faa |
src/platform/nm-linux-platform.c | 4 ++--
|
|
|
a85faa |
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
|
a85faa |
|
|
|
a85faa |
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c
|
|
|
a85faa |
index c36e967..e3ab5e6 100644
|
|
|
a85faa |
--- a/src/platform/nm-linux-platform.c
|
|
|
a85faa |
+++ b/src/platform/nm-linux-platform.c
|
|
|
a85faa |
@@ -4070,7 +4070,7 @@ do_change_link_request (NMPlatform *platform,
|
|
|
a85faa |
int nle;
|
|
|
a85faa |
|
|
|
a85faa |
if (!nm_platform_netns_push (platform, &netns))
|
|
|
a85faa |
- return NM_PLATFORM_ERROR_UNSPECIFIED;
|
|
|
a85faa |
+ return seq_result;
|
|
|
a85faa |
|
|
|
a85faa |
retry:
|
|
|
a85faa |
nle = _nl_send_auto_with_seq (platform, nlmsg, &seq_result, NULL);
|
|
|
a85faa |
@@ -4078,7 +4078,7 @@ retry:
|
|
|
a85faa |
_LOGE ("do-change-link[%d]: failure sending netlink request \"%s\" (%d)",
|
|
|
a85faa |
ifindex,
|
|
|
a85faa |
nl_geterror (nle), -nle);
|
|
|
a85faa |
- return NM_PLATFORM_ERROR_UNSPECIFIED;
|
|
|
a85faa |
+ return seq_result;
|
|
|
a85faa |
}
|
|
|
a85faa |
|
|
|
a85faa |
/* always refetch the link after changing it. There seems to be issues
|
|
|
a85faa |
--
|
|
|
a85faa |
2.7.4
|
|
|
a85faa |
|
|
|
a85faa |
|
|
|
a85faa |
From 395a0fb95d59a384dbe26cb727db5fe4212bc598 Mon Sep 17 00:00:00 2001
|
|
|
a85faa |
From: Thomas Haller <thaller@redhat.com>
|
|
|
a85faa |
Date: Tue, 30 Aug 2016 16:20:40 +0200
|
|
|
a85faa |
Subject: [PATCH 6/6] platform: fix return value for error case in
|
|
|
a85faa |
do_change_link_request()
|
|
|
a85faa |
|
|
|
a85faa |
There is a "goto retry" in do_change_link_request(), at that point,
|
|
|
a85faa |
seq_result has the value -EOPNOTSUPP, instead of
|
|
|
a85faa |
WAIT_FOR_NL_RESPONSE_RESULT_UNKNOWN.
|
|
|
a85faa |
|
|
|
a85faa |
Fixes: 02fb3eff481f79d3caa67fdde20b2ae7aa5e640b
|
|
|
a85faa |
(cherry picked from commit 145d199589d34f8844d8e9cafc3c2c2ea8ec4d53)
|
|
|
a85faa |
(cherry picked from commit 89d68b1a96b382f692e61b57239baae504e62d04)
|
|
|
a85faa |
---
|
|
|
a85faa |
src/platform/nm-linux-platform.c | 4 ++--
|
|
|
a85faa |
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
|
a85faa |
|
|
|
a85faa |
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c
|
|
|
a85faa |
index e3ab5e6..070a83e 100644
|
|
|
a85faa |
--- a/src/platform/nm-linux-platform.c
|
|
|
a85faa |
+++ b/src/platform/nm-linux-platform.c
|
|
|
a85faa |
@@ -4070,7 +4070,7 @@ do_change_link_request (NMPlatform *platform,
|
|
|
a85faa |
int nle;
|
|
|
a85faa |
|
|
|
a85faa |
if (!nm_platform_netns_push (platform, &netns))
|
|
|
a85faa |
- return seq_result;
|
|
|
a85faa |
+ return WAIT_FOR_NL_RESPONSE_RESULT_UNKNOWN;
|
|
|
a85faa |
|
|
|
a85faa |
retry:
|
|
|
a85faa |
nle = _nl_send_auto_with_seq (platform, nlmsg, &seq_result, NULL);
|
|
|
a85faa |
@@ -4078,7 +4078,7 @@ retry:
|
|
|
a85faa |
_LOGE ("do-change-link[%d]: failure sending netlink request \"%s\" (%d)",
|
|
|
a85faa |
ifindex,
|
|
|
a85faa |
nl_geterror (nle), -nle);
|
|
|
a85faa |
- return seq_result;
|
|
|
a85faa |
+ return WAIT_FOR_NL_RESPONSE_RESULT_UNKNOWN;
|
|
|
a85faa |
}
|
|
|
a85faa |
|
|
|
a85faa |
/* always refetch the link after changing it. There seems to be issues
|
|
|
a85faa |
--
|
|
|
a85faa |
2.7.4
|
|
|
a85faa |
|