diff options
author | David Sommerseth <davids@redhat.com> | 2012-01-24 12:32:46 +0100 |
---|---|---|
committer | David Sommerseth <davids@redhat.com> | 2012-01-25 18:00:10 +0100 |
commit | 415421c24ac5b62d59fb8f03076521cba6f126cc (patch) | |
tree | 7340ff0ec74131afb722445878e2a5b667331d6a /init.c | |
parent | 62c613d46dc495d747074ca030d2cbdfd255c386 (diff) | |
download | openvpn-415421c24ac5b62d59fb8f03076521cba6f126cc.tar.gz openvpn-415421c24ac5b62d59fb8f03076521cba6f126cc.tar.xz openvpn-415421c24ac5b62d59fb8f03076521cba6f126cc.zip |
Add --route-pre-down/OPENVPN_PLUGIN_ROUTE_PREDOWN script/plug-in hook
This patchs adds a script/plug-in hook which is called right before the
network routes are taken down. This gives external processes a
possibility to tear down communication over the VPN before the VPN
disappears.
One use case can be to mount a networked file system over the VPN via
--route-up. And then to unmount this file system via --route-pre-down
Signed-off-by: David Sommerseth <davids@redhat.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Diffstat (limited to 'init.c')
-rw-r--r-- | init.c | 21 |
1 files changed, 19 insertions, 2 deletions
@@ -1583,8 +1583,25 @@ do_close_tun (struct context *c, bool force) /* delete any routes we added */ if (c->c1.route_list || c->c1.route_ipv6_list ) - delete_routes (c->c1.route_list, c->c1.route_ipv6_list, - c->c1.tuntap, ROUTE_OPTION_FLAGS (&c->options), c->c2.es); + { + run_up_down (c->options.route_predown_script, + c->plugins, + OPENVPN_PLUGIN_ROUTE_PREDOWN, + tuntap_actual, + NULL, + TUN_MTU_SIZE (&c->c2.frame), + EXPANDED_SIZE (&c->c2.frame), + print_in_addr_t (local, IA_EMPTY_IF_UNDEF, &gc), + print_in_addr_t (remote_netmask, IA_EMPTY_IF_UNDEF, &gc), + "init", + signal_description (c->sig->signal_received, + c->sig->signal_text), + "route-pre-down", + c->c2.es); + + delete_routes (c->c1.route_list, c->c1.route_ipv6_list, + c->c1.tuntap, ROUTE_OPTION_FLAGS (&c->options), c->c2.es); + } /* actually close tun/tap device based on --down-pre flag */ if (!c->options.down_pre) |