From patchwork Wed Sep 16 22:59:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 1460 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director12.mail.ord1d.rsapps.net ([172.27.255.52]) by backend30.mail.ord1d.rsapps.net with LMTP id OOgOHL4lY1+pGQAAIUCqbw (envelope-from ) for ; Thu, 17 Sep 2020 05:00:46 -0400 Received: from proxy2.mail.iad3a.rsapps.net ([172.27.255.52]) by director12.mail.ord1d.rsapps.net with LMTP id oBTpG74lY1/gaAAAIasKDg (envelope-from ) for ; Thu, 17 Sep 2020 05:00:46 -0400 Received: from smtp4.gate.iad3a ([172.27.255.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy2.mail.iad3a.rsapps.net with LMTPS id eO3pFL4lY1+1OQAABcWvHw (envelope-from ) for ; Thu, 17 Sep 2020 05:00:46 -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: smtp4.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=greenie.muc.de X-Suspicious-Flag: YES X-Classification-ID: 45614ef2-f8c4-11ea-a4cc-5254003c557e-1-1 Received: from [216.105.38.7] ([216.105.38.7:49476] helo=lists.sourceforge.net) by smtp4.gate.iad3a.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 3F/58-22996-DB5236F5; Thu, 17 Sep 2020 05:00:45 -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 1kIplj-0002Qp-NY; Thu, 17 Sep 2020 08:59:55 +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 1kIpli-0002Qi-2H for openvpn-devel@lists.sourceforge.net; Thu, 17 Sep 2020 08:59:54 +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=Mo5KrF1qNhh00L7LvoU9uhoHmJYGoF37zKOWQUpTGrA=; b=WZxJxS1PSBl3mSMkgbe3QhLJvD BiRVd+5kfsihUMPDinEtj1py1a6h33aYQFXE7iUCpVPhZj8x5u7ewdetUUWg6/qAvGZzPGSCDNtoE tlPNSMdANSpa7XbK+eUdO4qBfx/r2NPcBg1Ixshg3DWlLYtIJCjhtrQxdhQ438gjAZCw=; 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=Mo5KrF1qNhh00L7LvoU9uhoHmJYGoF37zKOWQUpTGrA=; b=BkvOOpG3t/0IthjrM/w4NdepEJ 24S/OmbYdfY5N25DPzWsxj/08PzonE0a8j5Tk83/G0ezNIitKUD7V/TAD7iGh9Y2L7ZE265w90ZT0 9Pn+idYPQ6NcB+xFcZxfuBsYONVXmCcHgtfC/GoE/NEPbnpNjUnYpKWskTPOXSJSEzQE=; Received: from dhcp-174.greenie.muc.de ([193.149.48.174] helo=blue.greenie.muc.de) by sfi-mx-3.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1kIpld-00CkSk-39 for openvpn-devel@lists.sourceforge.net; Thu, 17 Sep 2020 08:59:53 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.15.2/8.14.9) with ESMTP id 08H8xg7d021020 for ; Thu, 17 Sep 2020 10:59:42 +0200 Received: (from gert@localhost) by blue.greenie.muc.de (8.15.2/8.14.9/Submit) id 08H8xgTp021019 for openvpn-devel@lists.sourceforge.net; Thu, 17 Sep 2020 10:59:42 +0200 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Thu, 17 Sep 2020 10:59:41 +0200 Message-Id: <20200917085941.20972-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200911115916.16117-1-gert@greenie.muc.de> References: <20200911115916.16117-1-gert@greenie.muc.de> MIME-Version: 1.0 X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record X-Headers-End: 1kIpld-00CkSk-39 Subject: [Openvpn-devel] [PATCH v2] If IPv6 pool specification sets pool start to ::0 address, increment. 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 The first IPv6 address in a subnet is not usable (IPv6 anycast address), but our pool code ignored this. Instead of assigning an unusable address or erroring out, just log the fact, and increment the pool start to ::1 NOTE: this is a bit simplistic. A pool that is larger than /96 and has non-0 bits in the "uppermost bits" will still get the increment as we only look at the lowermost 32 bits. NOTE2: if the pool is specified with "--server-ipv6 $base/$bits", this is a non-issue, as the address for the pool start will be incremented anyway. v2: make comment more explicit about "we're only talking about the host part here" and "base sees only only 32 bit of the host part" Reported-by: NicolaF_ in Trac Trac: #1282 Signed-off-by: Gert Doering Acked-by: Antonio Quartulli --- doc/man-sections/server-options.rst | 3 ++- src/openvpn/pool.c | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/doc/man-sections/server-options.rst b/doc/man-sections/server-options.rst index 2009953c..56ffff9a 100644 --- a/doc/man-sections/server-options.rst +++ b/doc/man-sections/server-options.rst @@ -204,7 +204,8 @@ fast hardware. SSL/TLS authentication must be used in this mode. ifconfig-ipv6-pool ipv6addr/bits The pool starts at ``ipv6addr`` and matches the offset determined from - the start of the IPv4 pool. + the start of the IPv4 pool. If the host part of the given IPv6 + address is ``0``, the pool starts at ``ipv6addr`` +1. --ifconfig-pool-persist args Persist/unpersist ifconfig-pool data to ``file``, at ``seconds`` diff --git a/src/openvpn/pool.c b/src/openvpn/pool.c index 1f74ac57..2c5dd72d 100644 --- a/src/openvpn/pool.c +++ b/src/openvpn/pool.c @@ -224,6 +224,24 @@ ifconfig_pool_init(const bool ipv4_pool, enum pool_type type, in_addr_t start, } pool->ipv6.base = ipv6_base; + + /* if a pool starts at a base address that has all-zero in the + * host part, that first IPv6 address must not be assigned to + * clients because it is not usable (subnet anycast address). + * Start with 1, then. + * + * NOTE: this will also (mis-)fire for something like + * ifconfig-ipv6-pool 2001:db8:0:1:1234::0/64 + * as we only check the rightmost 32 bits of the host part. So be it. + */ + if (base == 0) + { + msg(D_IFCONFIG_POOL, "IFCONFIG POOL IPv6: incrementing pool start " + "to avoid ::0 assignment"); + base++; + pool->ipv6.base.s6_addr[15]++; + } + pool_ipv6_size = ipv6_netbits >= 112 ? (1 << (128 - ipv6_netbits)) - base : IFCONFIG_POOL_MAX;