summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2014-10-13 15:10:20 -0500
committerDan Williams <dcbw@redhat.com>2014-10-17 15:51:03 -0500
commitaab7fbfc4677d2120386839b6560e7ab33c8da98 (patch)
tree0927b09440d6c3e19027b6ce201a6fb9f58db252
parent755fa19e5db48f224abad310d4ac7fce34047ca2 (diff)
downloadNetworkManager-aab7fbfc4677d2120386839b6560e7ab33c8da98.tar.gz
core: ensure interface is up before applying IP configuration (bgo #738479)
Routing configuration fails to apply if the device is not IFF_UP, so if we're going to apply IP configuration to the device, make sure it's IFF_UP first. https://bugzilla.gnome.org/show_bug.cgi?id=738479 (cherry picked from commit 44900a1584dd25fccccd7e63ba7b07777e2d519a)
-rw-r--r--src/devices/nm-device.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 2a5a9c26f7..ec4a7c9c2e 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -4550,6 +4550,7 @@ nm_device_activate_ip4_config_commit (gpointer user_data)
const char *iface, *method;
NMConnection *connection;
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
+ int ip_ifindex;
/* Clear the activation source ID now that this stage has run */
activation_source_clear (self, FALSE, AF_INET);
@@ -4563,10 +4564,14 @@ nm_device_activate_ip4_config_commit (gpointer user_data)
connection = nm_act_request_get_connection (req);
g_assert (connection);
- /* Device should be up before we can do anything with it */
- if (!nm_platform_link_is_up (nm_device_get_ip_ifindex (self))) {
- nm_log_warn (LOGD_DEVICE, "(%s): interface %s not up for IP configuration",
- iface, nm_device_get_ip_iface (self));
+ /* Interface must be IFF_UP before IP config can be applied */
+ ip_ifindex = nm_device_get_ip_ifindex (self);
+ if (!nm_platform_link_is_up (ip_ifindex)) {
+ nm_platform_link_set_up (ip_ifindex);
+ if (!nm_platform_link_is_up (ip_ifindex)) {
+ nm_log_warn (LOGD_DEVICE, "(%s): interface %s not up for IP configuration",
+ iface, nm_device_get_ip_iface (self));
+ }
}
/* NULL to use the existing priv->dev_ip4_config */
@@ -4664,6 +4669,7 @@ nm_device_activate_ip6_config_commit (gpointer user_data)
const char *iface;
NMConnection *connection;
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
+ int ip_ifindex;
/* Clear the activation source ID now that this stage has run */
activation_source_clear (self, FALSE, AF_INET6);
@@ -4676,8 +4682,15 @@ nm_device_activate_ip6_config_commit (gpointer user_data)
connection = nm_act_request_get_connection (req);
g_assert (connection);
- /* Device should be up before we can do anything with it */
- g_warn_if_fail (nm_platform_link_is_up (nm_device_get_ip_ifindex (self)));
+ /* Interface must be IFF_UP before IP config can be applied */
+ ip_ifindex = nm_device_get_ip_ifindex (self);
+ if (!nm_platform_link_is_up (ip_ifindex)) {
+ nm_platform_link_set_up (ip_ifindex);
+ if (!nm_platform_link_is_up (ip_ifindex)) {
+ nm_log_warn (LOGD_DEVICE, "(%s): interface %s not up for IP configuration",
+ iface, nm_device_get_ip_iface (self));
+ }
+ }
/* Allow setting MTU etc */
if (NM_DEVICE_GET_CLASS (self)->ip6_config_pre_commit)