]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
put virtual IPv6 addresses into env
authorHeiko Hund <heiko.hund@sophos.com>
Wed, 25 Nov 2015 16:46:49 +0000 (17:46 +0100)
committerGert Doering <gert@greenie.muc.de>
Sun, 29 Nov 2015 13:55:20 +0000 (14:55 +0100)
Add missing environment variables for IPv6 virtual addresses:

  * ifconfig_pool_local_ip6
  * ifconfig_pool_remote_ip6
  * ifconfig_pool_ip6_netbits

Signed-off-by: Heiko Hund <heiko.hund@sophos.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1448470009-5243-1-git-send-email-heiko.hund@sophos.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10613
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit a8f8b9267183c3cfc065f344d61effe6c55c3da6)

src/openvpn/multi.c
src/openvpn/socket.c
src/openvpn/socket.h

index 4e5df1289efed7cab0bd647f6b6a188f2abf6fce..577c5d3987df4b3ab4d71b174f8199fc34367906 100644 (file)
@@ -1426,10 +1426,24 @@ multi_set_virtual_addr_env (struct multi_context *m, struct multi_instance *mi)
        }
     }
 
-    /* TODO: I'm not exactly sure what these environment variables are
-     *       used for, but if we have them for IPv4, we should also have
-     *       them for IPv6, no?
-     */
+  setenv_del (mi->context.c2.es, "ifconfig_pool_local_ip6");
+  setenv_del (mi->context.c2.es, "ifconfig_pool_remote_ip6");
+  setenv_del (mi->context.c2.es, "ifconfig_pool_ip6_netbits");
+
+  if (mi->context.c1.tuntap->ipv6 && mi->context.c2.push_ifconfig_ipv6_defined)
+    {
+      setenv_in6_addr (mi->context.c2.es,
+                       "ifconfig_pool_remote",
+                       &mi->context.c2.push_ifconfig_ipv6_local,
+                       SA_SET_IF_NONZERO);
+      setenv_in6_addr (mi->context.c2.es,
+                       "ifconfig_pool_local",
+                       &mi->context.c2.push_ifconfig_ipv6_remote,
+                       SA_SET_IF_NONZERO);
+      setenv_int (mi->context.c2.es,
+                  "ifconfig_pool_ip6_netbits",
+                  mi->context.c2.push_ifconfig_ipv6_netbits);
+    }
 }
 
 /*
index 0f46bad6988cfc4de3e12bdcee4a95f8e5ca2aa9..3e30c750a39949c78bf1d2edcb5db2013f589877 100644 (file)
@@ -2409,6 +2409,22 @@ setenv_in_addr_t (struct env_set *es, const char *name_prefix, in_addr_t addr, c
     }
 }
 
+void
+setenv_in6_addr (struct env_set *es,
+                 const char *name_prefix,
+                 const struct in6_addr *addr,
+                 const unsigned int flags)
+{
+  if (!IN6_IS_ADDR_UNSPECIFIED (addr) || !(flags & SA_SET_IF_NONZERO))
+    {
+      struct openvpn_sockaddr si;
+      CLEAR (si);
+      si.addr.in6.sin6_family = AF_INET6;
+      si.addr.in6.sin6_addr = *addr;
+      setenv_sockaddr (es, name_prefix, &si, flags);
+    }
+}
+
 void
 setenv_link_socket_actual (struct env_set *es,
                           const char *name_prefix,
index aec029e1ad475ad39d69f09ddd1f4e37ce8ea716..b7a4e013609df8f45e8348ee4910cc3c85e0b80b 100644 (file)
@@ -378,6 +378,11 @@ void setenv_in_addr_t (struct env_set *es,
                       in_addr_t addr,
                       const unsigned int flags);
 
+void setenv_in6_addr (struct env_set *es,
+                      const char *name_prefix,
+                      const struct in6_addr *addr,
+                      const unsigned int flags);
+
 void setenv_link_socket_actual (struct env_set *es,
                                const char *name_prefix,
                                const struct link_socket_actual *act,