From patchwork Wed Apr 25 09:57:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 320 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director7.mail.ord1d.rsapps.net ([172.27.255.54]) by backend30.mail.ord1d.rsapps.net (Dovecot) with LMTP id 2F4GBzTe4FrkSwAAIUCqbw for ; Wed, 25 Apr 2018 15:59:48 -0400 Received: from proxy16.mail.iad3a.rsapps.net ([172.27.255.54]) by director7.mail.ord1d.rsapps.net (Dovecot) with LMTP id i/03GjTe4FoKZwAAovjBpQ ; Wed, 25 Apr 2018 15:59:48 -0400 Received: from smtp39.gate.iad3a ([172.27.255.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy16.mail.iad3a.rsapps.net with LMTP id UB8yGDTe4FoFGgAADc5QwQ ; Wed, 25 Apr 2018 15:59:48 -0400 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp39.gate.iad3a.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dmarc=none (p=nil; dis=none) header.from=unstable.cc X-Suspicious-Flag: YES X-Classification-ID: 3464e5f4-48c3-11e8-ac8e-525400eea4e4-1-1 Received: from [216.105.38.7] ([216.105.38.7:16201] helo=lists.sourceforge.net) by smtp39.gate.iad3a.rsapps.net (envelope-from ) (ecelerity 4.2.1.56364 r(Core:4.2.1.14)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id AD/16-18310-33ED0EA5; Wed, 25 Apr 2018 15:59:47 -0400 Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1fBQZI-0008T1-1z; Wed, 25 Apr 2018 19:59:08 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1fBQZH-0008Sf-Cq for openvpn-devel@lists.sourceforge.net; Wed, 25 Apr 2018 19:59:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: 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=mdkeJNVp1X0wNmfWns0+vZVDzkTG0gwcrPIVTjQiFPk=; b=JQsqW7ra+RaI1m7nAAPI8pwlFE 1y4eOnMYBcFrS7drtA+1v754EVK0sBuFYKrDlfm7wMlxLNcx0rOZ7/A0RqYKOoWuAsi8CqT+vd8pV umq56IUhReL3TNJedo2fYmRT+h+xAhSihj1scz0RoTtt27tLc5Vqhxku67HCziCJJMU0=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To :MIME-Version:Content-Type:Content-Transfer-Encoding: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=mdkeJNVp1X0wNmfWns0+vZVDzkTG0gwcrPIVTjQiFPk=; b=jthBj6Oxi1YvJUGGQiOa7twrmq lU5gxEDUbTrQxNv1XR/MMoEK/8FmQApf1MmKFRkldmcEykEGRNI+DX6R4FIPemm8orhjVvij+jLCf xjPbSBzSw5l6rT0s5qQKI366g0gKqxr9/W4X3xkigt1hd64sv80hGhdhRUGjXV1LXLkI=; Received: from s2.neomailbox.net ([5.148.176.60]) by sfi-mx-3.v28.lw.sourceforge.com with esmtps (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) id 1fBQZF-00Bt3y-8F for openvpn-devel@lists.sourceforge.net; Wed, 25 Apr 2018 19:59:06 +0000 From: Antonio Quartulli To: openvpn-devel@lists.sourceforge.net Date: Thu, 26 Apr 2018 03:57:22 +0800 Message-Id: <20180425195722.20744-9-a@unstable.cc> In-Reply-To: <20180425195722.20744-1-a@unstable.cc> References: <20180425195722.20744-1-a@unstable.cc> X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [5.148.176.60 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record X-Headers-End: 1fBQZF-00Bt3y-8F Subject: [Openvpn-devel] [RFC 8/8] 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: , Cc: Antonio Quartulli MIME-Version: 1.0 Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox 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. Signed-off-by: Antonio Quartulli --- src/openvpn/socket.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c index 9d961347..3dd44b83 100644 --- a/src/openvpn/socket.c +++ b/src/openvpn/socket.c @@ -378,9 +378,8 @@ openvpn_getaddrinfo(unsigned int flags, signal_received = &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) @@ -408,6 +407,10 @@ openvpn_getaddrinfo(unsigned int flags, 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); @@ -1599,6 +1602,10 @@ resolve_bind_local(struct link_socket *sock, const sa_family_t af) 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);