Browse code

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

Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <777939F9-A753-4A66-B40E-1346AFD588DE@sparklabs.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17290.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>

James Bekkema authored on 2018/07/23 12:28:31
Showing 4 changed files
... ...
@@ -6219,8 +6219,16 @@ into OpenVPN's ``tun''.  The gateway parameter is only used for
6219 6219
 IPv6 routes across ``tap'' devices, and if missing, the ``ipv6remote''
6220 6220
 field from
6221 6221
 .B \-\-ifconfig\-ipv6
6222
+or
6223
+.B \-\-route\-ipv6\-gateway
6222 6224
 is used.
6223 6225
 .TP
6226
+.B \-\-route\-ipv6\-gateway gw
6227
+Specify a default gateway
6228
+.B gw
6229
+for use with
6230
+.B \-\-route\-ipv6.
6231
+.TP
6224 6232
 .B \-\-server\-ipv6 ipv6addr/bits
6225 6233
 convenience\-function to enable a number of IPv6 related options at
6226 6234
 once, namely
... ...
@@ -1466,12 +1466,10 @@ do_init_route_ipv6_list(const struct options *options,
1466 1466
     int metric = -1;            /* no metric set */
1467 1467
 
1468 1468
     gw = options->ifconfig_ipv6_remote;         /* default GW = remote end */
1469
-#if 0                                   /* not yet done for IPv6 - TODO!*/
1470
-    if (options->route_ipv6_default_gateway)            /* override? */
1469
+    if (options->route_ipv6_default_gateway)
1471 1470
     {
1472 1471
         gw = options->route_ipv6_default_gateway;
1473 1472
     }
1474
-#endif
1475 1473
 
1476 1474
     if (options->route_default_metric)
1477 1475
     {
... ...
@@ -200,8 +200,10 @@ static const char usage_message[] =
200 200
     "--route-ipv6 network/bits [gateway] [metric] :\n"
201 201
     "                  Add IPv6 route to routing table after connection\n"
202 202
     "                  is established.  Multiple routes can be specified.\n"
203
-    "                  gateway default: taken from 'remote' in --ifconfig-ipv6\n"
203
+    "                  gateway default: taken from --route-ipv6-gateway or 'remote'\n"
204
+    "                  in --ifconfig-ipv6\n"
204 205
     "--route-gateway gw|'dhcp' : Specify a default gateway for use with --route.\n"
206
+    "--route-ipv6-gateway gw : Specify a default gateway for use with --route-ipv6.\n"
205 207
     "--route-metric m : Specify a default metric for use with --route.\n"
206 208
     "--route-delay n [w] : Delay n seconds after connection initiation before\n"
207 209
     "                  adding routes (may be 0).  If not specified, routes will\n"
... ...
@@ -6228,6 +6230,18 @@ add_option(struct options *options,
6228 6228
             }
6229 6229
         }
6230 6230
     }
6231
+    else if (streq(p[0], "route-ipv6-gateway") && p[1] && !p[2])
6232
+    {
6233
+        if (ipv6_addr_safe(p[1]))
6234
+        {
6235
+            options->route_ipv6_default_gateway = p[1];
6236
+        }
6237
+        else
6238
+        {
6239
+            msg(msglevel, "route-ipv6-gateway parm '%s' must be a valid address", p[1]);
6240
+            goto err;
6241
+        }
6242
+    }
6231 6243
     else if (streq(p[0], "route-metric") && p[1] && !p[2])
6232 6244
     {
6233 6245
         VERIFY_PERMISSION(OPT_P_ROUTE);
... ...
@@ -343,6 +343,7 @@ struct options
343 343
     const char *route_script;
344 344
     const char *route_predown_script;
345 345
     const char *route_default_gateway;
346
+    const char *route_ipv6_default_gateway;
346 347
     int route_default_metric;
347 348
     bool route_noexec;
348 349
     int route_delay;