]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
When aborting in a non-graceful way, try to execute do_close_tun in
authorjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>
Tue, 12 Jan 2010 18:26:22 +0000 (18:26 +0000)
committerjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>
Tue, 12 Jan 2010 18:26:22 +0000 (18:26 +0000)
init.c prior to daemon exit to ensure that the tun/tap interface is
closed and any added routes are deleted.

git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@5367 e7ae566f-a301-0410-adde-c780ea21d3b5

error.c
init.c
version.m4

diff --git a/error.c b/error.c
index 1d6ed628c74c92b8bd4d1151d7e5eb3eb9d12c44..603796a1a0838a697daa510e0978f4352923bae0 100644 (file)
--- a/error.c
+++ b/error.c
@@ -682,10 +682,13 @@ msg_thread_uninit (void)
 void
 openvpn_exit (const int status)
 {
+  void tun_abort();
 #ifdef ENABLE_PLUGIN
   void plugin_abort (void);
 #endif
 
+  tun_abort();
+
 #ifdef WIN32
   uninit_win32 ();
 #endif
diff --git a/init.c b/init.c
index 20ca0a5503ac3af321ff73779499ddfba116dc23..3748c2e3dd4adbf51a4205a4d406061ea3a7a0d5 100644 (file)
--- a/init.c
+++ b/init.c
@@ -41,6 +41,8 @@
 
 #include "occ-inline.h"
 
+static struct context *static_context; /* GLOBAL */
+
 /*
  * Crypto initialization flags
  */
@@ -1109,6 +1111,7 @@ do_open_tun (struct context *c)
                               SET_MTU_TUN | SET_MTU_UPPER_BOUND);
 
       ret = true;
+      static_context = c;
     }
   else
     {
@@ -1162,6 +1165,8 @@ do_close_tun (struct context *c, bool force)
 
       if (force || !(c->sig->signal_received == SIGUSR1 && c->options.persist_tun))
        {
+         static_context = NULL;
+
 #ifdef ENABLE_MANAGEMENT
          /* tell management layer we are about to close the TUN/TAP device */
          if (management)
@@ -1218,6 +1223,17 @@ do_close_tun (struct context *c, bool force)
   gc_free (&gc);
 }
 
+void
+tun_abort()
+{
+  struct context *c = static_context;
+  if (c)
+    {
+      static_context = NULL;
+      do_close_tun (c, true);
+    }
+}
+
 /*
  * Handle delayed tun/tap interface bringup due to --up-delay or --pull
  */
index 48ca9972a79ffe3cc53d168d501408273641eedd..a2b40e2601d9debb469c1ef5e870ca67e54c13a3 100644 (file)
@@ -1,5 +1,5 @@
 dnl define the OpenVPN version
-define(PRODUCT_VERSION,[2.1.1])
+define(PRODUCT_VERSION,[2.1.1a])
 dnl define the TAP version
 define(PRODUCT_TAP_ID,[tap0901])
 define(PRODUCT_TAP_WIN32_MIN_MAJOR,[9])