Skip to contentSkip to conversation

Adds support for setting the default IPv6 gateway for routes using the route-ipv6-gateway option

PATCH In review James Bekkema 3 participants 3 messages Jul 23, 2018 – Dec 5, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Adds support for setting the default IPv6 gateway for routes using the route-ipv6-gateway option

This patch adds support for setting the default IPv6 gateway for routes using the "route-ipv6-gateway” option.

Currently if users try to use the "redirect-gateway ipv6” option, or a IPv6 route without a gateway, without using "ifconfig-ipv6" they’ll receive the message "OpenVPN ROUTE6: OpenVPN needs a gateway parameter for a --route-ipv6 option and no default was specified by either --route-ipv6-gateway or --ifconfig-ipv6 options”.

However, the "route-ipv6-gateway” option doesn’t actually exist, and it is required for bridged/TAP setups relying on IPv6 auto-configuration for IP assignment. This patch adds the "route-ipv6-gateway” option. The gateway specified must be an IPv6 address, FQDNs are not supported (to match the behaviour of the other IPv6 related options).

Currently in production use in Viscosity for macOS and Windows, no reported issues.

Thanks,
James

--
James Bekkema
SparkLabs Developer
https://www.sparklabs.com
https://twitter.com/sparklabs
[email protected]...

From 4925dea99cabdedb518be59fc14d83484b830cbe Mon Sep 17 00:00:00 2001
From: James Bekkema <[email protected]...>
Date: Mon, 23 Jul 2018 13:28:31 +1000
Subject: [PATCH] Adds support for setting the default IPv6 gateway for routes
using the route-ipv6-gateway option.

---
 doc/openvpn.8         |  8 ++++++++
 src/openvpn/init.c    |  4 +---
 src/openvpn/options.c | 16 +++++++++++++++-
 src/openvpn/options.h |  1 +
 4 files changed, 25 insertions(+), 4 deletions(-)
doc/openvpn.8 +8 -0
index 46ea58b6..7441b443 100644
@@ -6149,8 +6149,16 @@ into OpenVPN's ``tun''.  The gateway parameter is only used for
 IPv6 routes across ``tap'' devices, and if missing, the ``ipv6remote''
 field from
 .B \-\-ifconfig\-ipv6
+or
+.B \-\-route\-ipv6\-gateway
 is used.
 .TP
+.B \-\-route\-ipv6\-gateway gw
+Specify a default gateway
+.B gw
+for use with
+.B \-\-route\-ipv6.
+.TP
 .B \-\-server\-ipv6 ipv6addr/bits
 convenience\-function to enable a number of IPv6 related options at
 once, namely
src/openvpn/init.c +1 -3
index 057dbb4b..d2903b87 100644
@@ -1416,12 +1416,10 @@ do_init_route_ipv6_list(const struct options *options,
     int metric = -1;            /* no metric set */
 
     gw = options->ifconfig_ipv6_remote;         /* default GW = remote end */
-#if 0                                   /* not yet done for IPv6 - TODO!*/
-    if (options->route_ipv6_default_gateway)            /* override? */
+    if (options->route_ipv6_default_gateway)
     {
         gw = options->route_ipv6_default_gateway;
     }
-#endif
 
     if (options->route_default_metric)
     {
src/openvpn/options.c +15 -1
index b89f4ba2..0d11e968 100644
@@ -200,8 +200,10 @@ static const char usage_message[] =
     "--route-ipv6 network/bits [gateway] [metric] :\n"
     "                  Add IPv6 route to routing table after connection\n"
     "                  is established.  Multiple routes can be specified.\n"
-    "                  gateway default: taken from 'remote' in --ifconfig-ipv6\n"
+    "                  gateway default: taken from --route-ipv6-gateway or 'remote'\n"
+    "                  in --ifconfig-ipv6\n"
     "--route-gateway gw|'dhcp' : Specify a default gateway for use with --route.\n"
+    "--route-ipv6-gateway gw : Specify a default gateway for use with --route-ipv6.\n"
     "--route-metric m : Specify a default metric for use with --route.\n"
     "--route-delay n [w] : Delay n seconds after connection initiation before\n"
     "                  adding routes (may be 0).  If not specified, routes will\n"
@@ -6197,6 +6199,18 @@ add_option(struct options *options,
             }
         }
     }
+    else if (streq(p[0], "route-ipv6-gateway") && p[1] && !p[2])
+    {
+        if (ipv6_addr_safe(p[1]))
+        {
+            options->route_ipv6_default_gateway = p[1];
+        }
+        else
+        {
+            msg(msglevel, "route-ipv6-gateway parm '%s' must be a valid address", p[1]);
+            goto err;
+        }
+    }
     else if (streq(p[0], "route-metric") && p[1] && !p[2])
     {
         VERIFY_PERMISSION(OPT_P_ROUTE);
src/openvpn/options.h +1 -0
index 3a6c33f8..66d45081 100644
@@ -329,6 +329,7 @@ struct options
     const char *route_script;
     const char *route_predown_script;
     const char *route_default_gateway;
+    const char *route_ipv6_default_gateway;
     int route_default_metric;
     bool route_noexec;
     int route_delay;
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#1 lore raw

Am 23.07.18 um 05:45 schrieb James Bekkema:

Quoted 10 lines

This patch adds support for setting the default IPv6 gateway for routes using the "route-ipv6-gateway” option.

Currently if users try to use the "redirect-gateway ipv6” option, or a IPv6 route without a gateway, without using "ifconfig-ipv6" they’ll receive the message "OpenVPN ROUTE6: OpenVPN needs a gateway parameter for a --route-ipv6 option and no default was specified by either --route-ipv6-gateway or --ifconfig-ipv6 options”.

However, the "route-ipv6-gateway” option doesn’t actually exist, and it is required for bridged/TAP setups relying on IPv6 auto-configuration for IP assignment. This patch adds the "route-ipv6-gateway” option. The gateway specified must be an IPv6 address, FQDNs are not supported (to match the behaviour of the other IPv6 related options).

Currently in production use in Viscosity for macOS and Windows, no reported issues.

Looks good and looks like Gert wanted to implment to it and never got to it. But I will let Gert have the last word on it.

Arne

#2 lore raw

[Openvpn-devel] [PATCH applied] Re: Adds support for setting the default IPv6 gateway for routes using the route-ipv6-gateway option.

In reply to James Bekkema

Your patch has been applied to the master branch.

Thanks for not just enabling the option but for also showing a valid use case (which was mostly the reason why this got never implemented, I couldn't see a case where this was really useful).

commit d24e1b179b95a57b81d9802c13426b5cde66de10 (master)

Author: James Bekkema
Date:   Mon Jul 23 13:28:31 2018 +1000
     Adds support for setting the default IPv6 gateway for routes using the route-ipv6-gateway option.

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

--
kind regards,

Gert Doering