diff options
Diffstat (limited to '')
-rw-r--r-- | tun.c | 36 |
1 files changed, 33 insertions, 3 deletions
@@ -573,7 +573,7 @@ init_tun_post (struct tuntap *tt, } #if defined(TARGET_WIN32) || \ - defined(TARGET_DARWIN) || defined(TARGET_NETBSD) + defined(TARGET_DARWIN) || defined(TARGET_NETBSD) || defined(TARGET_OPENBSD) /* some of the platforms will auto-add a "network route" pointing * to the interface on "ifconfig tunX 2001:db8::1/64", others need @@ -880,7 +880,18 @@ do_ifconfig (struct tuntap *tt, openvpn_execve_check (&argv, es, S_FATAL, "OpenBSD ifconfig failed"); if ( do_ipv6 ) { - msg( M_FATAL, "can't configure IPv6 on OpenBSD yet - unimplemented" ); + argv_printf (&argv, + "%s %s inet6 %s/%d", + IFCONFIG_PATH, + actual, + ifconfig_ipv6_local, + tt->netbits_ipv6 + ); + argv_msg (M_INFO, &argv); + openvpn_execve_check (&argv, es, S_FATAL, "OpenBSD ifconfig inet6 failed"); + + /* and, hooray, we explicitely need to add a route... */ + add_route_connected_v6_net(tt, es); } tt->did_ifconfig = true; @@ -941,7 +952,7 @@ do_ifconfig (struct tuntap *tt, tt->netbits_ipv6 ); argv_msg (M_INFO, &argv); - openvpn_execve_check (&argv, es, S_FATAL, "NetBSD ifconfig failed"); + openvpn_execve_check (&argv, es, S_FATAL, "NetBSD ifconfig inet6 failed"); /* and, hooray, we explicitely need to add a route... */ add_route_connected_v6_net(tt, es); @@ -1910,12 +1921,31 @@ open_tun (const char *dev, const char *dev_type, const char *dev_node, struct tu } } +/* the current way OpenVPN handles tun devices on OpenBSD leads to + * lingering tunX interfaces after close -> for a full cleanup, they + * need to be explicitely destroyed + */ + void close_tun (struct tuntap* tt) { if (tt) { + struct gc_arena gc = gc_new (); + struct argv argv; + + /* setup command, close tun dev (clears tt->actual_name!), run command + */ + + argv_init (&argv); + argv_printf (&argv, "%s %s destroy", + IFCONFIG_PATH, tt->actual_name); + close_tun_generic (tt); + + argv_msg (M_INFO, &argv); + openvpn_execve_check (&argv, NULL, 0, "OpenBSD 'destroy tun interface' failed (non-critical)"); + free (tt); } } |