[Openvpn-devel,1/2] repair tap mode on OpenSolaris/OpenIndiana

Message ID 20191009095200.9337-1-gert@greenie.muc.de
State Accepted
Headers show
Series [Openvpn-devel,1/2] repair tap mode on OpenSolaris/OpenIndiana | expand

Commit Message

Gert Doering Oct. 8, 2019, 10:51 p.m. UTC
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.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
---
 src/openvpn/tun.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

Comments

Antonio Quartulli Oct. 9, 2019, 12:07 a.m. UTC | #1
Hi,

On 09/10/2019 11:51, Gert Doering wrote:
> 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).

Acked-by: Antonio Quartulli <antonio@openvpn.net>

> 
> Signed-off-by: Gert Doering <gert@greenie.muc.de>
> ---
>  src/openvpn/tun.c | 16 +++++++++++++---
>  1 file changed, 13 insertions(+), 3 deletions(-)
> 
> diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c
> index 0591df65..ce23eb6a 100644
> --- a/src/openvpn/tun.c
> +++ b/src/openvpn/tun.c
> @@ -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)
>
Antonio Quartulli Oct. 9, 2019, 12:10 a.m. UTC | #2
On 09/10/2019 13:07, Antonio Quartulli wrote:
> Thanks for fixing my change.
> The patch makes sense as it simply restores the original flow.

note: this fix affects SOLARIS specific code only.
Gert Doering Oct. 9, 2019, 12:43 a.m. UTC | #3
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 <gert@greenie.muc.de>
     Acked-by: Antonio Quartulli <antonio@openvpn.net>
     Message-Id: <20191009095200.9337-1-gert@greenie.muc.de>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg18905.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering

Patch

diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c
index 0591df65..ce23eb6a 100644
--- a/src/openvpn/tun.c
+++ b/src/openvpn/tun.c
@@ -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)