[network-manager-libreswan/lr/multiple-vpn: 2/9] service: tolerate non-zero from ipsec auto --ready



commit e39e05b16edd2f077896ede2c52d7d34d3b889c5
Author: Lubomir Rintel <lkundrak v3 sk>
Date:   Wed Nov 4 14:00:04 2015 +0100

    service: tolerate non-zero from ipsec auto --ready
    
    It returns status=3 if the daemon is ready, but failed to listen on some
    addresses. Libreswan doesn't seem too good about picking the correct
    addresses to listen on. It returns status=1 if it couldn't connect to
    the control socket.
    
    https://github.com/libreswan/libreswan/pull/42

 src/nm-libreswan-service.c |   24 ++++++++++++++----------
 1 files changed, 14 insertions(+), 10 deletions(-)
---
diff --git a/src/nm-libreswan-service.c b/src/nm-libreswan-service.c
index f61733f..6d6f3da 100644
--- a/src/nm-libreswan-service.c
+++ b/src/nm-libreswan-service.c
@@ -520,6 +520,7 @@ child_watch_cb (GPid pid, gint status, gpointer user_data)
        NMLibreswanPluginPrivate *priv = NM_LIBRESWAN_PLUGIN_GET_PRIVATE (self);
        guint ret = 1;
        GError *error = NULL;
+       gboolean success;
 
        if (priv->watch_id == 0 || priv->pid != pid) {
                /* Reap old child */
@@ -542,23 +543,26 @@ child_watch_cb (GPid pid, gint status, gpointer user_data)
        /* Reap child */
        waitpid (pid, NULL, WNOHANG);
 
-       if (ret != 0 && priv->retries) {
-               priv->retries--;
-               g_message ("Spawn: %d more tries...", priv->retries);
-               priv->retry_id = g_timeout_add (100, retry_cb, self);
-               return;
-       }
+       if (priv->connect_step == CONNECT_STEP_WAIT_READY)
+               success = (ret != 1);
+       else
+               success = (ret == 0);
 
-       if (ret == 0) {
+       if (success) {
                /* Success; do the next connect step */
                priv->connect_step++;
                priv->retries = 0;
-               if (!connect_step (self, &error))
-                       ret = 1;
+               success = connect_step (self, &error);
+       } else if (priv->retries) {
+               priv->retries--;
+               g_message ("Spawn: %d more tries...", priv->retries);
+               priv->retry_id = g_timeout_add (100, retry_cb, self);
+               return;
        }
 
-       if (ret != 0)
+       if (!success)
                connect_failed (self, error, NM_VPN_PLUGIN_FAILURE_CONNECT_FAILED);
+
        g_clear_error (&error);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]