Skip to contentSkip to conversation

Fix FreeBSD ifconfig for topology subnet tunnels.

PATCH In review Gert Doering 1 participant 2 messages Apr 26, 2015 – Jun 2, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix FreeBSD ifconfig for topology subnet tunnels.

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

---
 src/openvpn/tun.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)
src/openvpn/tun.c +23 -1
index 11a6d71..aa7a9f0 100644
@@ -626,6 +626,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
@@ -1150,7 +1172,7 @@ do_ifconfig (struct tuntap *tt,
 			  IFCONFIG_PATH,
 			  actual,
 			  ifconfig_local,
-			  ifconfig_local,
+			  create_arbitrary_remote( tt, &gc ),
 			  tun_mtu,
 			  ifconfig_remote_netmask
 			  );
Signature · 1 line
2.2.2
#1 lore raw

Lazy-ACK. 5 weeks on the list, no concerns (except from David about endianness, which I've tested for - i386 and sparc64).

Patch has been applied to the master and release/2.3 branch.

commit 60fd44e501f2002459a49c6c9bc64370ea26ca87 (master) commit e1182281f41ccd6c5820a13dad4382841f4832e6 (release/2.3)

Author: Gert Doering
Date:   Sun Apr 26 20:03:58 2015 +0200
     Fix FreeBSD ifconfig for topology subnet tunnels.

     Signed-off-by: Gert Doering <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: http://article.gmane.org/gmane.network.openvpn.devel/9606

--
kind regards,

Gert Doering