From patchwork Tue Mar 25 09:01:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 4193 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:81e:b0:60a:d70a:d3c7 with SMTP id jj30csp2388139mab; Tue, 25 Mar 2025 02:01:49 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWkFbtKJdG4uFdDy4X3X8xS6xL6VoMbGxtAyv1HqCpe0OQcDBIHzknE5SE1z5qLzuqAQEHRHcw8YCs=@openvpn.net X-Google-Smtp-Source: AGHT+IHJHJW9CxoROMTII+RIKWRpo79c3FCpdyiqh+kvunMWzry9RAc2EqS8P4ZIHmJBtLJ25Vjp X-Received: by 2002:a05:6808:18a1:b0:3f9:438f:1d91 with SMTP id 5614622812f47-3febf792c45mr10874106b6e.35.1742893309387; Tue, 25 Mar 2025 02:01:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1742893309; cv=none; d=google.com; s=arc-20240605; b=DM2VRytfidjPM0wCyXtgKWtaGsauGXkFRo9MxIIKtNZLqgkJzdEVkqtCA+jNMEc/kx KEvCx9NyW2GZLTuS9UT+4LNvixmYqoqlIUBd9BssmKJf7AJ4n1V5qJk354ZTgBKheTQD x9o1rEbX2w94U7nonAVsmaA61WfB2QvN33k3Zn0FG94LWXsv+TB4efH/Hvqd7sY+2q3k 9uT03+Jtf4uKoLTr0ALWOs9+DLejHnxL/wmPOJkCiNXo5PSnKOHtDT1YruBuYT3nI+oT /FkOMrP8YzNQ6inwF0CYgZABHIkUYY9e39QjIWi/3eUwkRIg1oajs2NEh51nWEzwu/of Gbfw== 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=RXxH/P2R2Vk0zzjlJzi1Y3fViem9bGZluiaG+m2wlug=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=YO9hAQv9SVn7z5U7Y+0vzEL2YGLjhE2tavHKoyXtkZEAvlgmv+oGfi2j5/mzme1I9P Tr9jCnt51PbkMVIzsRsFMxeM8s3WnIlXsv2oshpiAMy7E6LJJf9/wfsYCmerNcbPY0/g QdI17WmL4jdIpn8Ml6DRInQsFhbz3iaMn4ugAGGuu6LsGzxDJs4TJhRIBM34m/oEP3Qj m9lrBGu5nuKNxhm5+p9t5d70KbS8zIMlqDkgIZe/wZklYh6jY59R5eclayfjs0SAzMBz HQ+gYYoNT+bvjv5JmgYuI192HLp5vA4q3wkVpPgF+461YpOG3YXL+IZ912y/8iYVP51g EAEg==; 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="AHxhz/No"; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=SngodAWa; 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-3febf69ba2csi6352932b6e.59.2025.03.25.02.01.48 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Mar 2025 02:01:49 -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="AHxhz/No"; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=SngodAWa; 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-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1tx0AJ-0004DT-O4; Tue, 25 Mar 2025 09:01:44 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1tx0AH-0004DA-HS for openvpn-devel@lists.sourceforge.net; Tue, 25 Mar 2025 09:01:42 +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=CFQ3f8P+1M8s6/Y+tRuntF+YBZOsxrpBldc76bkQkzA=; b=AHxhz/No0/qngEyVCIye35ROiL nK2P0UiLhr6PEVuxNEPvmJux9+Q3gBVrlhCPFKHDtpqNnAqBV9onoIs9ztR1HlTRkMvWEdwvdm8UM qcSOAbHptQvCC041epRjoTvl4BBADW7Wx0FDBnfg6ws1DXBfAn8dEVsecYHQuT+d14ow=; 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=CFQ3f8P+1M8s6/Y+tRuntF+YBZOsxrpBldc76bkQkzA=; b=SngodAWag/JD5BTPfAm0P20dMY T7c+Pon4/VP0B5saTqbzzJsCl8XPCaPV5uVw6d0OIiln14hs2QS2bPfsb+4RE3k46FP358UD2wBww eQT82DImh/DVVy1Fov6ochjKYWcRON5uWLn5QvPgQnrJAVTqWZBoNkfu6jtnPdB+v2h4=; 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 1tx0A9-0000AN-W1 for openvpn-devel@lists.sourceforge.net; Tue, 25 Mar 2025 09:01:42 +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 52P91MkP028928 for ; Tue, 25 Mar 2025 10:01:22 +0100 Received: (from gert@localhost) by blue.greenie.muc.de (8.17.1.9/8.17.1.9/Submit) id 52P91MHl028927 for openvpn-devel@lists.sourceforge.net; Tue, 25 Mar 2025 10:01:22 +0100 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Tue, 25 Mar 2025 10:01:15 +0100 Message-ID: <20250325090121.28813-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-2.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: Antonio Quartulli 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. Content analysis details: (0.0 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_VALIDITY_SAFE_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_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record X-Headers-End: 1tx0A9-0000AN-W1 Subject: [Openvpn-devel] [PATCH v2] socket: don't transfer bind family to socket in case of ANY address 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?1827556094437788568?= X-GMAIL-MSGID: =?utf-8?q?1827556094437788568?= From: Antonio Quartulli 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 Acked-by: Arne Schwabe --- 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/+/907 This mail reflects revision 2 of this Change. Acked-by according to Gerrit (reflected above): Arne Schwabe diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c index 6b32e30..be7395d 100644 --- a/src/openvpn/socket.c +++ b/src/openvpn/socket.c @@ -1724,9 +1724,19 @@ gai_strerror(status)); } - /* the resolved 'local entry' might have a different family than what - * was globally configured */ - sock->info.af = sock->info.lsa->bind_local->ai_family; + /* the address family returned by openvpn_getaddrinfo() should be + * taken into consideration only if we really passed an hostname + * to resolve. Otherwise its value is not useful to us and may + * actually break our socket, i.e. when it returns AF_INET + * but our remote is v6 only. + */ + if (sock->local_host) + { + /* the resolved 'local entry' might have a different family than + * what was globally configured + */ + sock->info.af = sock->info.lsa->bind_local->ai_family; + } } gc_free(&gc);