From: "cron2 (Code Review)"
Date: Fri, 27 Dec 2024 17:37:25 +0000
In-Reply-To:
References:
Reply-To: gert@...1296..., arne-openvpn@...1227...,
gianmarco@...2726..., openvpn-devel@lists.sourceforge.net,
frank@...2641..., a@...2181...
Message-ID: <496ebeccb55cdfe13d169e37ecd63e3583c67d40-EmailReplacePatchSet-HTML@...2715...>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Disposition: inline
Content-Type: multipart/alternative; boundary="hYFwmQgQwYI="; charset=UTF-8
Subject: [Openvpn-devel] [S] Change in openvpn[master]: override ai_family
if 'local' numeric address was specified
List-Id:
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
To: its_Giaan , plaisthos , flichtenheld
Cc: openvpn-devel
--hYFwmQgQwYI=
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
cron2 has uploaded a new patch set (#10) to the change originally created b=
y its_Giaan. ( http://gerrit.openvpn.net/c/openvpn/+/762?usp=3Demail )
The following approvals got outdated and were removed:
Code-Review+2 by cron2
Change subject: override ai_family if 'local' numeric address was specified
......................................................................
override ai_family if 'local' numeric address was specified
This change ensures that when a numeric IP address is specified
as argument to a 'local' directive, its ai_family overrides
the one extracted from the 'proto' config option.
Change-Id: Ie2471e6b2d6974e70423b09918ad1c2136253754
Signed-off-by: Antonio Quartulli
Signed-off-by: Gianmarco De Gregori
Acked-by: Gert Doering
Message-Id: <20241227161755.4010-1-gert@...1296...>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30=
257.html
Signed-off-by: Gert Doering
---
M src/openvpn/socket.c
1 file changed, 16 insertions(+), 2 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/62/762/10
diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c
index 01874fe..b895bd4 100644
--- a/src/openvpn/socket.c
+++ b/src/openvpn/socket.c
@@ -467,9 +467,8 @@
sig_info =3D &sigrec;
}
- /* try numeric ipv6 addr first */
+ /* try numeric ip addr first */
CLEAR(hints);
- hints.ai_family =3D ai_family;
hints.ai_flags =3D AI_NUMERICHOST;
if (flags & GETADDR_PASSIVE)
@@ -486,6 +485,13 @@
hints.ai_socktype =3D SOCK_STREAM;
}
+ /* if hostname is not set, we want to bind to 'ANY', with
+ * the correct address family - v4-only or v6/v6-dual-stack */
+ if (!hostname)
+ {
+ hints.ai_family =3D ai_family;
+ }
+
status =3D getaddrinfo(hostname, servname, &hints, res);
if (status !=3D 0) /* parse as numeric address failed? */
@@ -497,6 +503,10 @@
const char *fmt;
int level =3D 0;
+ /* this is not a numeric IP, therefore force resolution using the
+ * provided ai_family */
+ hints.ai_family =3D ai_family;
+
if (hostname && (flags & GETADDR_RANDOMIZE))
{
hostname =3D hostname_randomize(hostname, &gc);
@@ -1690,6 +1700,10 @@
sock->local_host, sock->local_port,
gai_strerror(status));
}
+
+ /* the resolved 'local entry' might have a different family than w=
hat
+ * was globally configured */
+ sock->info.af =3D sock->info.lsa->bind_local->ai_family;
}
gc_free(&gc);
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/762?usp=3Demail
To unsubscribe, or for help writing mail filters, visit http://gerrit.openv=
pn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie2471e6b2d6974e70423b09918ad1c2136253754
Gerrit-Change-Number: 762
Gerrit-PatchSet: 10
Gerrit-Owner: its_Giaan
Gerrit-Reviewer: cron2
Gerrit-Reviewer: flichtenheld
Gerrit-Reviewer: plaisthos
Gerrit-CC: openvpn-devel
Gerrit-CC: ordex
Gerrit-MessageType: newpatchset
--hYFwmQgQwYI=
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
cron2 uploaded patch set #10 to the change originally c=
reated by its_Giaan.
View Change
The following approvals got outdate=
d and were removed:
Code-Review+2 by cron2
override ai_family if 'local' numeric addres=
s was specified This change ensures that when a numeric IP address i=
s specified as argument to a 'local' directive, its ai_family ov=
errides the one extracted from the 'proto' config option. Change-Id: Ie2471e6b2d6974e70423b09918ad1c2136253754 Signed-off-by: Ant=
onio Quartulli <a@...2181...> Signed-off-by: Gianmarco De Gregori =
<gianmarco@...2726...> Acked-by: Gert Doering <gert@...1296...&=
gt; Message-Id: <20241227161755.4010-1-gert@...1296...> URL: ht=
tps://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30257.htm=
l Signed-off-by: Gert Doering <gert@...1296...> --- M src/op=
envpn/socket.c 1 file changed, 16 insertions(+), 2 deletions(-) <=
/pre>git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/62/762/10
=
diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c index 01874fe..b895bd4 100644--- a/src/openvpn/socket.=
c +++ b/src/openvpn/socket.c @@ -467,9 +467=
,8 @@ sig_info =3D &sigrec; =
} =
- /* try numeric ipv6 addr first */ + /* try numeric ip addr first */ =
CLEAR(hints); - hin=
ts.ai_family =3D ai_family; hints.ai_flags =3D AI_NUME=
RICHOST; if (flags & GETADDR_PAS=
SIVE) @@ -486,6 +485,13 @@ hints.a=
i_socktype =3D SOCK_STREAM; } =
+ /* if hostname is not =
set, we want to bind to 'ANY', with + * the correct address family - v4-only or v6/v=
6-dual-stack */ + =
if (!hostname) + {=
+ hints.ai_fa=
mily =3D ai_family; +=
} + status =3D getaddrinfo(hostname, servname, &hints, res);=
if (status !=3D 0) /* parse as numeric add=
ress failed? */ @@ -497,6 +503,10 @@ =
const char *fmt; int level =3D 0; + /* this=
is not a numeric IP, therefore force resolution using the + * provided ai_family */ + hints.ai_family=
=3D ai_family; + if (hostname && (flags & GETADDR_RANDOMIZ=
E)) { hostname =3D ho=
stname_randomize(hostname, &gc); @@ -1690,6 +1700,10 @@=
sock->local_host, sock->local_port,=
gai_strerror(status)); =
} + =
+ /* the resolved 'l=
ocal entry' might have a different family than what + * was globally configured */=
span>+ sock->info=
.af =3D sock->info.lsa->bind_local->ai_family; =
} gc_free(&gc); To view, visit change 762 . To unsubscribe, or for help wri=
ting mail filters, visit set=
tings .
=
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie2471e6b2d6974e70423b09918a=
d1c2136253754
Gerrit-Change-Number: 762
Gerrit-PatchSet: 10
Gerrit-Owner: its_Giaan <gianmarco@...2786...=
..>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: flichtenheld <frank@...2716...=
1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...=
.1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...=
ts.sourceforge.net>
Gerrit-CC: ordex <a@...2181...>
Gerrit-MessageType: newpatchset
--hYFwmQgQwYI=--