diff options
author | Thomas Haller <thaller@redhat.com> | 2016-01-07 22:16:29 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2016-01-08 16:25:06 +0100 |
commit | 0fb6c20fac7e7c46d595c245f74863a0662ae553 (patch) | |
tree | 50e29b972055200f16e8e2fa26c213d2ae1833a5 | |
parent | 377a2dd7e514af9b2d01a03302a6a9135fe53825 (diff) | |
download | NetworkManager-0fb6c20fac7e7c46d595c245f74863a0662ae553.tar.gz |
fixup! device: remove default-unmanaged and refactor unamanged flagslr/default-unmanaged-bgo746566-4
Refactor setting user-udev unmanaged flag.
-rw-r--r-- | src/devices/nm-device.c | 36 | ||||
-rw-r--r-- | src/devices/nm-device.h | 1 |
2 files changed, 23 insertions, 14 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 8d99c560b1..cde856181a 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -1192,12 +1192,9 @@ nm_device_finish_init (NMDevice *self) * Later we might want to manage 'lo' too. Currently that doesn't work because * NetworkManager might down the interface or remove the 127.0.0.1 address. */ nm_device_set_unmanaged_flags_initial (self, NM_UNMANAGED_LOOPBACK, TRUE); - } else if (priv->platform_link_initialized || (priv->is_nm_owned && nm_device_is_software (self))) { - gboolean platform_unmanaged = FALSE; - - if (nm_platform_link_get_unmanaged (NM_PLATFORM_GET, priv->ifindex, &platform_unmanaged)) - nm_device_set_unmanaged_flags_initial (self, NM_UNMANAGED_USER_UDEV, platform_unmanaged); - } else { + } else if (priv->platform_link_initialized || (priv->is_nm_owned && nm_device_is_software (self))) + nm_device_set_unmanaged_flags_user_udev (self, TRUE); + else { /* Hardware and externally-created software links stay unmanaged * until they are fully initialized by the platform. NM created * links must be available for activation immediately and thus @@ -1514,16 +1511,9 @@ device_link_changed (NMDevice *self) update_dynamic_ip_setup (self); if (priv->ifindex > 0 && !priv->platform_link_initialized && info.initialized) { - gboolean platform_unmanaged = FALSE; - priv->platform_link_initialized = TRUE; - if (nm_platform_link_get_unmanaged (NM_PLATFORM_GET, priv->ifindex, &platform_unmanaged)) { - nm_device_set_unmanaged_flags (self, - NM_UNMANAGED_USER_UDEV, - platform_unmanaged, - NM_DEVICE_STATE_REASON_USER_REQUESTED); - } + nm_device_set_unmanaged_flags_user_udev (self, FALSE); nm_device_set_unmanaged_flags (self, NM_UNMANAGED_PLATFORM_INIT, @@ -8478,6 +8468,24 @@ nm_device_set_unmanaged_flags_by_device_spec (NMDevice *self, const GSList *unma : NM_DEVICE_STATE_REASON_NOW_MANAGED); } +void +nm_device_set_unmanaged_flags_user_udev (NMDevice *self, gboolean initial) +{ + int ifindex; + gboolean platform_unmanaged = FALSE; + + ifindex = self->priv->ifindex; + + if ( ifindex <= 0 + || !nm_platform_link_get_unmanaged (NM_PLATFORM_GET, ifindex, &platform_unmanaged)) + return; + + if (initial) + nm_device_set_unmanaged_flags_initial (self, NM_UNMANAGED_USER_UDEV, platform_unmanaged); + else + nm_device_set_unmanaged_flags (self, NM_UNMANAGED_USER_UDEV, platform_unmanaged, NM_DEVICE_STATE_REASON_USER_REQUESTED); +} + /** * nm_device_set_unmanaged_flags_initial(): * @self: the #NMDevice diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h index e4732cfc1d..f8c6116f85 100644 --- a/src/devices/nm-device.h +++ b/src/devices/nm-device.h @@ -507,6 +507,7 @@ void nm_device_set_unmanaged_flags (NMDevice *device, gboolean unmanaged, NMDeviceStateReason reason); void nm_device_set_unmanaged_flags_by_device_spec (NMDevice *self, const GSList *unmanaged_specs); +void nm_device_set_unmanaged_flags_user_udev (NMDevice *self, gboolean initial); void nm_device_set_unmanaged_flags_initial (NMDevice *device, NMUnmanagedFlags flag, gboolean unmanaged); |