diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2019-04-12 10:35:09 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2019-04-12 10:35:09 +0200 |
commit | 246c2dbe9a104efc3703093103401e0cd278ff5b (patch) | |
tree | 41858b277409f83d4ca254e9693a1fe55ffdf222 | |
parent | 7b6a3aaf291b0757778fd2683cdb25adafed922e (diff) | |
parent | c0d5b58332840939f93bb5d4053422dbd42ec4f7 (diff) | |
download | NetworkManager-246c2dbe9a104efc3703093103401e0cd278ff5b.tar.gz |
merge: branch 'bg/unmanaged-sw-dev-rh1679230'
https://bugzilla.redhat.com/show_bug.cgi?id=1679230
https://github.com/NetworkManager/NetworkManager/pull/340
-rw-r--r-- | src/devices/nm-device.c | 36 | ||||
-rw-r--r-- | src/devices/nm-device.h | 2 | ||||
-rw-r--r-- | src/nm-manager.c | 7 |
3 files changed, 43 insertions, 2 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 06ad2ce821..957455204c 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -5315,7 +5315,8 @@ nm_device_autoconnect_allowed (NMDevice *self) if (priv->state < NM_DEVICE_STATE_DISCONNECTED) return FALSE; } else { - /* Unrealized devices can always autoconnect. */ + if (!nm_device_check_unrealized_device_managed (self)) + return FALSE; } /* The 'autoconnect-allowed' signal is emitted on a device to allow @@ -13517,6 +13518,32 @@ nm_device_set_unmanaged_by_flags_queue (NMDevice *self, _set_unmanaged_flags (self, flags, set_op, TRUE, FALSE, reason); } +/** + * nm_device_check_unrealized_device_managed: + * + * Checks if a unrealized device is managed from user settings + * or user configuration. + */ +gboolean +nm_device_check_unrealized_device_managed (NMDevice *self) +{ + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); + + nm_assert (!nm_device_is_real (self)); + + if (!nm_config_data_get_device_config_boolean (NM_CONFIG_GET_DATA, + NM_CONFIG_KEYFILE_KEY_DEVICE_MANAGED, + self, + TRUE, + TRUE)) + return FALSE; + + if (nm_device_spec_match_list (self, nm_settings_get_unmanaged_specs (priv->settings))) + return FALSE; + + return TRUE; +} + void nm_device_set_unmanaged_by_user_settings (NMDevice *self) { @@ -15977,17 +16004,22 @@ nm_device_spec_match_list_full (NMDevice *self, const GSList *specs, int no_matc { NMDeviceClass *klass; NMMatchSpecMatchType m; + const char *hw_address = NULL; + gboolean is_fake; g_return_val_if_fail (NM_IS_DEVICE (self), FALSE); klass = NM_DEVICE_GET_CLASS (self); + hw_address = nm_device_get_permanent_hw_address_full (self, + !nm_device_get_unmanaged_flags (self, NM_UNMANAGED_PLATFORM_INIT), + &is_fake); m = nm_match_spec_device (specs, nm_device_get_iface (self), nm_device_get_type_description (self), nm_device_get_driver (self), nm_device_get_driver_version (self), - nm_device_get_permanent_hw_address (self), + is_fake ? NULL : hw_address, klass->get_s390_subchannels ? klass->get_s390_subchannels (self) : NULL, nm_dhcp_manager_get_config (nm_dhcp_manager_get ())); diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h index 45c9dda00c..d11c33ab46 100644 --- a/src/devices/nm-device.h +++ b/src/devices/nm-device.h @@ -691,6 +691,8 @@ void nm_device_set_unmanaged_by_user_udev (NMDevice *self); void nm_device_set_unmanaged_by_user_conf (NMDevice *self); void nm_device_set_unmanaged_by_quitting (NMDevice *device); +gboolean nm_device_check_unrealized_device_managed (NMDevice *self); + gboolean nm_device_is_nm_owned (NMDevice *device); gboolean nm_device_has_capability (NMDevice *self, NMDeviceCapabilities caps); diff --git a/src/nm-manager.c b/src/nm-manager.c index d82f671a6b..1c396939ca 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -1995,6 +1995,13 @@ system_create_virtual_device (NMManager *self, NMConnection *connection) g_object_unref (device); } + if (!nm_device_check_unrealized_device_managed (device)) { + _LOG3D (LOGD_DEVICE, connection, + "skip activation because virtual device '%s' is unmanaged", + nm_device_get_iface (device)); + return device; + } + /* Create backing resources if the device has any autoconnect connections */ connections = nm_settings_get_connections_clone (priv->settings, NULL, NULL, NULL, |