From patchwork Tue Dec 24 12:16:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 4014 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:998b:b0:5e7:b9eb:58e8 with SMTP id d11csp4577606mav; Tue, 24 Dec 2024 04:17:03 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUSBWN5oSqt5P0fCY7n/Jy0+KIeYYjlseZF4dW7S1AE6527naWg/wBiFomI7MnwJS9QFSl5kyF9VIE=@openvpn.net X-Google-Smtp-Source: AGHT+IFC7voXrcNxip7UUEQrFGfDjKIaeWsdRXKzLyHprtjmUBIsFEKwMYLjZFYjEUu1WxZF4uxh X-Received: by 2002:a05:6871:82c:b0:29e:3d2a:a4a9 with SMTP id 586e51a60fabf-2a7d113e2c8mr10157494fac.5.1735042623769; Tue, 24 Dec 2024 04:17:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735042623; cv=none; d=google.com; s=arc-20240605; b=dQaG457GoP/wKFYRlwnhLugFTYufuT9yS4ktr6HWEXTaticPFzjcnBJJ6MBPvJ1xr5 sq5XS5Q6lvE/E0Ta9v+EcBTJ8htzAAlui1oevACNwcFgN0i2esY30V2OPjv5q9pveDMf 6aQppANIWX3ZRgImRD7fzv9T6HR+OQzlcexApMaJKwmKppEO4u+jWVY2dRKcn1D9wLw3 6FVvUJmMXEK86KRKoonHPlAz1mFrreVXb3CD5kG/lHVtt5Kq8hl1QzWUZ6ZlR01rMRUL hJUOK+kAQ07eExYV/YV4oYLf6od9zf39dlOi25bHBMvK3VMIU0C/CqeJrI4Orb7koFUy 8wUw== 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=KWxgdqcwcnkrE1EttJ2zckIDL48LNt5kX+NdCvhqvzc=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=GuUAsg2glYF2p6lu99yV5T03vAzidL+7D87TTu+VM2NxM5JX2W2vjAc5gRLm0CKbOe /kruHfNLZl6sapDc5QMc9LRw5L3uAniQNijjIKyWefWmv2k5GQeZX2SXvQ+b7MhskBPx wIB1qYyP1bWtbX0/zk74UeumkuQCLio/eC4ReOtwHcicJycO9Rhw9lbEESCWzXFwDpd1 UXrX+6u6aEJLxEoHEYKPsfO/YrwsF3qWxqk1ZrsgP5xsT9EYds7og6NJYN2m1WMLXY5+ IfMO+2Ep9FNYZ9mPBkOAqzu8zn6IpNeU6tt9ePU2UBZddpyTFgBI9WRwIk6Q4LginlKt eqwQ==; 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=IFq6rwsN; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=S5m9WKVz; 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 586e51a60fabf-2a7d749a9e9si7631385fac.52.2024.12.24.04.17.03 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Dec 2024 04:17:03 -0800 (PST) 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=IFq6rwsN; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=S5m9WKVz; 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-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1tQ3qL-0003oj-T7; Tue, 24 Dec 2024 12:16:58 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1tQ3qJ-0003oS-Ox for openvpn-devel@lists.sourceforge.net; Tue, 24 Dec 2024 12:16:56 +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=rUsw9XyYSb2JvnQoemK8dACBoGINPDwERUjej9z25R8=; b=IFq6rwsNfOvlOHmEGvDNcKccKz eEZ3WThRK45HuzmopleJ7kXbID92f2t0DwXreBSfluX9OKpuso2c5gtxHPno1x4nONOc5iy0ZnZim tf99jwlqySGIYzRcNgXY+BPr7baf8NeYgZBJR0Z09CXr1qv0ckEgEUv052eqzh6fPJMs=; 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=rUsw9XyYSb2JvnQoemK8dACBoGINPDwERUjej9z25R8=; b=S5m9WKVzO2/XXTe8JtZM6CvTwm mkRXkFEXY0T8k1y82DSnUjBhxt4DcJzYohgGjcuWb2SkVEBAcdoxgawvKdb+lfdbQTQLUxmS52AEt B8z/J7s2bTgGqxG8OXkEM9cP1YEKv6bKVVHvdXHbOJCOBkRK5cNelcHkoQ0Ge5aVPEio=; 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 1tQ3qI-0001M9-Ui for openvpn-devel@lists.sourceforge.net; Tue, 24 Dec 2024 12:16:56 +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 4BOCGghn029985 for ; Tue, 24 Dec 2024 13:16:42 +0100 Received: (from gert@localhost) by blue.greenie.muc.de (8.17.1.9/8.17.1.9/Submit) id 4BOCGgrd029984 for openvpn-devel@lists.sourceforge.net; Tue, 24 Dec 2024 13:16:42 +0100 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Tue, 24 Dec 2024 13:16:40 +0100 Message-ID: <20241224121640.29973-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 This change ensures that when a numeric IP address is specified as argument to a 'local' directive, its ai_family overrides the one extracted from the 'proto' config option. 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-accredit.habeas.com] 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: 1tQ3qI-0001M9-Ui Subject: [Openvpn-devel] [PATCH v7] override ai_family if 'local' numeric address was specified 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?1819324054327917395?= X-GMAIL-MSGID: =?utf-8?q?1819324054327917395?= From: Antonio Quartulli This change ensures that when a numeric IP address is specified as argument to a 'local' directive, its ai_family overrides the one extracted from the 'proto' config option. Change-Id: Ie2471e6b2d6974e70423b09918ad1c2136253754 Signed-off-by: Antonio Quartulli Signed-off-by: Gianmarco De Gregori 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/+/762 This mail reflects revision 7 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 7921433..966dade 100644 --- a/src/openvpn/socket.c +++ b/src/openvpn/socket.c @@ -488,9 +488,8 @@ sig_info = &sigrec; } - /* try numeric ipv6 addr first */ + /* try numeric ip addr first */ CLEAR(hints); - hints.ai_family = ai_family; hints.ai_flags = AI_NUMERICHOST; if (flags & GETADDR_PASSIVE) @@ -518,6 +517,10 @@ const char *fmt; int level = 0; + /* this is not a numeric IP, therefore force resolution using the + * provided ai_family */ + hints.ai_family = ai_family; + if (hostname && (flags & GETADDR_RANDOMIZE)) { hostname = hostname_randomize(hostname, &gc); @@ -1716,6 +1719,10 @@ sock->local_host, sock->local_port, 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; } gc_free(&gc);