From: "its_Giaan (Code Review)" Date: Fri, 27 Dec 2024 12:39:19 +0000 In-Reply-To: References: Reply-To: gianmarco@...2726..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641..., gert@...1296..., a@...2181... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="Sbb/mpzCGho="; 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: plaisthos , cron2 , flichtenheld Cc: openvpn-devel --Sbb/mpzCGho= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld, its_Giaan, ordex, plais= thos. Hello cron2, flichtenheld, ordex, plaisthos, I'd like you to reexamine a change. Please visit http://gerrit.openvpn.net/c/openvpn/+/762?usp=3Demail to look at the new patch set (#9). 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 --- M src/openvpn/socket.c 1 file changed, 16 insertions(+), 2 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/62/762/9 diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c index 7921433..b84521a 100644 --- a/src/openvpn/socket.c +++ b/src/openvpn/socket.c @@ -488,9 +488,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) @@ -507,6 +506,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? */ @@ -518,6 +524,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); @@ -1716,6 +1726,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: 9 Gerrit-Owner: its_Giaan Gerrit-Reviewer: cron2 Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: ordex Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: its_Giaan Gerrit-Attention: flichtenheld Gerrit-Attention: ordex Gerrit-MessageType: newpatchset --Sbb/mpzCGho= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld, its_Giaan, ordex, p= laisthos.

its_Giaan uploaded patch set #9 to this change.

<= a href=3D"http://gerrit.openvpn.net/c/openvpn/+/762?usp=3Demail">View Chang= e

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 on= e extracted from the 'proto' config option.

Change-Id: Ie247= 1e6b2d6974e70423b09918ad1c2136253754
Signed-off-by: Antonio Quartulli &l= t;a@...2181...>
Signed-off-by: Gianmarco De Gregori <gianmarco@...493...= 2726...>
---
M src/openvpn/socket.c
1 file changed, 16 insertio= ns(+), 2 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/ope=
nvpn refs/changes/62/762/9
diff --git a/src/openvpn/socket.c b/src/=
openvpn/socket.c
index 7921433..b84521a 100644
--- a/src/openvpn/socket.c
+++ b/src/openvpn/socket.c
@@ -488,9 +488,8 @@
sig_info =3D &a= mp;sigrec;
}

- /* try numeric ipv6 addr first */
+ /* try numeric ip add= r first */
CLEAR(hints);
- hints.ai_family =3D ai_family;
= hints.ai_flags =3D AI_NUMERICHOST;

= if (flags & GETADDR_PASSIVE)
@@ -507,6 +506,13 @@
hints.ai_socktype =3D SOCK_STREAM;
= }

+ /* if hostname is not set, we want to bind to 'ANY', with<= /span>
+ * the correct a= ddress family - v4-only or v6/v6-dual-stack */
+ if (!hostname)
+ {
+ hints.ai_family =3D ai_family;
+ }
+
status =3D getaddrinfo(hostname, ser= vname, &hints, res);

if (status = !=3D 0) /* parse as numeric address failed? */
@@ -518,6 +5= 24,10 @@
const char *fmt;
= int level =3D 0;

+ /* this is not a numeric IP, therefore force resolu= tion using the
+ = * provided ai_family */
+ hints.ai_family =3D ai_family;
+
if (hostname &&= ; (flags & GETADDR_RANDOMIZE))
{
hostname =3D hostname_randomize(hostname, &gc);
<= br>@@ -1716,6 +1726,10 @@
sock->l= ocal_host, sock->local_port,
gai_strerr= or(status));
}
+
= + /* the resolved 'local entry' might have a different famil= y than what
+ = * was globally configured */
+ sock->info.af =3D sock->info.lsa->bind_local->= ;ai_family;
}

g= c_free(&gc);

To view, visit change 762. = To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie2471e6b2d6974e70423b09918a= d1c2136253754
Gerrit-Change-Number: 762
Gerrit-PatchSet: 9
Gerrit-Owner: its_Giaan <gianmarco@...2786...= ..>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: ordex <a@...2181...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-Attention: its_Giaan <gianmarco@...1665...= 726...>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
Gerrit-Attention: ordex <a@...2181...> <= /div>
Gerrit-MessageType: newpatchset
--Sbb/mpzCGho=--