summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-10-25 15:27:57 +0200
committerThomas Haller <thaller@redhat.com>2016-11-03 12:24:02 +0100
commit9f51a93d973e673ff5a6ee286cef1b7347f09767 (patch)
treed760b9e96bc9d95003fa6e64c6c22150f2c718f7
parent38b6f36edcc1d908863f66fd20dd79f1ef084f91 (diff)
downloadNetworkManager-9f51a93d973e673ff5a6ee286cef1b7347f09767.tar.gz
device: delay evaluating unmanaged-by-user-settings flags until link initialized
Before the link is initialized, that is before UDEV completed initializing the device, we should not evaluate the user-settings unmanaged flags. The reason is, that evaluating it likely involves looking at the permanent MAC address, which might use the wrong fake MAC address (before UDEV set the right one). Also, it might use the wrong ifname to lookup the permanent MAC address via ethtool. (cherry picked from commit c0d249b733325046ca192d112d468b86aac54ba4)
-rw-r--r--src/devices/nm-device.c39
-rw-r--r--src/devices/nm-device.h2
-rw-r--r--src/nm-manager.c15
3 files changed, 40 insertions, 16 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 0aee6fbf65..7b7dd4d435 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -1833,7 +1833,7 @@ device_link_changed (NMDevice *self)
ip_ifname_changed = !priv->ip_iface;
if (nm_device_get_unmanaged_flags (self, NM_UNMANAGED_PLATFORM_INIT))
- nm_device_set_unmanaged_by_user_settings (self, nm_settings_get_unmanaged_specs (priv->settings));
+ nm_device_set_unmanaged_by_user_settings (self);
else
update_unmanaged_specs = TRUE;
@@ -1912,7 +1912,7 @@ device_link_changed (NMDevice *self)
}
if (update_unmanaged_specs)
- nm_device_set_unmanaged_by_user_settings (self, nm_settings_get_unmanaged_specs (priv->settings));
+ nm_device_set_unmanaged_by_user_settings (self);
if ( got_hw_addr
&& !priv->up
@@ -9868,6 +9868,21 @@ _set_unmanaged_flags (NMDevice *self,
allow_state_transition = FALSE;
was_managed = allow_state_transition && nm_device_get_managed (self, FALSE);
+ if ( NM_FLAGS_HAS (priv->unmanaged_flags, NM_UNMANAGED_PLATFORM_INIT)
+ && NM_FLAGS_HAS (flags, NM_UNMANAGED_PLATFORM_INIT)
+ && NM_IN_SET (set_op, NM_UNMAN_FLAG_OP_SET_MANAGED)) {
+ /* we are clearing the platform-init flags. This triggers additional actions. */
+ if (!NM_FLAGS_HAS (flags, NM_UNMANAGED_USER_SETTINGS)) {
+ gboolean unmanaged;
+
+ unmanaged = nm_device_spec_match_list (self,
+ nm_settings_get_unmanaged_specs (NM_DEVICE_GET_PRIVATE (self)->settings));
+ nm_device_set_unmanaged_flags (self,
+ NM_UNMANAGED_USER_SETTINGS,
+ !!unmanaged);
+ }
+ }
+
old_flags = priv->unmanaged_flags;
old_mask = priv->unmanaged_mask;
@@ -9982,20 +9997,30 @@ nm_device_set_unmanaged_by_flags_queue (NMDevice *self,
}
void
-nm_device_set_unmanaged_by_user_settings (NMDevice *self, const GSList *unmanaged_specs)
+nm_device_set_unmanaged_by_user_settings (NMDevice *self)
{
- NMDevicePrivate *priv;
gboolean unmanaged;
g_return_if_fail (NM_IS_DEVICE (self));
- priv = NM_DEVICE_GET_PRIVATE (self);
+ if (nm_device_get_unmanaged_flags (self, NM_UNMANAGED_PLATFORM_INIT)) {
+ /* the device is already unmanaged due to platform-init.
+ *
+ * We want to delay evaluating the device spec, because it will freeze
+ * the permanent MAC address. That should not be done, before the platform
+ * link is fully initialized (via UDEV).
+ *
+ * Note that when clearing NM_UNMANAGED_PLATFORM_INIT, we will re-evaluate
+ * whether the device is unmanaged by user-settings. */
+ return;
+ }
- unmanaged = nm_device_spec_match_list (self, unmanaged_specs);
+ unmanaged = nm_device_spec_match_list (self,
+ nm_settings_get_unmanaged_specs (NM_DEVICE_GET_PRIVATE (self)->settings));
nm_device_set_unmanaged_by_flags (self,
NM_UNMANAGED_USER_SETTINGS,
- unmanaged,
+ !!unmanaged,
unmanaged
? NM_DEVICE_STATE_REASON_NOW_UNMANAGED
: NM_DEVICE_STATE_REASON_NOW_MANAGED);
diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h
index 90443749ec..f90444cd07 100644
--- a/src/devices/nm-device.h
+++ b/src/devices/nm-device.h
@@ -509,7 +509,7 @@ void nm_device_set_unmanaged_by_flags_queue (NMDevice *self,
NMUnmanagedFlags flags,
NMUnmanFlagOp set_op,
NMDeviceStateReason reason);
-void nm_device_set_unmanaged_by_user_settings (NMDevice *self, const GSList *unmanaged_specs);
+void nm_device_set_unmanaged_by_user_settings (NMDevice *self);
void nm_device_set_unmanaged_by_user_udev (NMDevice *self);
void nm_device_set_unmanaged_by_quitting (NMDevice *device);
diff --git a/src/nm-manager.c b/src/nm-manager.c
index 722a4b7daa..94781cd0c5 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -1320,11 +1320,10 @@ system_unmanaged_devices_changed_cb (NMSettings *settings,
{
NMManager *self = NM_MANAGER (user_data);
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
- const GSList *unmanaged_specs, *iter;
+ const GSList *iter;
- unmanaged_specs = nm_settings_get_unmanaged_specs (priv->settings);
for (iter = priv->devices; iter; iter = g_slist_next (iter))
- nm_device_set_unmanaged_by_user_settings (NM_DEVICE (iter->data), unmanaged_specs);
+ nm_device_set_unmanaged_by_user_settings (NM_DEVICE (iter->data));
}
static void
@@ -1993,7 +1992,7 @@ add_device (NMManager *self, NMDevice *device, GError **error)
type_desc = nm_device_get_type_desc (device);
g_assert (type_desc);
- nm_device_set_unmanaged_by_user_settings (device, nm_settings_get_unmanaged_specs (priv->settings));
+ nm_device_set_unmanaged_by_user_settings (device);
nm_device_set_unmanaged_flags (device,
NM_UNMANAGED_SLEEPING,
@@ -2812,15 +2811,15 @@ unmanaged_to_disconnected (NMDevice *device)
if (nm_device_get_state (device) == NM_DEVICE_STATE_UNMANAGED) {
nm_device_state_changed (device,
- NM_DEVICE_STATE_UNAVAILABLE,
- NM_DEVICE_STATE_REASON_USER_REQUESTED);
+ NM_DEVICE_STATE_UNAVAILABLE,
+ NM_DEVICE_STATE_REASON_USER_REQUESTED);
}
if ( nm_device_is_available (device, NM_DEVICE_CHECK_DEV_AVAILABLE_FOR_USER_REQUEST)
&& (nm_device_get_state (device) == NM_DEVICE_STATE_UNAVAILABLE)) {
nm_device_state_changed (device,
- NM_DEVICE_STATE_DISCONNECTED,
- NM_DEVICE_STATE_REASON_USER_REQUESTED);
+ NM_DEVICE_STATE_DISCONNECTED,
+ NM_DEVICE_STATE_REASON_USER_REQUESTED);
}
}