diff options
author | Gert Doering <gert@greenie.muc.de> | 2010-08-08 12:34:00 +0200 |
---|---|---|
committer | Gert Doering <gert@greenie.muc.de> | 2011-04-24 17:22:43 +0200 |
commit | ada9769e32da0152c61ef76fefe403444d61af43 (patch) | |
tree | 1cf22ff58f4b70684ddd8cae1cd4bf445354427b /tun.c | |
parent | 2232f4b5ba74b7e0b77353e1e99f12637a8a15f6 (diff) | |
download | openvpn-ada9769e32da0152c61ef76fefe403444d61af43.tar.gz openvpn-ada9769e32da0152c61ef76fefe403444d61af43.tar.xz openvpn-ada9769e32da0152c61ef76fefe403444d61af43.zip |
implement IPv6 ifconfig + route setup/deletion on OpenBSD
destroy tunX interface on tun_close()
tested on OpenBSD 4.7
Signed-off-by: Gert Doering <gert@greenie.muc.de>
Diffstat (limited to 'tun.c')
-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); } } |