openbsd-ports/net/openvpn/patches/patch-tun_c
sthen 61fe1a9218 Teach OpenVPN to use a specific ifconfig command for "topology subnet"
rather than defaulting to a bogus one which enables link0. From Mitja Muzenic.
2012-01-23 18:07:21 +00:00

48 lines
1.5 KiB
Plaintext

$OpenBSD: patch-tun_c,v 1.1 2012/01/23 18:07:21 sthen Exp $
--- tun.c.orig Tue Dec 13 16:58:56 2011
+++ tun.c Thu Jan 12 09:04:48 2012
@@ -776,7 +776,19 @@ do_ifconfig (struct tuntap *tt,
tun_mtu
);
else
- argv_printf (&argv,
+ {
+ if (tt->topology == TOP_SUBNET)
+ argv_printf (&argv,
+ "%s %s %s %s netmask %s mtu %d up",
+ IFCONFIG_PATH,
+ actual,
+ ifconfig_local,
+ ifconfig_local,
+ ifconfig_remote_netmask,
+ tun_mtu
+ );
+ else
+ argv_printf (&argv,
"%s %s %s netmask %s mtu %d broadcast %s link0",
IFCONFIG_PATH,
actual,
@@ -785,9 +797,22 @@ do_ifconfig (struct tuntap *tt,
tun_mtu,
ifconfig_broadcast
);
+ }
argv_msg (M_INFO, &argv);
openvpn_execve_check (&argv, es, S_FATAL, "OpenBSD ifconfig failed");
tt->did_ifconfig = true;
+
+ /* Add a network route for the local tun interface */
+ if (!tun && tt->topology == TOP_SUBNET)
+ {
+ struct route r;
+ CLEAR (r);
+ r.defined = true;
+ r.network = tt->local & tt->remote_netmask;
+ r.netmask = tt->remote_netmask;
+ r.gateway = tt->local;
+ add_route (&r, tt, 0, es);
+ }
#elif defined(TARGET_NETBSD)