From 38b6037f3373b2c2ed52a22f6e2f02655c06bdfd Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Tue, 11 Nov 2014 16:10:37 -0600 Subject: [PATCH] vpn: update DefaultRouteManager before sending state change signal The DRM now affects DNS too, since it determines the "best" IPv4 and IPv6 configs based on it's idea of the default route. The Policy is also still updating DNS from a state-change handler for VPN connections. This led to a situation where the Policy would remove the VPN's IP config from the DNS manager in vpn_connection_deactivated() and call update_ip4_dns(), whereupon get_best_ip4_config() returned the just-removed VPN IPv4 config as "best" because the VPN connection hadn't yet told the DefaultRouteManager to remove it. Which meant VPN nameservers stuck around in resolv.conf for a long time after the VPN was disconnected. Fixes: a39a3ae4cd72d695f1b5d10eaa79544f2020a54e --- src/vpn-manager/nm-vpn-connection.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/vpn-manager/nm-vpn-connection.c b/src/vpn-manager/nm-vpn-connection.c index fe5d812791..c581874880 100644 --- a/src/vpn-manager/nm-vpn-connection.c +++ b/src/vpn-manager/nm-vpn-connection.c @@ -325,6 +325,11 @@ _set_vpn_state (NMVpnConnection *connection, dispatcher_cleanup (connection); + if (vpn_state >= STATE_DISCONNECTED && vpn_state <= STATE_FAILED) { + nm_default_route_manager_ip4_remove_default_route (nm_default_route_manager_get (), connection); + nm_default_route_manager_ip6_remove_default_route (nm_default_route_manager_get (), connection); + } + /* The connection gets destroyed by the VPN manager when it enters the * disconnected/failed state, but we need to keep it around for a bit * to send out signals and handle the dispatcher. So ref it. @@ -342,9 +347,6 @@ _set_vpn_state (NMVpnConnection *connection, g_object_notify (G_OBJECT (connection), NM_VPN_CONNECTION_VPN_STATE); } - nm_default_route_manager_ip4_update_default_route (nm_default_route_manager_get (), connection); - nm_default_route_manager_ip6_update_default_route (nm_default_route_manager_get (), connection); - switch (vpn_state) { case STATE_NEED_AUTH: /* Do nothing; not part of 'default' because we don't want to touch