From 39990a2b83308baf1372bbc8846136036a55cf50 Mon Sep 17 00:00:00 2001 From: smos Date: Tue, 10 May 2011 10:01:48 +0200 Subject: Change the netsh.exe command from "add" to "set". This prevents the netsh.exe command from exiting with a status 1 when the address already exists. By adding store=active the address will not survive a reboot and be assigned temporarily. Tested on Windows 7 and Windows XP SP 2. Signed-off-by: smos Acked-by: Gert Doering Signed-off-by: Gert Doering --- tun.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tun.c') diff --git a/tun.c b/tun.c index 45db2b5..55d66e1 100644 --- a/tun.c +++ b/tun.c @@ -1167,9 +1167,9 @@ do_ifconfig (struct tuntap *tt, if (!strcmp (actual, "NULL")) msg (M_FATAL, "Error: When using --tun-ipv6, if you have more than one TAP-Win32 adapter, you must also specify --dev-node"); - /* example: netsh interface ipv6 add address MyTap 2001:608:8003::d */ + /* example: netsh interface ipv6 set address MyTap 2001:608:8003::d store=active */ argv_printf (&argv, - "%s%sc interface ipv6 add address %s %s", + "%s%sc interface ipv6 set address %s %s store=active", get_win_sys_path(), NETSH_PATH_SUFFIX, actual, -- cgit From b55e49bd69484fdd440098f9485de159251e1cce Mon Sep 17 00:00:00 2001 From: Gert Doering Date: Sun, 22 May 2011 19:02:39 +0200 Subject: 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 --- tun.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'tun.c') diff --git a/tun.c b/tun.c index 55d66e1..cea1784 100644 --- a/tun.c +++ b/tun.c @@ -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) -- cgit