diff options
author | Gert Doering <gert@greenie.muc.de> | 2011-05-22 19:02:39 +0200 |
---|---|---|
committer | Gert Doering <gert@greenie.muc.de> | 2011-05-22 19:08:22 +0200 |
commit | b55e49bd69484fdd440098f9485de159251e1cce (patch) | |
tree | fad30ddc3db287ef24de8df83f5f630792893817 /tun.c | |
parent | 39990a2b83308baf1372bbc8846136036a55cf50 (diff) | |
download | openvpn-b55e49bd69484fdd440098f9485de159251e1cce.tar.gz openvpn-b55e49bd69484fdd440098f9485de159251e1cce.tar.xz openvpn-b55e49bd69484fdd440098f9485de159251e1cce.zip |
Windows IPv6 cleanup - properly remove IPv6 routes and interface config
after tunnel shutdown. Needs to make delete_route_ipv6() visible from
tun.c (route.c, route.h) and to properly zero-out host bits from IPv6
"network" at interface route clearing. Further, add IPv6 routes with
"store=active" to make sure nothing lingers after a system crash while
OpenVPN was running.
While at it, small Solaris cleanup - use CLEAR() to zero-out "ifr" struct.
Tested on Windows XP SP3 and Win7 by Gert Doering and Tony Lim.
Signed-off-by: Gert Doering <gert@greenie.muc.de>
Diffstat (limited to 'tun.c')
-rw-r--r-- | tun.c | 30 |
1 files changed, 28 insertions, 2 deletions
@@ -591,6 +591,18 @@ void add_route_connected_v6_net(struct tuntap * tt, r6.gateway = tt->local_ipv6; add_route_ipv6 (&r6, tt, 0, es); } + +void delete_route_connected_v6_net(struct tuntap * tt, + const struct env_set *es) +{ + struct route_ipv6 r6; + + r6.defined = true; + r6.network = tt->local_ipv6; + r6.netbits = tt->netbits_ipv6; + r6.gateway = tt->local_ipv6; + delete_route_ipv6 (&r6, tt, 0, es); +} #endif @@ -1649,7 +1661,7 @@ open_tun (const char *dev, const char *dev_type, const char *dev_node, struct tu * http://www.whiteboard.ne.jp/~admin2/tuntap/ * has IPv6 support */ - memset(&ifr, 0x0, sizeof(ifr)); + CLEAR(ifr); if (tt->type == DEV_TYPE_NULL) { @@ -4851,9 +4863,23 @@ close_tun (struct tuntap *tt) { if ( tt->ipv6 && tt->did_ifconfig_ipv6_setup ) { + struct argv argv; + argv_init (&argv); + + /* remove route pointing to interface */ + delete_route_connected_v6_net(tt, NULL); + /* netsh interface ipv6 delete address \"%s\" %s */ const char * ifconfig_ipv6_local = print_in6_addr (tt->local_ipv6, 0, &gc); - msg( M_WARN, "TODO: remove IPv6 address %s", ifconfig_ipv6_local ); + argv_printf (&argv, + "%s%sc interface ipv6 delete address %s %s", + get_win_sys_path(), + NETSH_PATH_SUFFIX, + tt->actual_name, + ifconfig_ipv6_local ); + + netsh_command (&argv, 1); + argv_reset (&argv); } #if 1 if (tt->ipapi_context_defined) |