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 21:44:22 +0200
commitd83848be9dfd0edb5f318b81854b371133d84f6e (patch)
treefbe272c6976c0844752d9e152955ebf63db6b806
parentc66995ad4ddbe44cbbb4d4d56a48420be6d483cf (diff)
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.
-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 f26c85764..7dbdd4f88 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);
@@ -2741,6 +2742,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
@@ -2758,6 +2760,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)
@@ -2782,7 +2785,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;
}
@@ -2822,7 +2825,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)) {
@@ -2918,6 +2921,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
@@ -2929,6 +2934,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;
@@ -3012,17 +3018,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 8c099508b..b60a3ece5 100644
--- a/src/devices/nm-device.h
+++ b/src/devices/nm-device.h
@@ -612,6 +612,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 8d1bf320f..b13ad35c1 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -2198,6 +2198,7 @@ factory_device_added_cb (NMDeviceFactory *factory,
if (nm_device_realize_start (device,
NULL,
+ FALSE,
NM_UNMAN_FLAG_OP_FORGET,
NULL,
&error)) {
@@ -2276,6 +2277,7 @@ platform_link_added (NMManager *self,
return;
} else if (nm_device_realize_start (candidate,
plink,
+ FALSE,
NM_UNMAN_FLAG_OP_FORGET,
&compatible,
&error)) {
@@ -2347,6 +2349,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)) {