Browse code

IPv6 address/route delete fix for Win8

Use "store=active" for IPv6 address and route deletion - seems to be
required on Windows 8 and up, and not doing it will break OpenVPN
reconnection (old addresses are not properly deleted, thus address can
not be configured on connect).

Reported-by: Cedric <cedric+openvpn@bgtn.net>
Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Cedric Tabary <cedric+openvpn@bgtn.net>
Message-Id: <20140413170648.GU16637@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/8499

Gert Doering authored on 2014/04/13 20:12:02
Showing 2 changed files
... ...
@@ -1958,10 +1958,16 @@ delete_route_ipv6 (const struct route_ipv6 *r6, const struct tuntap *tt, unsigne
1958 1958
     argv_printf_cat (&argv, "METRIC %d", r->metric);
1959 1959
 #endif
1960 1960
 
1961
+  /* Windows XP to 7 "just delete" routes, wherever they came from, but
1962
+   * in Windows 8(.1?), if you create them with "store=active", this is
1963
+   * how you should delete them as well (pointed out by Cedric Tabary)
1964
+   */
1965
+  argv_printf_cat( &argv, " store=active" );
1966
+
1961 1967
   argv_msg (D_ROUTE, &argv);
1962 1968
 
1963 1969
   netcmd_semaphore_lock ();
1964
-  openvpn_execve_check (&argv, es, 0, "ERROR: Windows route add ipv6 command failed");
1970
+  openvpn_execve_check (&argv, es, 0, "ERROR: Windows route delete ipv6 command failed");
1965 1971
   netcmd_semaphore_release ();
1966 1972
 
1967 1973
 #elif defined (TARGET_SOLARIS)
... ...
@@ -5305,10 +5305,14 @@ close_tun (struct tuntap *tt)
5305 5305
 	  /* remove route pointing to interface */
5306 5306
 	  delete_route_connected_v6_net(tt, NULL);
5307 5307
 
5308
+	  /* "store=active" is needed in Windows 8(.1) to delete the
5309
+	   * address we added (pointed out by Cedric Tabary).
5310
+	   */
5311
+
5308 5312
 	  /* netsh interface ipv6 delete address \"%s\" %s */
5309 5313
 	  ifconfig_ipv6_local = print_in6_addr (tt->local_ipv6, 0,  &gc);
5310 5314
 	  argv_printf (&argv,
5311
-		    "%s%sc interface ipv6 delete address %s %s",
5315
+		    "%s%sc interface ipv6 delete address %s %s store=active",
5312 5316
 		     get_win_sys_path(),
5313 5317
 		     NETSH_PATH_SUFFIX,
5314 5318
 		     tt->actual_name,