From: "ordex (Code Review)" Date: Wed, 12 Mar 2025 21:52:28 +0000 References: Reply-To: a@...2181..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="wogSq2oTJck="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: socket: don't transfer bind family to socket in case of ANY address List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --wogSq2oTJck= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld, plaisthos. Hello plaisthos, flichtenheld, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/907?usp=3Demail to review the following change. Change subject: socket: don't transfer bind family to socket in case of ANY= address ...................................................................... socket: don't transfer bind family to socket in case of ANY address With the introduction of multisocket, we need to transfer the AI family of the bound address to the socket, as it may differ from what was set globally. However, this operation makes sense only when getaddrinfo() for bind is performed on a non-empty hostname. An empty hostname (ANY) may return AF_INET which will break following connection attempts to v6 only remotes. Change-Id: I27f305d3ae9bf650bab409e99173688d9f88ab65 Signed-off-by: Antonio Quartulli --- M src/openvpn/socket.c 1 file changed, 11 insertions(+), 3 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/07/907/1 diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c index 6b32e30..808870b 100644 --- a/src/openvpn/socket.c +++ b/src/openvpn/socket.c @@ -1724,9 +1724,17 @@ 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; + /* the resolved family makes sense only if the host is not ANY, + * otherwise getaddrinfo() may return v4 and break connections + * to v6 only remotes + */ + if (sock->local_host) + { + /* the resolved 'local entry' might have a different family th= an + * what 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/+/907?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: I27f305d3ae9bf650bab409e99173688d9f88ab65 Gerrit-Change-Number: 907 Gerrit-PatchSet: 1 Gerrit-Owner: ordex Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: flichtenheld Gerrit-MessageType: newchange --wogSq2oTJck= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld, plaisthos.

ordex would like plaisthos and flichtenheld to review t= his change.

Vi= ew Change

socket: don't transfer bind family to socket in case of A=
NY address

With the introduction of multisocket, we need to transfer= the
AI family of the bound address to the socket, as it may differ
f= rom what was set globally.

However, this operation makes sense only = when getaddrinfo()
for bind is performed on a non-empty hostname.
An = empty hostname (ANY) may return AF_INET which will break
following conne= ction attempts to v6 only remotes.

Change-Id: I27f305d3ae9bf650bab40= 9e99173688d9f88ab65
Signed-off-by: Antonio Quartulli <antonio@...2787...= ...>
---
M src/openvpn/socket.c
1 file changed, 11 insertions(+= ), 3 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn=
 refs/changes/07/907/1
diff --git a/src/openvpn/socket.c b/src/open=
vpn/socket.c
index 6b32e30..808870b 100644
= --- a/src/openvpn/socket.c
+++ b/src/openvpn/socket.c
@@ -1724,9 +1724,17 @@
gai_stre= rror(status));
}

- /* the resolved 'local en= try' might have a different family than what

- * was globally configured */
= - sock->info.af =3D soc= k->info.lsa->bind_local->ai_family;
+ /* the resolved family makes sense only if= the host is not ANY,
+ * otherwise getaddrinfo() may return v4 and break connections
+ * to v6 only = remotes
+ */<= /span>
+ if (sock->= ;local_host)
+ = {
+ /* th= e resolved 'local entry' might have a different family than<= br>+ * what was glo= bally configured
+ = */
+ = sock->info.af =3D sock->info.lsa->bind_local->ai_family;
+ }
<= span> }


gc_free(&gc);=

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

=
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I27f305d3ae9bf650bab409e9917= 3688d9f88ab65
Gerrit-Change-Number: 907
Gerrit-PatchSet: 1
Gerrit-Owner: ordex <a@...2181...>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
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-MessageType: newchange
--wogSq2oTJck=--