From: "plaisthos (Code Review)" Date: Mon, 17 Mar 2025 15:14:08 +0000 References: Reply-To: arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <885170f99ccebf00ec9e7501915538f8a35ea716-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="UY0mXBvCozQ="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: Mention address if not unspecific on DNS failure List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld Cc: openvpn-devel --UY0mXBvCozQ= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld. Hello flichtenheld, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/909?usp=3Demail to review the following change. Change subject: Mention address if not unspecific on DNS failure ...................................................................... Mention address if not unspecific on DNS failure With the recent changes breaking configs that included lport 0, it became apparent that having the address family in the error message when resolving fails, would have made diagnosis in this case and probably others much easier. Change-Id: I1c8fcd5bb6e1fa0020d52879eefbafdb2630e7b5 Signed-off-by: Arne Schwabe --- M src/openvpn/socket.c 1 file changed, 21 insertions(+), 2 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/09/909/1 diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c index 6b32e30..24c414d 100644 --- a/src/openvpn/socket.c +++ b/src/openvpn/socket.c @@ -445,6 +445,22 @@ throw_signal_soft(SIGHUP, "Preresolving failed"); } +/** + * Small helper function for openvpn_getaddrinfo to print the address + * family when resolving fails + */ +static const char * +gettaddrinfo_addr_family_name(int af) +{ + switch (af) + { + case AF_INET: return "[AF_INET]"; + + case AF_INET6: return "[AF_INET6]"; + } + return ""; +} + /* * Translate IPv4/IPv6 addr or hostname into struct addrinfo * If resolve error, try again for resolve_retry_seconds seconds. @@ -545,11 +561,11 @@ print_hostname =3D "undefined"; } - fmt =3D "RESOLVE: Cannot resolve host address: %s:%s (%s)"; + fmt =3D "RESOLVE: Cannot resolve host address: %s:%s%s (%s)"; if ((flags & GETADDR_MENTION_RESOLVE_RETRY) && !resolve_retry_seconds) { - fmt =3D "RESOLVE: Cannot resolve host address: %s:%s (%s) " + fmt =3D "RESOLVE: Cannot resolve host address: %s:%s%s (%s) %s" "(I would have retried this name query if you had " "specified the --resolv-retry option.)"; } @@ -561,6 +577,8 @@ goto done; } + + #ifdef ENABLE_MANAGEMENT if (flags & GETADDR_UPDATE_MANAGEMENT_STATE) { @@ -639,6 +657,7 @@ fmt, print_hostname, print_servname, + gettaddrinfo_addr_family_name(ai_family), gai_strerror(status)); if (--resolve_retries <=3D 0) -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/909?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: I1c8fcd5bb6e1fa0020d52879eefbafdb2630e7b5 Gerrit-Change-Number: 909 Gerrit-PatchSet: 1 Gerrit-Owner: plaisthos Gerrit-Reviewer: flichtenheld Gerrit-CC: openvpn-devel Gerrit-Attention: flichtenheld Gerrit-MessageType: newchange --UY0mXBvCozQ= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld.

plaisthos would like flichtenheld to review this change.

Vi= ew Change

Mention address if not unspecific on DNS failure

With = the recent changes breaking configs that included lport 0, it became
app= arent that having the address family in the error message when
resolvin= g fails, would have made diagnosis in this case and probably others
much= easier.

Change-Id: I1c8fcd5bb6e1fa0020d52879eefbafdb2630e7b5
Sig= ned-off-by: Arne Schwabe <arne@...1227...>
---
M src/openvpn/so= cket.c
1 file changed, 21 insertions(+), 2 deletions(-)

git pu= ll ssh://gerrit.openvpn.net:29418/openvpn refs/changes/09/909/1
dif=
f --git a/src/openvpn/socket.c b/src/openvpn/socket.c
index= 6b32e30..24c414d 100644
--- a/src/openvpn/socket.c<= br>+++ b/src/openvpn/socket.c
@@ -445,6 +445,22 @@
throw_signal_soft(SIGHUP, "Preresolving failed"= ;);
}

+/**
+ * Small helper function for openvpn_getaddrinfo to print the address<= /span>
+ * family when resol= ving fails
+ */
+static const char *
+gettaddrinfo_addr_family_= name(int af)
+{
+ switch (af)+ {
+ case AF_INET: return "[AF_I= NET]";
+<= br>+ case AF_INET6: retu= rn "[AF_INET6]";
+ }
+ ret= urn "";
+}<= /span>
+
/*=
* Translate IPv4/IPv6 addr or hostname into struct addri= nfo
* If resolve error, try again for resolve_retry_secon= ds seconds.
@@ -545,11 +561,11 @@
= print_hostname =3D "undefined";
}

- = fmt =3D "RESOLVE: Cannot resolve host address: %s:%s (%s)";
+ fmt =3D "R= ESOLVE: Cannot resolve host address: %s:%s%s (%s)";
= if ((flags & GETADDR_MENTION_RESOLVE_RETRY)
= && !resolve_retry_seconds)
{
- fmt =3D "= RESOLVE: Cannot resolve host address: %s:%s (%s) "
+ fmt =3D "RESOLVE: Cann= ot resolve host address: %s:%s%s (%s) %s"
= "(I would have retried this name query if you had "=
"specified the --resolv-retry option.)&qu= ot;;
}
@@ -561,6 +577,8 @@<= br> goto done;
}

+
+
#ifdef ENABLE_MANA= GEMENT
if (flags & GETADDR_UPDATE_MANAGEMENT_S= TATE)
{
@@ -639,6 +657,7 @@=
fmt,
print_host= name,
print_servname,
+ gettaddrinfo_addr_family= _name(ai_family),
gai_strerror(status));

if (--resolve_retries <=3D= 0)

To view, visit change 909. To unsubscrib= e, or for help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I1c8fcd5bb6e1fa0020d52879eef= bafdb2630e7b5
Gerrit-Change-Number: 909
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <arne-openvpn@...1711...= 27...>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
Gerrit-MessageType: newchange
--UY0mXBvCozQ=--