From f84b8f7afc2d5627859897deeb03c296bcdabe6c Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 26 Sep 2016 14:45:35 +0200 Subject: [PATCH] device: pass the user-explict flag to nm_device_realize_start() No change in behavior yet, because for unrealized devices the user-explict unmanaged flag is always cleared. The new option is still unused. --- src/devices/nm-device.c | 21 +++++++++++++++++---- src/devices/nm-device.h | 1 + src/nm-manager.c | 18 +++++++++++++++--- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index a1fb1322f8..ad80c2e94d 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -501,7 +501,9 @@ static gboolean ip_config_valid (NMDeviceState state); static NMActStageReturn dhcp4_start (NMDevice *self, NMConnection *connection); 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); +static void realize_start_setup (NMDevice *self, + const NMPlatformLink *plink, + 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); static void _cancel_activation (NMDevice *self); @@ -2374,6 +2376,8 @@ link_type_compatible (NMDevice *self, * nm_device_realize_start(): * @self: the #NMDevice * @plink: an existing platform link or %NULL + * @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 * @error: location to store error, or %NULL * @@ -2389,6 +2393,7 @@ link_type_compatible (NMDevice *self, gboolean nm_device_realize_start (NMDevice *self, const NMPlatformLink *plink, + NMUnmanFlagOp unmanaged_user_explicit, gboolean *out_compatible, GError **error) { @@ -2412,7 +2417,7 @@ nm_device_realize_start (NMDevice *self, plink_copy = *plink; plink = &plink_copy; } - realize_start_setup (self, plink); + realize_start_setup (self, plink, unmanaged_user_explicit); return TRUE; } @@ -2452,7 +2457,7 @@ nm_device_create_and_realize (NMDevice *self, plink = &plink_copy; } - realize_start_setup (self, plink); + realize_start_setup (self, plink, NM_UNMAN_FLAG_OP_FORGET); nm_device_realize_finish (self, plink); if (nm_device_get_managed (self, FALSE)) { @@ -2533,6 +2538,7 @@ realize_start_notify (NMDevice *self, * realize_start_setup(): * @self: the #NMDevice * @plink: the #NMPlatformLink if backed by a kernel netdevice + * @unmanaged_user_explicit: the user-explict unmanaged flag to set. * * Update the device from backing resource properties (like hardware * addresses, carrier states, driver/firmware info, etc). This function @@ -2541,7 +2547,9 @@ realize_start_notify (NMDevice *self, * stuff). */ static void -realize_start_setup (NMDevice *self, const NMPlatformLink *plink) +realize_start_setup (NMDevice *self, + const NMPlatformLink *plink, + NMUnmanFlagOp unmanaged_user_explicit) { NMDevicePrivate *priv; NMDeviceClass *klass; @@ -2662,6 +2670,11 @@ realize_start_setup (NMDevice *self, const NMPlatformLink *plink) klass->realize_start_notify (self, plink); + nm_assert (!nm_device_get_unmanaged_mask (self, NM_UNMANAGED_USER_EXPLICIT)); + nm_device_set_unmanaged_flags (self, + NM_UNMANAGED_USER_EXPLICIT, + unmanaged_user_explicit); + /* Do not manage externally created software devices until they are IFF_UP * or have IP addressing */ nm_device_set_unmanaged_flags (self, diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h index f98978bdc0..0814ddc089 100644 --- a/src/devices/nm-device.h +++ b/src/devices/nm-device.h @@ -595,6 +595,7 @@ gboolean nm_device_has_capability (NMDevice *self, NMDeviceCapabilities caps); gboolean nm_device_realize_start (NMDevice *device, const NMPlatformLink *plink, + NMUnmanFlagOp unmanaged_user_explicit, gboolean *out_compatible, GError **error); void nm_device_realize_finish (NMDevice *self, diff --git a/src/nm-manager.c b/src/nm-manager.c index 4430cb4ccf..2171260240 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -2133,7 +2133,11 @@ factory_device_added_cb (NMDeviceFactory *factory, g_return_if_fail (NM_IS_MANAGER (self)); - if (nm_device_realize_start (device, NULL, NULL, &error)) { + if (nm_device_realize_start (device, + NULL, + NM_UNMAN_FLAG_OP_FORGET, + NULL, + &error)) { add_device (self, device, NULL); _device_realize_finish (self, device, NULL); } else { @@ -2206,7 +2210,11 @@ platform_link_added (NMManager *self, * device with the link's name. */ return; - } else if (nm_device_realize_start (candidate, plink, &compatible, &error)) { + } else if (nm_device_realize_start (candidate, + plink, + NM_UNMAN_FLAG_OP_FORGET, + &compatible, + &error)) { /* Success */ _device_realize_finish (self, candidate, plink); return; @@ -2259,7 +2267,11 @@ platform_link_added (NMManager *self, if (device) { gs_free_error GError *error = NULL; - if (nm_device_realize_start (device, plink, NULL, &error)) { + if (nm_device_realize_start (device, + plink, + NM_UNMAN_FLAG_OP_FORGET, + NULL, + &error)) { add_device (self, device, NULL); _device_realize_finish (self, device, plink); } else {