Skip to contentSkip to conversation

repair tap mode on OpenSolaris/OpenIndiana

PATCH In review Gert Doering 2 participants 8 messages Oct 9, 2019 – Oct 28, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 repair tap mode on OpenSolaris/OpenIndiana

commit 611fcbc48 joined the two distinct calls for "add ipv6 address to tap interface" and "set MTU" for Solaris - but due to peculiarities on how this platform handles IPv6 addresses ("ifconfig addif" creates a new "tap0:1" subinterface with the new address - which does not have a distinct MTU) this does not work.

un-join calls again.

---
 src/openvpn/tun.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
src/openvpn/tun.c +13 -3
index 0591df65..ce23eb6a 100644
@@ -937,9 +937,11 @@ do_ifconfig_ipv6(struct tuntap *tt, const char *ifname, int tun_mtu,
          * server will ignore the DHCPv6 packets anyway.  So we don't.
          */
 
-        /* static IPv6 addresses need to go to a subinterface (tap0:1) */
-        argv_printf(&argv, "%s %s inet6 addif %s/%d mtu %d up", IFCONFIG_PATH,
-                    ifname, ifconfig_ipv6_local, tt->netbits_ipv6, tun_mtu);
+        /* static IPv6 addresses need to go to a subinterface (tap0:1)
+         * and we cannot set an mtu here (must go to the "parent")
+         */
+        argv_printf(&argv, "%s %s inet6 addif %s/%d up", IFCONFIG_PATH,
+                    ifname, ifconfig_ipv6_local, tt->netbits_ipv6 );
     }
     argv_msg(M_INFO, &argv);
 
@@ -947,6 +949,14 @@ do_ifconfig_ipv6(struct tuntap *tt, const char *ifname, int tun_mtu,
     {
         solaris_error_close(tt, es, ifname, true);
     }
+
+    if (tt->type != DEV_TYPE_TUN)
+    {
+        argv_printf(&argv, "%s %s inet6 mtu %d", IFCONFIG_PATH,
+                    ifname, tun_mtu);
+        argv_msg(M_INFO, &argv);
+        openvpn_execve_check(&argv, es, 0, "Solaris ifconfig IPv6 mtu failed");
+    }
 #elif defined(TARGET_OPENBSD) || defined(TARGET_NETBSD) \
     || defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) \
     || defined(TARGET_DRAGONFLY)
Signature · 1 line
2.23.0
#1 lore raw

PATCH 2/2 Fix IPv6 routes on tap interfaces on OpenSolaris/OpenIndiana

The "route add" code always used "metric 0" on OpenSolaris, because (on tun interfaces) it was required to make the route work on "non-ethernet" interfaces (connected, no NDP).

This breaks routes via tap interfaces on recent Solaris versions (tested on OpenIndiana 2019) - there, routes only work if metric is != 0 (or just not set). Otherwise it tries to map the gateway address to a local address and fails.

---
 src/openvpn/route.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
src/openvpn/route.c +2 -2
index 3183fb47..97e90e56 100644
@@ -2043,8 +2043,8 @@ add_route_ipv6(struct route_ipv6 *r6, const struct tuntap *tt,
                 r6->netbits,
                 gateway );
 
-    /* on tun/tap, not "elsewhere"? -> metric 0 */
-    if (!r6->iface)
+    /* on tun (not tap), not "elsewhere"? -> metric 0 */
+    if (tt->type == DEV_TYPE_TUN && !r6->iface)
     {
         argv_printf_cat(&argv, "0");
     }
Signature · 1 line
2.23.0
Acked-by on v1 1/2
#5 lore raw
In reply to Gert Doering

Hi,

Quoted 7 lines · Gert Doering

commit 611fcbc48 joined the two distinct calls for "add ipv6 address to tap interface" and "set MTU" for Solaris - but due to peculiarities on how this platform handles IPv6 addresses ("ifconfig addif" creates a new "tap0:1" subinterface with the new address - which does not have a distinct MTU) this does not work.

un-join calls again.

Thanks for fixing my change.
The patch makes sense as it simply restores the original flow.

I have only reviewed the code and compile-tested it, but I trust Gert who said to have performed a t_client test on his OpenIndiana2019 host (which is where the problem was found in the first place).

Quoted 41 lines
---
 src/openvpn/tun.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
src/openvpn/tun.c +13 -3
index 0591df65..ce23eb6a 100644
@@ -937,9 +937,11 @@ do_ifconfig_ipv6(struct tuntap *tt, const char *ifname, int tun_mtu,
          * server will ignore the DHCPv6 packets anyway.  So we don't.
          */
 
-        /* static IPv6 addresses need to go to a subinterface (tap0:1) */
-        argv_printf(&argv, "%s %s inet6 addif %s/%d mtu %d up", IFCONFIG_PATH,
-                    ifname, ifconfig_ipv6_local, tt->netbits_ipv6, tun_mtu);
+        /* static IPv6 addresses need to go to a subinterface (tap0:1)
+         * and we cannot set an mtu here (must go to the "parent")
+         */
+        argv_printf(&argv, "%s %s inet6 addif %s/%d up", IFCONFIG_PATH,
+                    ifname, ifconfig_ipv6_local, tt->netbits_ipv6 );
     }
     argv_msg(M_INFO, &argv);
 
@@ -947,6 +949,14 @@ do_ifconfig_ipv6(struct tuntap *tt, const char *ifname, int tun_mtu,
     {
         solaris_error_close(tt, es, ifname, true);
     }
+
+    if (tt->type != DEV_TYPE_TUN)
+    {
+        argv_printf(&argv, "%s %s inet6 mtu %d", IFCONFIG_PATH,
+                    ifname, tun_mtu);
+        argv_msg(M_INFO, &argv);
+        openvpn_execve_check(&argv, es, 0, "Solaris ifconfig IPv6 mtu failed");
+    }
 #elif defined(TARGET_OPENBSD) || defined(TARGET_NETBSD) \
     || defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) \
     || defined(TARGET_DRAGONFLY)
Signature · 1 line
Antonio Quartulli
#6 lore raw
Quoted 2 lines · Antonio Quartulli

Thanks for fixing my change.
The patch makes sense as it simply restores the original flow.

note: this fix affects SOLARIS specific code only.

Signature · 1 line
Antonio Quartulli
Acked-by on v1 2/2
#2 lore raw

Re: [Openvpn-devel] [PATCH 2/2] Fix IPv6 routes on tap interfaces on OpenSolaris/OpenIndiana

In reply to Gert Doering

Hi,

Quoted 9 lines · Gert Doering

The "route add" code always used "metric 0" on OpenSolaris, because (on tun interfaces) it was required to make the route work on "non-ethernet" interfaces (connected, no NDP).

This breaks routes via tap interfaces on recent Solaris versions (tested on OpenIndiana 2019) - there, routes only work if metric is != 0 (or just not set). Otherwise it tries to map the gateway address to a local address and fails.

I have no means to test the code so I only stared at it and ensured it was affecting the SOLARIS platform code only. It does what the commit says and it makes sense in the solaris-nonsense-world.

Gert has performed some live tests on his new OpenIndiana 2019 host (where the problem was observed) and ensured it worked fine.

Quoted 21 lines
---
 src/openvpn/route.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
src/openvpn/route.c +2 -2
index 3183fb47..97e90e56 100644
@@ -2043,8 +2043,8 @@ add_route_ipv6(struct route_ipv6 *r6, const struct tuntap *tt,
                 r6->netbits,
                 gateway );
 
-    /* on tun/tap, not "elsewhere"? -> metric 0 */
-    if (!r6->iface)
+    /* on tun (not tap), not "elsewhere"? -> metric 0 */
+    if (tt->type == DEV_TYPE_TUN && !r6->iface)
     {
         argv_printf_cat(&argv, "0");
     }
Signature · 1 line
Antonio Quartulli
#7 lore raw
In reply to Gert Doering

Your patch has been applied to the master branch.

commit cc132d695609973d80b2edbc4cc654d95d72dde7

Author: Gert Doering
Date:   Wed Oct 9 11:51:59 2019 +0200
     repair tap mode on OpenSolaris/OpenIndiana

     Signed-off-by: Gert Doering <[email protected]...>
     Acked-by: Antonio Quartulli <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg18905.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#3 lore raw

[Openvpn-devel] [PATCH applied] Re: Fix IPv6 routes on tap interfaces on OpenSolaris/OpenIndiana

In reply to Gert Doering

Your patch has been applied to the master branch.

commit 01b3a48c29df6dc4bade3d8fb7903346a3f77887

Author: Gert Doering
Date:   Wed Oct 9 11:52:00 2019 +0200
     Fix IPv6 routes on tap interfaces on OpenSolaris/OpenIndiana

     Signed-off-by: Gert Doering <[email protected]...>
     Acked-by: Antonio Quartulli <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg18906.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#4 lore raw

Re: [Openvpn-devel] [PATCH applied] Re: Fix IPv6 routes on tap interfaces on OpenSolaris/OpenIndiana

Hi,

Quoted 5 lines · Gert Doering

Your patch has been applied to the master branch.

commit 01b3a48c29df6dc4bade3d8fb7903346a3f77887

Author: Gert Doering
Date:   Wed Oct 9 11:52:00 2019 +0200

I have also pulled this to release/2.4, as it's needed to unbreak tap on OpenIndiana.

(This is the "route metric 0" confusion - the "do not mix addif and mtu" patch is not needed because the offending refactoring is not in 2.4 either)

commit 0b2b25dfa3a19aba9c99e9a55a082fe85c4ccd59 (HEAD -> release/2.4, vweb1/release/2.4)

Author: Gert Doering <[email protected]...>
Date:   Wed Oct 9 11:52:00 2019 +0200

Fix IPv6 routes on tap interfaces on OpenSolaris/OpenIndiana

(cherry picked from commit 01b3a48c29df6dc4bade3d8fb7903346a3f77887)

gert

Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you 
 feed honest figures into a computer, honest figures come out. Never doubted 
 it myself till I met a computer with a sense of humor."
                             Robert A. Heinlein, The Moon is a Harsh Mistress

Gert Doering - Munich, Germany                             [email protected]...