]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Fix subnet topology on NetBSD (2.4).
authorAdam Ciarciński <adam@netbsd.org>
Thu, 2 Aug 2018 14:17:56 +0000 (16:17 +0200)
committerGert Doering <gert@greenie.muc.de>
Thu, 9 Aug 2018 11:27:01 +0000 (13:27 +0200)
This the same change as in commit 98e1d917fc, just adapted to the
code differences between master and release/2.4

Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <B09CA954-FCB8-4362-912F-F43DDD7DC59C@NetBSD.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17268.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/tun.c

index 00292657a9304a9ff6a6351ec7e05fabb30d2ee4..db7c25ff5a5f99dbd4ccfe5ba5a6716ee9d744ee 100644 (file)
@@ -845,7 +845,7 @@ delete_route_connected_v6_net(struct tuntap *tt,
 #endif /* if defined(_WIN32) || defined(TARGET_DARWIN) || defined(TARGET_NETBSD) || defined(TARGET_OPENBSD) */
 
 #if defined(TARGET_FREEBSD) || defined(TARGET_DRAGONFLY)  \
-    || defined(TARGET_OPENBSD)
+    || defined(TARGET_NETBSD) || defined(TARGET_OPENBSD)
 /* 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"
@@ -1269,6 +1269,8 @@ do_ifconfig(struct tuntap *tt,
 
 #elif defined(TARGET_NETBSD)
 
+        in_addr_t remote_end;           /* for "virtual" subnet topology */
+
         if (tun)
         {
             argv_printf(&argv,
@@ -1282,12 +1284,13 @@ do_ifconfig(struct tuntap *tt,
         }
         else if (tt->topology == TOP_SUBNET)
         {
+            remote_end = create_arbitrary_remote( tt );
             argv_printf(&argv,
                         "%s %s %s %s mtu %d netmask %s up",
                         IFCONFIG_PATH,
                         actual,
                         ifconfig_local,
-                        ifconfig_local,
+                        print_in_addr_t(remote_end, 0, &gc),
                         tun_mtu,
                         ifconfig_remote_netmask
                         );
@@ -1312,6 +1315,18 @@ do_ifconfig(struct tuntap *tt,
         argv_msg(M_INFO, &argv);
         openvpn_execve_check(&argv, es, S_FATAL, "NetBSD ifconfig failed");
 
+        /* Add a network route for the local tun interface */
+        if (!tun && tt->topology == TOP_SUBNET)
+        {
+            struct route_ipv4 r;
+            CLEAR(r);
+            r.flags = RT_DEFINED;
+            r.network = tt->local & tt->remote_netmask;
+            r.netmask = tt->remote_netmask;
+            r.gateway = remote_end;
+            add_route(&r, tt, 0, NULL, es);
+        }
+
         if (do_ipv6)
         {
             argv_printf(&argv,