From: "its_Giaan (Code Review)" Date: Mon, 23 Sep 2024 13:41:25 +0000 References: Reply-To: gianmarco@...2726..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641..., a@...2181... Message-ID: <4b34686b59b394fe61dc447f3083b91eb681f37d-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="tyCxjNoe+Lo="; 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 , flichtenheld Cc: openvpn-devel --tyCxjNoe+Lo= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld, ordex, plaisthos. Hello plaisthos, flichtenheld, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/762?usp=3Demail to review the following change. 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 --- M src/openvpn/socket.c 1 file changed, 9 insertions(+), 2 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/62/762/1 diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c index 27566c6..f152071 100644 --- a/src/openvpn/socket.c +++ b/src/openvpn/socket.c @@ -489,9 +489,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) @@ -519,6 +518,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); @@ -1712,6 +1715,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: 1 Gerrit-Owner: its_Giaan Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: ordex Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: flichtenheld Gerrit-Attention: ordex Gerrit-MessageType: newchange --tyCxjNoe+Lo= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld, ordex, plaisthos. <= /p>

its_Giaan would like plaisthos and flichtenheld to review this change.

Vi= ew Change

override ai_family if 'local' numeric address was spe=
cified

This change ensures that when a numeric IP address is specifi= ed
as argument to a 'local' directive, its ai_family overridesthe one extracted from the 'proto' config option.

Change-I= d: Ie2471e6b2d6974e70423b09918ad1c2136253754
Signed-off-by: Antonio Quar= tulli <a@...2181...>
---
M src/openvpn/socket.c
1 file chang= ed, 9 insertions(+), 2 deletions(-)

git pull ssh://gerrit.openvpn=
.net:29418/openvpn refs/changes/62/762/1
diff --git a/src/openvpn/s=
ocket.c b/src/openvpn/socket.c
index 27566c6..f152071 10064= 4
--- a/src/openvpn/socket.c
+++ b/src/open= vpn/socket.c
@@ -489,9 +489,8 @@
s= ig_info =3D &sigrec;
}
- /* try numeric ipv6 addr fi= rst */
+ /* try nu= meric ip addr first */
CLEAR(hints);
- hints.ai_family =3D ai_family;
hints.ai_flags =3D AI_NUMERICHOST;

if (flags & GETADDR_PASSIVE)
@@ -519,6 = +518,10 @@
const char *fmt;
= int level =3D 0;

+ /* this is not a numeric IP, therefore force reso= lution using the
+ = * provided ai_family */
+ hints.ai_family =3D ai_family;
+
if (hostname &&a= mp; (flags & GETADDR_RANDOMIZE))
{
<= span> hostname =3D hostname_randomize(hostname, &gc);
@@ -1712,6 +1715,10 @@
sock->= ;local_host, sock->local_port,
gai_stre= rror(status));
}
+
+ = * was globally configured */
+ sock->info.af =3D sock->info.lsa->bind_local-&= gt;ai_family;
}

= gc_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: 1
Gerrit-Owner: its_Giaan <gianmarco@...2786...= ..>
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: flichtenheld <frank@...2375...= 41...>
Gerrit-Attention: ordex <a@...2181...> <= /div>
Gerrit-MessageType: newchange
--tyCxjNoe+Lo=--