summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-06-07 22:11:50 +0200
committerThomas Haller <thaller@redhat.com>2017-06-08 22:00:56 +0200
commit8e25de8ab360fc973d7222685f107b81dd872dc1 (patch)
treeac201559f0b9d8a0927d15a9f68663f53c733823
parentde1c460e586be65f5549c5d705a10888d5f1baae (diff)
downloadNetworkManager-8e25de8ab360fc973d7222685f107b81dd872dc1.tar.gz
device: only set nm-owned from statefile during initial setup
The state file should only be read initially when NM starts, that is: during NMManager's platform_query_devices(). At all later points, for example when a software device gets destroyed and re-realized, the state file is clearly no longer relevant. Hence, pass the set-nm-owned flag from NMManager to realize_start_setup(). This is very much the same as with the NM_UNMANAGED_FLAG_USER_EXPLICT flag, which we also read from the state-file. (cherry picked from commit d83848be9dfd0edb5f318b81854b371133d84f6e)
-rw-r--r--src/devices/nm-device.c22
-rw-r--r--src/devices/nm-device.h1
-rw-r--r--src/nm-manager.c3
3 files changed, 15 insertions, 11 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index debe3fd705..d9bdfb069f 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -527,6 +527,7 @@ static gboolean dhcp6_start (NMDevice *self, gboolean wait_for_ll);
static void nm_device_start_ip_check (NMDevice *self);
static void realize_start_setup (NMDevice *self,
const NMPlatformLink *plink,
+ gboolean set_nm_owned,
NMUnmanFlagOp unmanaged_user_explicit);
static void _commit_mtu (NMDevice *self, const NMIP4Config *config);
static void dhcp_schedule_restart (NMDevice *self, int family, const char *reason);
@@ -2740,6 +2741,7 @@ link_type_compatible (NMDevice *self,
* nm_device_realize_start():
* @self: the #NMDevice
* @plink: an existing platform link or %NULL
+ * @set_nm_owned: for software device, if TRUE set nm-owned.
* @unmanaged_user_explicit: the user-explicit unmanaged flag to apply
* on the device initially.
* @out_compatible: %TRUE on return if @self is compatible with @plink
@@ -2757,6 +2759,7 @@ link_type_compatible (NMDevice *self,
gboolean
nm_device_realize_start (NMDevice *self,
const NMPlatformLink *plink,
+ gboolean set_nm_owned,
NMUnmanFlagOp unmanaged_user_explicit,
gboolean *out_compatible,
GError **error)
@@ -2781,7 +2784,7 @@ nm_device_realize_start (NMDevice *self,
plink_copy = *plink;
plink = &plink_copy;
}
- realize_start_setup (self, plink, unmanaged_user_explicit);
+ realize_start_setup (self, plink, set_nm_owned, unmanaged_user_explicit);
return TRUE;
}
@@ -2821,7 +2824,7 @@ nm_device_create_and_realize (NMDevice *self,
plink = &plink_copy;
}
- realize_start_setup (self, plink, NM_UNMAN_FLAG_OP_FORGET);
+ realize_start_setup (self, plink, FALSE, NM_UNMAN_FLAG_OP_FORGET);
nm_device_realize_finish (self, plink);
if (nm_device_get_managed (self, FALSE)) {
@@ -2917,6 +2920,8 @@ realize_start_notify (NMDevice *self,
* realize_start_setup():
* @self: the #NMDevice
* @plink: the #NMPlatformLink if backed by a kernel netdevice
+ * @set_nm_owned: if TRUE and device is a software-device, set nm-owned.
+ * TRUE.
* @unmanaged_user_explicit: the user-explict unmanaged flag to set.
*
* Update the device from backing resource properties (like hardware
@@ -2928,6 +2933,7 @@ realize_start_notify (NMDevice *self,
static void
realize_start_setup (NMDevice *self,
const NMPlatformLink *plink,
+ gboolean set_nm_owned,
NMUnmanFlagOp unmanaged_user_explicit)
{
NMDevicePrivate *priv;
@@ -3011,17 +3017,11 @@ realize_start_setup (NMDevice *self,
_add_capabilities (self, capabilities);
- /* Update nm-owned flag according to state file */
if ( !priv->nm_owned
- && priv->ifindex > 0
+ && set_nm_owned
&& nm_device_is_software (self)) {
- gs_free NMConfigDeviceStateData *dev_state = NULL;
-
- dev_state = nm_config_device_state_load (priv->ifindex);
- if (dev_state && dev_state->nm_owned == TRUE) {
- priv->nm_owned = TRUE;
- _LOGD (LOGD_DEVICE, "set nm-owned from state file");
- }
+ priv->nm_owned = TRUE;
+ _LOGD (LOGD_DEVICE, "set nm-owned from state file");
}
if (!priv->udi) {
diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h
index 27f5018c74..74cc2303c8 100644
--- a/src/devices/nm-device.h
+++ b/src/devices/nm-device.h
@@ -611,6 +611,7 @@ gboolean nm_device_has_capability (NMDevice *self, NMDeviceCapabilities caps);
gboolean nm_device_realize_start (NMDevice *device,
const NMPlatformLink *plink,
+ gboolean set_nm_owned,
NMUnmanFlagOp unmanaged_user_explicit,
gboolean *out_compatible,
GError **error);
diff --git a/src/nm-manager.c b/src/nm-manager.c
index 67b3238b3e..acf1b2a0ce 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -2215,6 +2215,7 @@ factory_device_added_cb (NMDeviceFactory *factory,
if (nm_device_realize_start (device,
NULL,
+ FALSE,
NM_UNMAN_FLAG_OP_FORGET,
NULL,
&error)) {
@@ -2293,6 +2294,7 @@ platform_link_added (NMManager *self,
return;
} else if (nm_device_realize_start (candidate,
plink,
+ FALSE,
NM_UNMAN_FLAG_OP_FORGET,
&compatible,
&error)) {
@@ -2364,6 +2366,7 @@ platform_link_added (NMManager *self,
if (nm_device_realize_start (device,
plink,
+ dev_state ? (dev_state->nm_owned == 1) : FALSE,
unmanaged_user_explicit,
NULL,
&error)) {