From bd372bab2f5d57cbcbec7b00211ae62516103918 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Mon, 13 May 2019 14:28:52 +0200 Subject: [PATCH 1/3] device: use variable for platform in realize_start_setup() (cherry picked from commit 831f079e55590b03b8b980290b8ddddf28feba66) --- src/devices/nm-device.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 09ba9c5d57..aa600d9803 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -4261,6 +4261,7 @@ realize_start_setup (NMDevice *self, { NMDevicePrivate *priv; NMDeviceClass *klass; + NMPlatform *platform; static guint32 id = 0; NMDeviceCapabilities capabilities = 0; NMConfig *config; @@ -4285,6 +4286,7 @@ realize_start_setup (NMDevice *self, _LOGD (LOGD_DEVICE, "start setup of %s, kernel ifindex %d", G_OBJECT_TYPE_NAME (self), plink ? plink->ifindex : 0); klass = NM_DEVICE_GET_CLASS (self); + platform = nm_device_get_platform (self); /* Balanced by a thaw in nm_device_realize_finish() */ g_object_freeze_notify (G_OBJECT (self)); @@ -4303,19 +4305,19 @@ realize_start_setup (NMDevice *self, nm_device_update_from_platform_link (self, plink); if (priv->ifindex > 0) { - priv->physical_port_id = nm_platform_link_get_physical_port_id (nm_device_get_platform (self), priv->ifindex); + priv->physical_port_id = nm_platform_link_get_physical_port_id (platform, priv->ifindex); _notify (self, PROP_PHYSICAL_PORT_ID); - priv->dev_id = nm_platform_link_get_dev_id (nm_device_get_platform (self), priv->ifindex); + priv->dev_id = nm_platform_link_get_dev_id (platform, priv->ifindex); - if (nm_platform_link_is_software (nm_device_get_platform (self), priv->ifindex)) + if (nm_platform_link_is_software (platform, priv->ifindex)) capabilities |= NM_DEVICE_CAP_IS_SOFTWARE; _set_mtu (self, - nm_platform_link_get_mtu (nm_device_get_platform (self), + nm_platform_link_get_mtu (platform, priv->ifindex)); - nm_platform_link_get_driver_info (nm_device_get_platform (self), + nm_platform_link_get_driver_info (platform, priv->ifindex, NULL, &priv->driver_version, @@ -4326,9 +4328,9 @@ realize_start_setup (NMDevice *self, _notify (self, PROP_FIRMWARE_VERSION); if (nm_platform_kernel_support_get (NM_PLATFORM_KERNEL_SUPPORT_TYPE_USER_IPV6LL)) - priv->ipv6ll_handle = nm_platform_link_get_user_ipv6ll_enabled (nm_device_get_platform (self), priv->ifindex); + priv->ipv6ll_handle = nm_platform_link_get_user_ipv6ll_enabled (platform, priv->ifindex); - if (nm_platform_link_supports_sriov (nm_device_get_platform (self), priv->ifindex)) + if (nm_platform_link_supports_sriov (platform, priv->ifindex)) capabilities |= NM_DEVICE_CAP_SRIOV; } @@ -4394,6 +4396,7 @@ realize_start_setup (NMDevice *self, nm_device_set_unmanaged_by_user_udev (self); nm_device_set_unmanaged_by_user_conf (self); + nm_device_set_unmanaged_flags (self, NM_UNMANAGED_PLATFORM_INIT, plink && !plink->initialized); } From 21ee2f50e8f5d61d29ec7af0c63cab93857d9fc7 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Mon, 13 May 2019 14:30:48 +0200 Subject: [PATCH 2/3] manager: relax condition when checking for duplicate ACs An active connection started by user could be queued in state UNKNOWN which means the device hasn't started activating yet. Eventually it will, and we don't want to cancel the user activation because of an internal autoconnection attempt. (cherry picked from commit d33c995d45caadebe2c7cc0e3e625f0d828a7a4f) --- src/nm-manager.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/nm-manager.c b/src/nm-manager.c index 512d3c1b9d..7d77144c80 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -4891,9 +4891,7 @@ _internal_activation_auth_done (NMManager *self, c_list_for_each_entry (ac, &priv->active_connections_lst_head, active_connections_lst) { if ( nm_active_connection_get_device (ac) == nm_active_connection_get_device (active) && nm_active_connection_get_settings_connection (ac) == nm_active_connection_get_settings_connection (active) - && NM_IN_SET (nm_active_connection_get_state (ac), - NM_ACTIVE_CONNECTION_STATE_ACTIVATING, - NM_ACTIVE_CONNECTION_STATE_ACTIVATED)) { + && nm_active_connection_get_state (ac) <= NM_ACTIVE_CONNECTION_STATE_ACTIVATED) { g_set_error (&error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_CONNECTION_ALREADY_ACTIVE, From 767204e315e24a296f78aab9675c5c5542587ba7 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 16 May 2019 11:29:00 +0200 Subject: [PATCH 3/3] device: don't wait udev for devices created by us If we created a software interface it is because we already decided that it should be managed, and so there is no point in waiting udev to check that the interface is not udev-unmanaged. We still wait udev for software interfaces created externally. (cherry picked from commit 58db61545d101723e7cb45dc7eadc7e4ad7a4b0c) --- src/devices/nm-device.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index aa600d9803..52cf8631b5 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -636,7 +636,8 @@ static void realize_start_setup (NMDevice *self, gboolean assume_state_guess_assume, const char *assume_state_connection_uuid, gboolean set_nm_owned, - NMUnmanFlagOp unmanaged_user_explicit); + NMUnmanFlagOp unmanaged_user_explicit, + gboolean force_platform_init); static void _set_mtu (NMDevice *self, guint32 mtu); static void _commit_mtu (NMDevice *self, const NMIP4Config *config); static void _cancel_activation (NMDevice *self); @@ -4082,7 +4083,8 @@ nm_device_realize_start (NMDevice *self, assume_state_guess_assume, assume_state_connection_uuid, set_nm_owned, - unmanaged_user_explicit); + unmanaged_user_explicit, + FALSE); return TRUE; } @@ -4127,7 +4129,8 @@ nm_device_create_and_realize (NMDevice *self, plink, FALSE, /* assume_state_guess_assume */ NULL, /* assume_state_connection_uuid */ - FALSE, NM_UNMAN_FLAG_OP_FORGET); + FALSE, NM_UNMAN_FLAG_OP_FORGET, + TRUE); nm_device_realize_finish (self, plink); if (nm_device_get_managed (self, FALSE)) { @@ -4244,6 +4247,8 @@ realize_start_notify (NMDevice *self, * @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. + * @force_platform_init: if TRUE the platform-init unmanaged flag is + * forcefully cleared. * * Update the device from backing resource properties (like hardware * addresses, carrier states, driver/firmware info, etc). This function @@ -4257,7 +4262,8 @@ realize_start_setup (NMDevice *self, gboolean assume_state_guess_assume, const char *assume_state_connection_uuid, gboolean set_nm_owned, - NMUnmanFlagOp unmanaged_user_explicit) + NMUnmanFlagOp unmanaged_user_explicit, + gboolean force_platform_init) { NMDevicePrivate *priv; NMDeviceClass *klass; @@ -4266,6 +4272,7 @@ realize_start_setup (NMDevice *self, NMDeviceCapabilities capabilities = 0; NMConfig *config; guint real_rate; + gboolean unmanaged; /* plink is a NMPlatformLink type, however, we require it to come from the platform * cache (where else would it come from?). */ @@ -4396,9 +4403,12 @@ realize_start_setup (NMDevice *self, nm_device_set_unmanaged_by_user_udev (self); nm_device_set_unmanaged_by_user_conf (self); + unmanaged = plink + && !plink->initialized + && !force_platform_init; nm_device_set_unmanaged_flags (self, NM_UNMANAGED_PLATFORM_INIT, - plink && !plink->initialized); + unmanaged); } /**