From c84fd50287086082a8037ccb112f99b1026edd17 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Tue, 15 Mar 2016 12:02:53 +0100 Subject: [PATCH 1/2] device: don't update applied connection for generated assumed devices The applied connection must describe the configuration that was initially activated on the device. Even if the IP configuration changes, we shouldn't reset the applied connection for devices using a generated-assumed connection, otherwise we would lose information on the IP method we're trying on the device. --- src/devices/nm-device.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 4e954ae9a..5568cae6f 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -7925,23 +7925,16 @@ nm_device_set_ip4_config (NMDevice *self, nm_exported_object_clear_and_unexport (&old_config); if (nm_device_uses_generated_assumed_connection (self)) { - NMConnection *connection = nm_device_get_applied_connection (self); NMConnection *settings_connection = NM_CONNECTION (nm_device_get_settings_connection (self)); NMSetting *s_ip4; - g_object_freeze_notify (G_OBJECT (connection)); g_object_freeze_notify (G_OBJECT (settings_connection)); nm_connection_remove_setting (settings_connection, NM_TYPE_SETTING_IP4_CONFIG); s_ip4 = nm_ip4_config_create_setting (priv->ip4_config); nm_connection_add_setting (settings_connection, s_ip4); - nm_connection_remove_setting (connection, NM_TYPE_SETTING_IP4_CONFIG); - s_ip4 = nm_ip4_config_create_setting (priv->ip4_config); - nm_connection_add_setting (connection, s_ip4); - g_object_thaw_notify (G_OBJECT (settings_connection)); - g_object_thaw_notify (G_OBJECT (connection)); } nm_device_queue_recheck_assume (self); @@ -8090,23 +8083,16 @@ nm_device_set_ip6_config (NMDevice *self, nm_exported_object_clear_and_unexport (&old_config); if (nm_device_uses_generated_assumed_connection (self)) { - NMConnection *connection = nm_device_get_applied_connection (self); NMConnection *settings_connection = NM_CONNECTION (nm_device_get_settings_connection (self)); NMSetting *s_ip6; - g_object_freeze_notify (G_OBJECT (connection)); g_object_freeze_notify (G_OBJECT (settings_connection)); nm_connection_remove_setting (settings_connection, NM_TYPE_SETTING_IP6_CONFIG); s_ip6 = nm_ip6_config_create_setting (priv->ip6_config); nm_connection_add_setting (settings_connection, s_ip6); - nm_connection_remove_setting (connection, NM_TYPE_SETTING_IP6_CONFIG); - s_ip6 = nm_ip6_config_create_setting (priv->ip6_config); - nm_connection_add_setting (connection, s_ip6); - g_object_thaw_notify (G_OBJECT (settings_connection)); - g_object_thaw_notify (G_OBJECT (connection)); } nm_device_queue_recheck_assume (self); From 9b7f9af0776c5b741c616d3af4b0cda522c27295 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Tue, 15 Mar 2016 12:03:23 +0100 Subject: [PATCH 2/2] device: take care of default route of DHCP generated-assumed connections In general we don't touch the externally set default route on devices that use a generated-assumed connection. When the IP method is AUTO (or DHCP), this means that we are not able to restore the default route after a temporary expiration of the lease which removes addresses/routes from the device. Change this, and let NM update the default route for generated-assumed devices using dynamic addressing. https://bugzilla.redhat.com/show_bug.cgi?id=1265239 --- src/devices/nm-device.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 5568cae6f..10e9ffeac 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -4244,6 +4244,7 @@ ip4_config_merge_and_apply (NMDevice *self, gboolean routes_full_sync; gboolean ignore_auto_routes = FALSE; gboolean ignore_auto_dns = FALSE; + gboolean auto_method = FALSE; /* Merge all the configs into the composite config */ if (config) { @@ -4259,6 +4260,10 @@ ip4_config_merge_and_apply (NMDevice *self, if (s_ip4) { ignore_auto_routes = nm_setting_ip_config_get_ignore_auto_routes (s_ip4); ignore_auto_dns = nm_setting_ip_config_get_ignore_auto_dns (s_ip4); + + if (nm_streq0 (nm_setting_ip_config_get_method (s_ip4), + NM_SETTING_IP4_CONFIG_METHOD_AUTO)) + auto_method = TRUE; } } @@ -4314,10 +4319,12 @@ ip4_config_merge_and_apply (NMDevice *self, goto END_ADD_DEFAULT_ROUTE; } - if (nm_device_uses_generated_assumed_connection (self)) { - /* a generate-assumed-connection always detects the default route from platform */ + /* a generated-assumed connection detects the default route from the platform, + * but if the IP method is automatic we need to update the default route to + * maintain connectivity. + */ + if (nm_device_uses_generated_assumed_connection (self) && !auto_method) goto END_ADD_DEFAULT_ROUTE; - } /* At this point, we treat assumed and non-assumed connections alike. * For assumed connections we do that because we still manage RA and DHCP @@ -4964,6 +4971,7 @@ ip6_config_merge_and_apply (NMDevice *self, gboolean routes_full_sync; gboolean ignore_auto_routes = FALSE; gboolean ignore_auto_dns = FALSE; + gboolean auto_method = FALSE; /* Apply ignore-auto-routes and ignore-auto-dns settings */ connection = nm_device_get_applied_connection (self); @@ -4973,6 +4981,11 @@ ip6_config_merge_and_apply (NMDevice *self, if (s_ip6) { ignore_auto_routes = nm_setting_ip_config_get_ignore_auto_routes (s_ip6); ignore_auto_dns = nm_setting_ip_config_get_ignore_auto_dns (s_ip6); + + if (NM_IN_STRSET (nm_setting_ip_config_get_method (s_ip6), + NM_SETTING_IP6_CONFIG_METHOD_AUTO, + NM_SETTING_IP6_CONFIG_METHOD_DHCP)) + auto_method = TRUE; } } @@ -5036,10 +5049,12 @@ ip6_config_merge_and_apply (NMDevice *self, goto END_ADD_DEFAULT_ROUTE; } - if (nm_device_uses_generated_assumed_connection (self)) { - /* a generate-assumed-connection always detects the default route from platform */ + /* a generated-assumed connection detects the default route from the platform, + * but if the IP method is automatic we need to update the default route to + * maintain connectivity. + */ + if (nm_device_uses_generated_assumed_connection (self) && !auto_method) goto END_ADD_DEFAULT_ROUTE; - } /* At this point, we treat assumed and non-assumed connections alike. * For assumed connections we do that because we still manage RA and DHCP