From patchwork Tue Mar 25 19:57:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 4196 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:81e:b0:60a:d70a:d3c7 with SMTP id jj30csp2757850mab; Tue, 25 Mar 2025 12:58:08 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV9s7HA19ndPvTbHfvupEaF1oO8JyBmKx3TtLUBVfVfdl6iObrZvMrWTXUoy9KytPSaioEMF975gfM=@openvpn.net X-Google-Smtp-Source: AGHT+IEYvfOjRYFNi4g1bMce0Xvu3BE2JywH42vwe6fWUKkiU803kDmh9ZVTJ2AoSh4dl3FSfJYB X-Received: by 2002:a05:6808:13cc:b0:3f9:c0f6:215e with SMTP id 5614622812f47-3febf713f88mr11043494b6e.12.1742932688178; Tue, 25 Mar 2025 12:58:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1742932688; cv=none; d=google.com; s=arc-20240605; b=M9f/YXQKuwS+Hn/W3pttrkwXWefGQ5qhG3cVzzUDUWVAvQTYFRfEjrHx73CUjpdL+F Ao/L98x0TTQ3dnQfTPxf2kryzpAV8BGI3y6xPDQV/XnT7FwWeEiDw/Ip/Wwqr+Hs+3iG s7YpEhiiQ4FCEYcHh3iRiLXHLwdaSCRMVAdg6L9VEkS2BK5RZN4vidpe9u8OgQBIQNbT NwtBLHxCtznJr5B0aLRku2sLGQSPcDc1OaG4D9gYyVRABkMXrBM8liysi0gMew/O4ieT g4f2gXtHmLfjwBTgiM/uqxEsSpR0v3tfjkotgTJtIW47sbVrKNUo9nwzJl0tF+hXrUII b4EQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature; bh=L4+FpEd61SyoHcO6B2bCul1ukFa8X2tTKysZFfONDgk=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=F/nwHVFxVRv3PMbZWQ1vgcXwU+vs+Q4iThj2en6ZJSiZCau3VTiHABr7V4BIUbB9kq WK6faWWqth6+jvBP3g13gRjQSZVUFUyusd1pGzk2uPJi/DQ/uA1nVy+r7b+0ylgibRfp l/x1uqRo8agYlIaqnPNJkvsyNz+xhNI5oqZiubQ8XxwrIfX92rgCrA1cGqawyYLi0jBe P8pMiU1aXdDruRzNCbVpNws98z8R1T+4+/QtMXo9zRG+8361S7NNgxDWiYpQSvIytXql 0KfJrNwaepBD1XPERe6w9nuUvU93mOeOYmyFGnu3weLlfOdu/x91t5fjkGsVuzObNZyg QHMw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=m3sYiDKo; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=Sr9VIHzy; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 5614622812f47-3feed1558f3si745888b6e.173.2025.03.25.12.58.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Mar 2025 12:58:07 -0700 (PDT) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=m3sYiDKo; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=Sr9VIHzy; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1txAPQ-0002XG-TL; Tue, 25 Mar 2025 19:58:00 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1txAPP-0002X9-7y for openvpn-devel@lists.sourceforge.net; Tue, 25 Mar 2025 19:57:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=MYAp3R8B71hfBLgDaNf2atjsCDvTV5RPvhKMNPdHLZc=; b=m3sYiDKo/zK3r4CRC08YNqXeW2 lL1GJWe85wD3BS/7ajh3QS5OL66YxE5eiNZsMAKBZXVN/tytJbSC9IfqbNUyKrNzIjo646Zvlpip3 x+cwSie4cvnW4tXPRIDJqfzRjI9tbT+8btX2LTH3oiPpecek+H9SKyAAzHjCqRSVpRCs=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=MYAp3R8B71hfBLgDaNf2atjsCDvTV5RPvhKMNPdHLZc=; b=Sr9VIHzyoSWeg+g6AQkhPvSUs1 /at6W4t6swRmMN0ilF3De4N4ivXgJ0lguNEuzv8Hhn/JaM10SXCG2otkH2ABb5qAXrJ+ACjr4uPEY uJ8Klfljzi0GKqrHYiy9j6IyHA7UbWL9ATCX1rFd85tv3UwXFWSJNM/AUmIprlQUu8tY=; Received: from dhcp-174.greenie.muc.de ([193.149.48.174] helo=blue.greenie.muc.de) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1txAPN-0001CU-CS for openvpn-devel@lists.sourceforge.net; Tue, 25 Mar 2025 19:57:58 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.17.1.9/8.17.1.9) with ESMTP id 52PJvowa008001 for ; Tue, 25 Mar 2025 20:57:50 +0100 Received: (from gert@localhost) by blue.greenie.muc.de (8.17.1.9/8.17.1.9/Submit) id 52PJvocZ008000 for openvpn-devel@lists.sourceforge.net; Tue, 25 Mar 2025 20:57:50 +0100 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Tue, 25 Mar 2025 20:57:43 +0100 Message-ID: <20250325195750.7899-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Score: 0.0 (/) X-Spam-Report: Spam detection software, running on the system "util-spamd-1.v13.lw.sourceforge.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Arne Schwabe 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 [...] Content analysis details: (0.0 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [193.149.48.174 listed in sa-trusted.bondedsender.org] 0.0 RCVD_IN_VALIDITY_RPBL_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [193.149.48.174 listed in bl.score.senderscore.com] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record X-Headers-End: 1txAPN-0001CU-CS Subject: [Openvpn-devel] [PATCH v4] Mention address if not unspecific on DNS failure X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1827563234500950572?= X-GMAIL-MSGID: =?utf-8?q?1827597386277364458?= From: Arne Schwabe 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 --- This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/909 This mail reflects revision 4 of this Change. Acked-by according to Gerrit (reflected above): Gert Doering 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 = "undefined"; } - fmt = "RESOLVE: Cannot resolve host address: %s:%s (%s)"; + fmt = "RESOLVE: Cannot resolve host address: %s:%s%s (%s)"; if ((flags & GETADDR_MENTION_RESOLVE_RETRY) && !resolve_retry_seconds) { - fmt = "RESOLVE: Cannot resolve host address: %s:%s (%s) " + fmt = "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 <= 0)