From: Lev Stipakov Date: Wed, 11 Nov 2015 11:48:07 +0000 (+0200) Subject: Use adapter index instead of name for windows IPv6 interface config X-Git-Tag: v2.3.9~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e2afbdb61392e750cfc54cc2ac9d08e5b6db4794;p=thirdparty%2Fopenvpn.git Use adapter index instead of name for windows IPv6 interface config Some windows machines get weird issues with netsh when using adapter name on "netsh.exe interface ipv6 set address" command. Changed logic to get adapter index and use it instead of adapter name for netsh set address command. v2: * Remove netsh call which uses adapter name. After thoughtful testing turns out that "adapter name" code branch is never used. v3: * Use interface= syntax. * Add forward declaration of get_adapter_index_flexible to get rid of warning. * NOTE: temp variable is needed because argv_printf() does not handle combined strings like "interface=%lu" today Signed-off-by: Olli Mannisto Signed-off-by: Lev Stipakov Acked-by: Gert Doering Message-Id: <1447242487-30243-1-git-send-email-lstipakov@gmail.com> URL: http://article.gmane.org/gmane.network.openvpn.devel/10484 Signed-off-by: Gert Doering (cherry picked from commit efeaf947c9c5c88d77d16ac4917c1350c447c8dc) --- diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index 3e2021591..a63b95111 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -66,6 +66,8 @@ static void netsh_command (const struct argv *a, int n); static const char *netsh_get_id (const char *dev_node, struct gc_arena *gc); +static DWORD get_adapter_index_flexible (const char *name); + #endif #ifdef TARGET_SOLARIS @@ -1228,18 +1230,20 @@ do_ifconfig (struct tuntap *tt, if ( do_ipv6 ) { char * saved_actual; + char iface[64]; if (!strcmp (actual, "NULL")) msg (M_FATAL, "Error: When using --tun-ipv6, if you have more than one TAP-Windows adapter, you must also specify --dev-node"); - /* example: netsh interface ipv6 set address MyTap 2001:608:8003::d store=active */ + openvpn_snprintf(iface, sizeof(iface), "interface=%lu", get_adapter_index_flexible(actual)); + + /* example: netsh interface ipv6 set address interface=42 2001:608:8003::d store=active */ argv_printf (&argv, - "%s%sc interface ipv6 set address %s %s store=active", + "%s%sc interface ipv6 set address %s %s store=active", get_win_sys_path(), NETSH_PATH_SUFFIX, - actual, - ifconfig_ipv6_local ); - + iface, + ifconfig_ipv6_local); netsh_command (&argv, 4); /* explicit route needed */