[Openvpn-devel,v2,5/8] make server capable of starting with an IPv6-only tunnel

Message ID 20180608052017.6696-6-a@unstable.cc
State Superseded
Headers show
Series Allow IPv6-only tunnels | expand

Commit Message

Antonio Quartulli June 7, 2018, 7:20 p.m. UTC
From: Antonio Quartulli <antonio@openvpn.net>

Due to the current logic it is not possible for a server
to create an IPv6-only tunnel, because OpenVPN mandates
the existance of an IPv4 configuration (even if fake).

This change relaxes this constraint and allows servers to
bring up tunnels without any IPv4 setting at all.

For the user this means that a server can be configured
with just the "--server-ipv6" directive and no "--server"
at all.

Trac: #208
Cc: Gert Doering <gert@greenie.muc.de>
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
---
 src/openvpn/helper.c | 8 ++++++--
 src/openvpn/multi.c  | 3 ++-
 2 files changed, 8 insertions(+), 3 deletions(-)

Patch

diff --git a/src/openvpn/helper.c b/src/openvpn/helper.c
index ff9df506..42ba5b2c 100644
--- a/src/openvpn/helper.c
+++ b/src/openvpn/helper.c
@@ -177,10 +177,11 @@  helper_client_server(struct options *o)
      */
     if (o->server_ipv6_defined)
     {
-        if (!o->server_defined)
+        if (o->client)
         {
-            msg(M_USAGE, "--server-ipv6 must be used together with --server");
+            msg(M_USAGE, "--server and --client cannot be used together");
         }
+
         if (o->server_flags & SF_NOPOOL)
         {
             msg( M_USAGE, "--server-ipv6 is incompatible with 'nopool' option" );
@@ -190,6 +191,9 @@  helper_client_server(struct options *o)
             msg( M_USAGE, "--server-ipv6 already defines an ifconfig-ipv6-pool, so you can't also specify --ifconfig-pool explicitly");
         }
 
+        o->mode = MODE_SERVER;
+        o->tls_server = true;
+
         /* local ifconfig is "base address + 1" and "+2" */
         o->ifconfig_ipv6_local =
             print_in6_addr( add_in6_addr( o->server_network_ipv6, 1), 0, &o->gc );
diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c
index 20f8611b..dbc8f370 100644
--- a/src/openvpn/multi.c
+++ b/src/openvpn/multi.c
@@ -388,7 +388,8 @@  multi_init(struct multi_context *m, struct context *t, bool tcp_mode, int thread
      * differently based on whether a tun or tap style
      * tunnel.
      */
-    if (t->options.ifconfig_pool_defined)
+    if (t->options.ifconfig_pool_defined
+        || t->options.ifconfig_ipv6_pool_defined)
     {
         int pool_type = IFCONFIG_POOL_INDIV;