From: "cron2 (Code Review)" Date: Tue, 25 Mar 2025 21:23:56 +0000 In-Reply-To: References: Reply-To: gert@...1296..., 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="qDqmCjihUes="; 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: plaisthos , flichtenheld Cc: openvpn-devel --qDqmCjihUes= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has uploaded a new patch set (#5) to the change originally created by= plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/909?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+2 by cron2 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 Acked-by: Gert Doering Message-Id: <20250325195750.7899-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31= 237.html Signed-off-by: Gert Doering --- M src/openvpn/socket.c 1 file changed, 19 insertions(+), 2 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/09/909/5 diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c index 6b32e30..09de1b0 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 * +getaddrinfo_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)" "(I would have retried this name query if you had " "specified the --resolv-retry option.)"; } @@ -639,6 +655,7 @@ fmt, print_hostname, print_servname, + getaddrinfo_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: 5 Gerrit-Owner: plaisthos Gerrit-Reviewer: cron2 Gerrit-Reviewer: flichtenheld Gerrit-CC: openvpn-devel Gerrit-MessageType: newpatchset --qDqmCjihUes= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 uploaded patch set #5 to the change originally cr= eated by plaisthos.

View Change

The following approvals got outdated= and were removed: Code-Review+2 by cron2

Mention address if not unspecific on DNS failure
=
With the recent changes breaking configs that included lport 0, it beca= me
apparent that having the address family in the error message whenresolving fails, would have made diagnosis in this case and probably other= s
much easier.

Change-Id: I1c8fcd5bb6e1fa0020d52879eefbafdb2630e7= b5
Signed-off-by: Arne Schwabe <arne@...1227...>
Acked-by: Gert= Doering <gert@...1296...>
Message-Id: <20250325195750.7899-1-g= ert@...1296...>
URL: https://www.mail-archive.com/openvpn-devel@...1697...= .sourceforge.net/msg31237.html
Signed-off-by: Gert Doering <gert@...1386...= 296...>
---
M src/openvpn/socket.c
1 file changed, 19 insertion= s(+), 2 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/open=
vpn refs/changes/09/909/5
diff --git a/src/openvpn/socket.c b/src/o=
penvpn/socket.c
index 6b32e30..09de1b0 100644
--- a/src/openvpn/socket.c
+++ b/src/openvpn/socket.c
@@ -445,6 +445,22 @@
throw_signal_soft(S= IGHUP, "Preresolving failed");
}

+/**
+ * Small helper function for open= vpn_getaddrinfo to print the address
+ * family when resolving fails
+ */
+static const char *
+getaddrinfo_addr_family_name(int af)
+{
+ switch (af)
+ {
+ = case AF_INET: return "[AF_INET]";
+
+ case AF_INET6: return "[AF_INET6]";
+ }
+ return "";
+}
+
/*
* Translate IPv4/IPv= 6 addr or hostname into struct addrinfo
* If resolve erro= r, try again for resolve_retry_seconds seconds.
@@ -545,11 = +561,11 @@
print_hostname =3D "undefined&= quot;;
}

- fmt =3D "RESOLVE: Cannot resol= ve host address: %s:%s (%s)";
+ fmt =3D "RESOLVE: Cannot resolve host address: = %s:%s%s (%s)";
if ((flags & GETADDR_MENTI= ON_RESOLVE_RETRY)
&& !resolve_retry_se= conds)
{
- fmt =3D "RESOLVE: Cannot resolve host address:= %s:%s (%s) "
+ = fmt =3D "RESOLVE: Cannot resolve host address: %s:%s%s (%s)= "
"(I would have retried this = name query if you had "
"speci= fied the --resolv-retry option.)";
}@@ -639,6 +655,7 @@
fmt, print_hostname,
pr= int_servname,
+ = getaddrinfo_addr_family_name(ai_family),
= gai_strerror(status));

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

To= view, visit change 909. To unsubscribe, 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: 5
Gerrit-Owner: plaisthos <arne-openvpn@...1711...= 27...>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-MessageType: newpatchset
--qDqmCjihUes=--