From patchwork Mon Jun 8 05:46:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 1148 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director12.mail.ord1d.rsapps.net ([172.31.255.6]) by backend30.mail.ord1d.rsapps.net with LMTP id ULklCM1d3l5PTwAAIUCqbw for ; Mon, 08 Jun 2020 11:48:29 -0400 Received: from proxy16.mail.iad3b.rsapps.net ([172.31.255.6]) by director12.mail.ord1d.rsapps.net with LMTP id aGFFBc1d3l7QLgAAIasKDg ; Mon, 08 Jun 2020 11:48:29 -0400 Received: from smtp17.gate.iad3b ([172.31.255.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy16.mail.iad3b.rsapps.net with LMTP id wOGCOsxd3l7LIwAAPj+4aA ; Mon, 08 Jun 2020 11:48:28 -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: smtp17.gate.iad3b.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: 7ecc49e0-a99f-11ea-8585-52540094e46f-1-1 Received: from [216.105.38.7] ([216.105.38.7:37834] helo=lists.sourceforge.net) by smtp17.gate.iad3b.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id B4/19-29993-CCD5EDE5; Mon, 08 Jun 2020 11:48:28 -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 1jiK06-0006N5-Mg; Mon, 08 Jun 2020 15:47:50 +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 1jiK04-0006Mx-Pg for openvpn-devel@lists.sourceforge.net; Mon, 08 Jun 2020 15:47:48 +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:Cc:To:From:Sender:Reply-To: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=k0gPGUt0QX6Y8ix+1GIefCKpt5XLmRQVcFJTY0YsidU=; b=iRFYeyk0CkdLjgPL00esOCTSNg YFrvkK9WJlZ5wcaZFnkhzdfd+RvSQ53oiIaEiHEfeJfDj62FcP9wvoKB2+8S1+DaDLF/p4DQ5wjk2 vmiOXHYsdEdaqD/LWVbjCfXITmePVaEGQHO+/cacHY3t7OKUpKSYDDiSHAkwEdUtDkNQ=; 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:Cc:To:From:Sender:Reply-To: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=k0gPGUt0QX6Y8ix+1GIefCKpt5XLmRQVcFJTY0YsidU=; b=ZDrqFwT67vIHgytBdjgbF8QPCc i0ZvnSfy7aqRrJKIV1yt1oqZwv1zkitodCkVo0bGLZJAINT3qpMMJmz30gjnzVc/Vz1xpfg7KET4z SqrL6CSe9Tr7gtkXxsYxxNg2Aoy0uUnZ982ysTLCsZCrhqmIYXxcoP07jukRQfrJ0d5M=; 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.92.2) id 1jiK02-00Dchk-SL for openvpn-devel@lists.sourceforge.net; Mon, 08 Jun 2020 15:47:48 +0000 From: Antonio Quartulli To: openvpn-devel@lists.sourceforge.net Date: Mon, 8 Jun 2020 17:46:50 +0200 Message-Id: <20200608154650.26475-1-a@unstable.cc> In-Reply-To: <20200607105939.GF1431@greenie.muc.de> References: <20200607105939.GF1431@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 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: unstable.cc] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1jiK02-00Dchk-SL Subject: [Openvpn-devel] [PATCH v5] ipv6-pool: get rid of size constraint 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 Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox Signed-off-by: Antonio Quartulli --- Changes from v4: - make the base computation depending on the size of the pool: - large pools will still start at +0x1000 (backward compatible) - smaller pools will start at +2 src/openvpn/helper.c | 21 +++++++++++++++++---- src/openvpn/options.c | 13 +++++++++---- src/openvpn/pool.c | 12 ++++++++++++ 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/src/openvpn/helper.c b/src/openvpn/helper.c index 277e6972..e353d5b7 100644 --- a/src/openvpn/helper.c +++ b/src/openvpn/helper.c @@ -198,12 +198,25 @@ helper_client_server(struct options *o) print_in6_addr( add_in6_addr( o->server_network_ipv6, 2), 0, &o->gc ); o->ifconfig_ipv6_netbits = o->server_netbits_ipv6; - /* pool starts at "base address + 0x1000" - leave enough room */ - ASSERT( o->server_netbits_ipv6 <= 112 ); /* want 16 bits */ + /* basic sanity check */ + ASSERT(o->server_netbits_ipv6 >= 64 && o->server_netbits_ipv6 <= 124); o->ifconfig_ipv6_pool_defined = true; - o->ifconfig_ipv6_pool_base = - add_in6_addr( o->server_network_ipv6, 0x1000 ); + /* For large enough pools we keep the original behaviour of adding + * 0x1000 when computing the base. + * + * Smaller pools can't get that far, therefore we just increase by 2 + */ + if (o->server_netbits_ipv6 < 112) + { + o->ifconfig_ipv6_pool_base = add_in6_addr(o->server_network_ipv6, + 0x1000); + } + else + { + o->ifconfig_ipv6_pool_base = add_in6_addr(o->server_network_ipv6, + 2); + } o->ifconfig_ipv6_pool_netbits = o->server_netbits_ipv6; push_option( o, "tun-ipv6", M_USAGE ); diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 018f6f18..9d3a8dfe 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -6718,9 +6718,12 @@ add_option(struct options *options, msg(msglevel, "error parsing --server-ipv6 parameter"); goto err; } - if (netbits < 64 || netbits > 112) + if (netbits < 64 || netbits > 124) { - msg( msglevel, "--server-ipv6 settings: only /64../112 supported right now (not /%d)", netbits ); + msg(msglevel, + "--server-ipv6 settings: network must be between /64 and /124 (not /%d)", + netbits); + goto err; } options->server_ipv6_defined = true; @@ -6840,9 +6843,11 @@ add_option(struct options *options, msg(msglevel, "error parsing --ifconfig-ipv6-pool parameters"); goto err; } - if (netbits < 64 || netbits > 112) + if (netbits < 64 || netbits > 124) { - msg( msglevel, "--ifconfig-ipv6-pool settings: only /64../112 supported right now (not /%d)", netbits ); + msg(msglevel, + "--ifconfig-ipv6-pool settings: network must be between /64 and /124 (not /%d)", + netbits); goto err; } diff --git a/src/openvpn/pool.c b/src/openvpn/pool.c index 4e303712..29667623 100644 --- a/src/openvpn/pool.c +++ b/src/openvpn/pool.c @@ -207,6 +207,12 @@ ifconfig_pool_init(const bool ipv4_pool, enum pool_type type, in_addr_t start, ASSERT(0); } + if (pool->ipv4.size < 2) + { + msg(M_FATAL, "IPv4 pool size is too small (%d), must be at least 2", + pool->ipv4.size); + } + msg(D_IFCONFIG_POOL, "IFCONFIG POOL IPv4: base=%s size=%d", print_in_addr_t(pool->ipv4.base, 0, &gc), pool->ipv4.size); } @@ -245,6 +251,12 @@ ifconfig_pool_init(const bool ipv4_pool, enum pool_type type, in_addr_t start, ? (1 << (128 - ipv6_netbits)) - base : IFCONFIG_POOL_MAX; + if (pool->ipv6.size < 2) + { + msg(M_FATAL, "IPv6 pool size is too small (%d), must be at least 2", + pool->ipv6.size); + } + msg(D_IFCONFIG_POOL, "IFCONFIG POOL IPv6: base=%s size=%d netbits=%d", print_in6_addr(pool->ipv6.base, 0, &gc), pool->ipv6.size, ipv6_netbits);