From 7a343cc981c08ea8f4e9652303bbe007739a6fcd Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 23 Jun 2016 22:54:25 +0200 Subject: [PATCH] vpn: reuse existing ip_config objects when config gets updated Previously we created a new NMIP[46]Config object to replace the previous one every time the plugin reported a new IP configuration through the Ip[46]Config signal, but the old configuration was not removed from the DNS manager and would become stale. The interaction with DNS manager is handled by NMPolicy, which only reacts to changes in connection status, so it's not easy to have the configuration removed from DNS while keeping the connection state ACTIVATED. A cleaner solutions is to avoid creating a new IP configuration object and reuse the existing one if possible. The side effect is that the D-Bus path of the object will not change, which seems also positive. https://bugzilla.redhat.com/show_bug.cgi?id=1348901 (cherry picked from commit 641e8b00fea2503acbcd5c8c942ed751a6607469) --- src/vpn-manager/nm-vpn-connection.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/vpn-manager/nm-vpn-connection.c b/src/vpn-manager/nm-vpn-connection.c index 8a6d678eaf..1d12eec9eb 100644 --- a/src/vpn-manager/nm-vpn-connection.c +++ b/src/vpn-manager/nm-vpn-connection.c @@ -1468,10 +1468,15 @@ nm_vpn_connection_ip4_config_get (NMVpnConnection *self, GVariant *dict) nm_connection_get_setting_ip4_config (_get_applied_connection (self)), route_metric); - nm_exported_object_clear_and_unexport (&priv->ip4_config); - priv->ip4_config = config; - nm_exported_object_export (NM_EXPORTED_OBJECT (config)); - g_object_notify (G_OBJECT (self), NM_ACTIVE_CONNECTION_IP4_CONFIG); + if (priv->ip4_config) { + nm_ip4_config_replace (priv->ip4_config, config, NULL); + g_object_unref (config); + } else { + priv->ip4_config = config; + nm_exported_object_export (NM_EXPORTED_OBJECT (config)); + g_object_notify (G_OBJECT (self), NM_ACTIVE_CONNECTION_IP4_CONFIG); + } + nm_vpn_connection_config_maybe_complete (self, TRUE); } @@ -1605,10 +1610,15 @@ next: nm_connection_get_setting_ip6_config (_get_applied_connection (self)), route_metric); - nm_exported_object_clear_and_unexport (&priv->ip6_config); - priv->ip6_config = config; - nm_exported_object_export (NM_EXPORTED_OBJECT (config)); - g_object_notify (G_OBJECT (self), NM_ACTIVE_CONNECTION_IP6_CONFIG); + if (priv->ip6_config) { + nm_ip6_config_replace (priv->ip6_config, config, NULL); + g_object_unref (config); + } else { + priv->ip6_config = config; + nm_exported_object_export (NM_EXPORTED_OBJECT (config)); + g_object_notify (G_OBJECT (self), NM_ACTIVE_CONNECTION_IP6_CONFIG); + } + nm_vpn_connection_config_maybe_complete (self, TRUE); }