summaryrefslogtreecommitdiff
path: root/src/nm-policy.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nm-policy.c')
-rw-r--r--src/nm-policy.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/nm-policy.c b/src/nm-policy.c
index ca2d340b59..e21df28a9c 100644
--- a/src/nm-policy.c
+++ b/src/nm-policy.c
@@ -1836,6 +1836,28 @@ vpn_connection_state_changed (NMVpnConnection *vpn,
}
static void
+vpn_connection_retry_after_failure (NMVpnConnection *vpn, NMPolicy *policy)
+{
+ NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (policy);
+ NMActiveConnection *ac = NM_ACTIVE_CONNECTION (vpn);
+ NMConnection *connection = nm_active_connection_get_connection (ac);
+ GError *error = NULL;
+
+ /* Attempt to reconnect VPN connections that failed after being connected */
+ if (!nm_manager_activate_connection (priv->manager,
+ connection,
+ NULL,
+ NULL,
+ nm_active_connection_get_subject (ac),
+ &error)) {
+ nm_log_warn (LOGD_DEVICE, "VPN '%s' reconnect failed: %s",
+ nm_connection_get_id (connection),
+ error->message ? error->message : "unknown");
+ g_clear_error (&error);
+ }
+}
+
+static void
active_connection_state_changed (NMActiveConnection *active,
GParamSpec *pspec,
NMPolicy *policy)
@@ -1859,6 +1881,9 @@ active_connection_added (NMManager *manager,
g_signal_connect (active, NM_VPN_CONNECTION_INTERNAL_STATE_CHANGED,
G_CALLBACK (vpn_connection_state_changed),
policy);
+ g_signal_connect (active, NM_VPN_CONNECTION_INTERNAL_RETRY_AFTER_FAILURE,
+ G_CALLBACK (vpn_connection_retry_after_failure),
+ policy);
}
g_signal_connect (active, "notify::" NM_ACTIVE_CONNECTION_STATE,
@@ -1877,6 +1902,9 @@ active_connection_removed (NMManager *manager,
vpn_connection_state_changed,
policy);
g_signal_handlers_disconnect_by_func (active,
+ vpn_connection_retry_after_failure,
+ policy);
+ g_signal_handlers_disconnect_by_func (active,
active_connection_state_changed,
policy);
}