]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Fix FreeBSD ifconfig for topology subnet tunnels.
authorGert Doering <gert@greenie.muc.de>
Sun, 26 Apr 2015 18:03:58 +0000 (20:03 +0200)
committerGert Doering <gert@greenie.muc.de>
Tue, 2 Jun 2015 17:00:28 +0000 (19:00 +0200)
For "topology subnet", we only pretend to have a subnet and keep
using the tun if in point-to-point mode - but for that to fully
work, the "remote" address needs to be different from the "local"
address.  So just arbitrarily construct one from the on-link
subnet - base+1, if "that is not us", base+2, otherwise.

Fix trac #481

See also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=194745

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Tested-By: Anton Sayetsky <vsasjason@gmail.com>
Lazy-ACK-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1430071438-31675-1-git-send-email-gert@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9606

src/openvpn/tun.c

index e479d4d177dd553a3bc707bc1b4a0cff90b3a14d..59e7436bf66fdbf6e17fa933c838ca51943e5ba1 100644 (file)
@@ -631,6 +631,28 @@ void delete_route_connected_v6_net(struct tuntap * tt,
 }
 #endif
 
+#if defined(TARGET_FREEBSD)||defined(TARGET_DRAGONFLY)
+/* we can't use true subnet mode on tun on all platforms, as that
+ * conflicts with IPv6 (wants to use ND then, which we don't do),
+ * but the OSes want "a remote address that is different from ours"
+ * - so we construct one, normally the first in the subnet, but if
+ * this is the same as ours, use the second one.
+ * The actual address does not matter at all, as the tun interface
+ * is still point to point and no layer 2 resolution is done...
+ */
+
+char *
+create_arbitrary_remote( struct tuntap *tt, struct gc_arena * gc )
+{
+  in_addr_t remote;
+
+  remote = (tt->local & tt->remote_netmask) +1;
+
+  if ( remote == tt->local ) remote ++;
+
+  return print_in_addr_t (remote, 0, &gc);
+}
+#endif
 
 /* execute the ifconfig command through the shell */
 void
@@ -1155,7 +1177,7 @@ do_ifconfig (struct tuntap *tt,
                          IFCONFIG_PATH,
                          actual,
                          ifconfig_local,
-                         ifconfig_local,
+                         create_arbitrary_remote( tt, &gc ),
                          tun_mtu,
                          ifconfig_remote_netmask
                          );