[Openvpn-devel] Fix environment variables for p2mp-assigned IPv6 addresses.

Message ID 20200715113132.22754-1-gert@greenie.muc.de
State Rejected
Headers show
Series
  • [Openvpn-devel] Fix environment variables for p2mp-assigned IPv6 addresses.
Related show

Commit Message

Gert Doering July 15, 2020, 11:31 a.m.
commit a8f8b926718 introduces $ENV{ifconfig_pool_local_ip6} and
$ENV{ifconfig_pool_remote_ip6}, but instead of properly setting them,
the code overwrites the IPv4 variables, $ENV{ifconfig_pool_remote}
and $ENV{ifconfig_pool_local}.

Trivial fix.

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

Comments

Arne Schwabe July 15, 2020, noon | #1
Am 15.07.20 um 13:31 schrieb Gert Doering:
> commit a8f8b926718 introduces $ENV{ifconfig_pool_local_ip6} and
> $ENV{ifconfig_pool_remote_ip6}, but instead of properly setting them,
> the code overwrites the IPv4 variables, $ENV{ifconfig_pool_remote}
> and $ENV{ifconfig_pool_local}.
> 
> Trivial fix.
>

Acked-By: Arne Schwabe <arne@rfc2549.org>
Gert Doering July 15, 2020, 12:21 p.m. | #2
Hi,

On Wed, Jul 15, 2020 at 01:31:32PM +0200, Gert Doering wrote:
> commit a8f8b926718 introduces $ENV{ifconfig_pool_local_ip6} and
> $ENV{ifconfig_pool_remote_ip6}, but instead of properly setting them,
> the code overwrites the IPv4 variables, $ENV{ifconfig_pool_remote}
> and $ENV{ifconfig_pool_local}.
> 
> Trivial fix.
> 
> Signed-off-by: Gert Doering <gert@greenie.muc.de>

And while the fix looks trivially right, it isn't... setenv_in6_addr()
calls setenv_sockaddr() which does

	openvpn_snprintf(name_buf, sizeof(name_buf), "%s_ip6", name_prefix);
	getnameinfo(&addr->addr.sa, sizeof(struct sockaddr_in6),
		    buf, sizeof(buf), NULL, 0, NI_NUMERICHOST);

so with the patch, I end up with

ifconfig_pool_local_ip6_ip6=fd00:abcd:204:5::1
ifconfig_pool_remote_ip6_ip6=fd00:abcd:204:5::2

seems the original code is not easy to understand, but correct.

So, NACK.

Taking "talking to myself" to new levels :-)

gert

Patch

diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c
index fe8fcd50..01da8c73 100644
--- a/src/openvpn/multi.c
+++ b/src/openvpn/multi.c
@@ -1624,11 +1624,11 @@  multi_set_virtual_addr_env(struct multi_instance *mi)
     if (mi->context.c2.push_ifconfig_ipv6_defined)
     {
         setenv_in6_addr(mi->context.c2.es,
-                        "ifconfig_pool_remote",
+                        "ifconfig_pool_remote_ip6",
                         &mi->context.c2.push_ifconfig_ipv6_local,
                         SA_SET_IF_NONZERO);
         setenv_in6_addr(mi->context.c2.es,
-                        "ifconfig_pool_local",
+                        "ifconfig_pool_local_ip6",
                         &mi->context.c2.push_ifconfig_ipv6_remote,
                         SA_SET_IF_NONZERO);
         setenv_int(mi->context.c2.es,