]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Change the hold command to communicate the time that OpenVPN would wait to the UI.
authorArne Schwabe <arne@rfc2549.org>
Wed, 12 Oct 2016 10:47:07 +0000 (12:47 +0200)
committerDavid Sommerseth <davids@openvpn.net>
Thu, 13 Oct 2016 15:19:48 +0000 (17:19 +0200)
Before the connect-retry change to do exponential backup this was not
necessary since the time was fixed. With the exponential backoff the
UI needs either to implement its own exponential backoff mechanism
or needs a way of knowing the value of OpenVPN internal mechansim.

Patch V2: Fixed typos noticed by Selva

[DS: Fixed a couple of whitespace errors in management_hold() at commit time]

Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <1476269227-13290-1-git-send-email-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg12675.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
doc/management-notes.txt
src/openvpn/init.c
src/openvpn/manage.c
src/openvpn/manage.h

index f68f3db98a80a2feb0045c4f194940d6e8d5f151..dd870ebc75a5f69f1e8ebd8c6ef3500bf7640bc3 100644 (file)
@@ -168,9 +168,12 @@ be reset by restarts.
 
 OpenVPN will indicate that it is in a hold state by
 sending a real-time notification to the management
-client:
+client, the parameter indicates how long OpenVPN would
+wait without UI (as influenced by connect-retry exponential
+backoff). The UI needs to wait for releasing the hold if it
+wants similar behavior:
 
-  >HOLD:Waiting for hold release
+  >HOLD:Waiting for hold release:10
 
 Command examples:
 
index af5d49130668082a83e794e7bb4759b3cf34cb4c..cc8e94551bf44a6a5989004c1419b79d1c22626f 100644 (file)
@@ -1960,16 +1960,17 @@ do_deferred_options (struct context *c, const unsigned int found)
 }
 
 /*
- * Possible hold on initialization
+ * Possible hold on initialization, holdtime is the
+ * time OpenVPN would wait without management
  */
 static bool
-do_hold (void)
+do_hold (int holdtime)
 {
 #ifdef ENABLE_MANAGEMENT
   if (management)
     {
       /* block until management hold is released */
-      if (management_hold (management))
+        if (management_hold (management, holdtime))
        return true;
     }
 #endif
@@ -2027,8 +2028,10 @@ socket_restart_pause (struct context *c)
   c->persist.restart_sleep_seconds = 0;
 
   /* do managment hold on context restart, i.e. second, third, fourth, etc. initialization */
-  if (do_hold ())
+  if (do_hold (sec))
+  {
     sec = 0;
+  }
 
   if (sec)
     {
@@ -2046,7 +2049,7 @@ do_startup_pause (struct context *c)
   if (!c->first_time)
     socket_restart_pause (c);
   else
-    do_hold (); /* do management hold on first context initialization */
+    do_hold (0); /* do management hold on first context initialization */
 }
 
 /*
@@ -3431,7 +3434,7 @@ open_management (struct context *c)
            }
 
          /* initial management hold, called early, before first context initialization */
-         do_hold ();
+         do_hold (0);
          if (IS_SIG (c))
            {
              msg (M_WARN, "Signal received from management interface, exiting");
index dcb1bc18757334455709d8f1ab627dfdf3edbbae..26a2f7ea18e498a7fdb814b5cc0cae2bbea79cc2 100644 (file)
@@ -3332,12 +3332,13 @@ management_should_daemonize (struct management *man)
  * Return true if the caller should not sleep for an additional time interval.
  */
 bool
-management_hold (struct management *man)
+management_hold (struct management *man, int holdtime)
 {
   if (management_would_hold (man))
     {
       volatile int signal_received = 0;
       const bool standalone_disabled_save = man->persist.standalone_disabled;
+      struct gc_arena gc = gc_new ();
 
       man->persist.standalone_disabled = false; /* This is so M_CLIENT messages will be correctly passed through msg() */
       man->persist.special_state_msg = NULL;
@@ -3347,7 +3348,9 @@ management_hold (struct management *man)
 
       if (!signal_received)
        {
-         man->persist.special_state_msg = ">HOLD:Waiting for hold release";
+         struct buffer out = alloc_buf_gc (128, &gc);
+         buf_printf (&out, ">HOLD:Waiting for hold release:%d", holdtime);
+         man->persist.special_state_msg = BSTR (&out);
          msg (M_CLIENT, "%s", man->persist.special_state_msg);
 
          /* run command processing event loop until we get our username/password */
@@ -3366,6 +3369,7 @@ management_hold (struct management *man)
       man->persist.special_state_msg = NULL;
       man->settings.mansig &= ~MANSIG_IGNORE_USR1_HUP;
 
+      gc_free (&gc);
       return true;
     }
   return false;
index 988600f5e290ef006f3e2a302e9db9c60808cad4..50db38cd5559862f3be09802164f14b5b0eb0a2b 100644 (file)
@@ -396,7 +396,7 @@ int managment_android_persisttun_action (struct management *man);
 
 bool management_should_daemonize (struct management *man);
 bool management_would_hold (struct management *man);
-bool management_hold (struct management *man);
+bool management_hold (struct management *man, int holdtime);
 
 void management_event_loop_n_seconds (struct management *man, int sec);