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=<idx> 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 <olmannisto@gmail.com>
Signed-off-by: Lev Stipakov <lstipakov@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
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 <gert@greenie.muc.de>
... | ... |
@@ -67,6 +67,8 @@ static void netsh_command (const struct argv *a, int n); |
67 | 67 |
|
68 | 68 |
static const char *netsh_get_id (const char *dev_node, struct gc_arena *gc); |
69 | 69 |
|
70 |
+static DWORD get_adapter_index_flexible (const char *name); |
|
71 |
+ |
|
70 | 72 |
#endif |
71 | 73 |
|
72 | 74 |
#ifdef TARGET_SOLARIS |
... | ... |
@@ -1301,18 +1303,20 @@ do_ifconfig (struct tuntap *tt, |
1301 | 1301 |
if ( do_ipv6 ) |
1302 | 1302 |
{ |
1303 | 1303 |
char * saved_actual; |
1304 |
+ char iface[64]; |
|
1304 | 1305 |
|
1305 | 1306 |
if (!strcmp (actual, "NULL")) |
1306 | 1307 |
msg (M_FATAL, "Error: When using --tun-ipv6, if you have more than one TAP-Windows adapter, you must also specify --dev-node"); |
1307 | 1308 |
|
1308 |
- /* example: netsh interface ipv6 set address MyTap 2001:608:8003::d store=active */ |
|
1309 |
+ openvpn_snprintf(iface, sizeof(iface), "interface=%lu", get_adapter_index_flexible(actual)); |
|
1310 |
+ |
|
1311 |
+ /* example: netsh interface ipv6 set address interface=42 2001:608:8003::d store=active */ |
|
1309 | 1312 |
argv_printf (&argv, |
1310 |
- "%s%sc interface ipv6 set address %s %s store=active", |
|
1313 |
+ "%s%sc interface ipv6 set address %s %s store=active", |
|
1311 | 1314 |
get_win_sys_path(), |
1312 | 1315 |
NETSH_PATH_SUFFIX, |
1313 |
- actual, |
|
1314 |
- ifconfig_ipv6_local ); |
|
1315 |
- |
|
1316 |
+ iface, |
|
1317 |
+ ifconfig_ipv6_local); |
|
1316 | 1318 |
netsh_command (&argv, 4); |
1317 | 1319 |
|
1318 | 1320 |
/* explicit route needed */ |