diff options
author | james <james@e7ae566f-a301-0410-adde-c780ea21d3b5> | 2010-01-12 18:26:22 +0000 |
---|---|---|
committer | james <james@e7ae566f-a301-0410-adde-c780ea21d3b5> | 2010-01-12 18:26:22 +0000 |
commit | 0c9eb1d3b3f9694c3bc3ad7cf8fdf7553789f93b (patch) | |
tree | d3a45f12f276901de60b4470b3aec7b8c4103388 /init.c | |
parent | Fixed some breakage in openvpn.spec (which is required to build an (diff) | |
download | openvpn-0c9eb1d3b3f9694c3bc3ad7cf8fdf7553789f93b.tar.xz |
When aborting in a non-graceful way, try to execute do_close_tun in
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
Diffstat (limited to 'init.c')
-rw-r--r-- | init.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -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 */ |