From patchwork Tue Sep 7 12:31:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Selva Nair X-Patchwork-Id: 1944 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director11.mail.ord1d.rsapps.net ([172.28.255.1]) by backend30.mail.ord1d.rsapps.net with LMTP id ysHrBYjoN2GNWAAAIUCqbw (envelope-from ) for ; Tue, 07 Sep 2021 18:32:40 -0400 Received: from proxy8.mail.ord1c.rsapps.net ([172.28.255.1]) by director11.mail.ord1d.rsapps.net with LMTP id sGzZBIjoN2FMUQAAvGGmqA (envelope-from ) for ; Tue, 07 Sep 2021 18:32:40 -0400 Received: from smtp24.gate.ord1c ([172.28.255.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy8.mail.ord1c.rsapps.net with LMTPS id OK5+BIjoN2HAKQAAHz/atg (envelope-from ) for ; Tue, 07 Sep 2021 18:32:40 -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: smtp24.gate.ord1c.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; dkim=fail (signature verification failed) header.d=gmail.com; dmarc=fail (p=none; dis=none) header.from=gmail.com X-Suspicious-Flag: YES X-Classification-ID: 81c1271c-102b-11ec-aab2-b8ca3a674470-1-1 Received: from [216.105.38.7] ([216.105.38.7:44548] helo=lists.sourceforge.net) by smtp24.gate.ord1c.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id A4/4E-36340-788E7316; Tue, 07 Sep 2021 18:32:39 -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 1mNjdD-00016A-Ge; Tue, 07 Sep 2021 22:31: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 1mNjdB-000164-CO for openvpn-devel@lists.sourceforge.net; Tue, 07 Sep 2021 22:31:53 +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=4zDFloCj9rgMgs814sk6iHyK+0scrrPI7574Vsd0boA=; b=U1cDpKjHdHYUsbdSyW7PapqIg/ 0E50nw0kpYfVNbkjtkCdDc82jrvpEkU38H9t3JyYCIl2c/Q0Uw2mKvucdm2nzbXShFQBc4VHJpy/r Gkgo26e4K5Q8zaQV/mlHZD3sTKizjx34ouSPtQO5lzK9yPeDk4GY0yd+QnwQCO7214rA=; 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=4zDFloCj9rgMgs814sk6iHyK+0scrrPI7574Vsd0boA=; b=jo/haBpNHeHWPwcx4U76avCvQ7 bvNUNKQXsv7MnCc5iorIcJvP7lpJtP/h5ZmZifuhPosUAkEcTRWfpXbg5vhkhf/RhUq+I/jC26H9H mRHVUBXUBz/8rFt0nphMsm6XB64dXGqvuZxI+L31/9FljwbyHV5+j4UaeHhBCQxGwhY0=; Received: from mail-il1-f173.google.com ([209.85.166.173]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92.3) id 1mNjd9-0005kt-Uf for openvpn-devel@lists.sourceforge.net; Tue, 07 Sep 2021 22:31:53 +0000 Received: by mail-il1-f173.google.com with SMTP id j15so272828ila.1 for ; Tue, 07 Sep 2021 15:31:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4zDFloCj9rgMgs814sk6iHyK+0scrrPI7574Vsd0boA=; b=O8d5S0lNL5voSn5TNjOaLO0AYq9QsTUZqYuzTX447uXip9WVL8WHT+c9vjDLXYqlFU clPw9/xfgYi7q8PmumDnCmROyVY695pBKEpTl8Yk/zfq4ars1ehnm/5jZ9A0ReOKYjEt MraF1/6wiMQ8EA0i6JGSf+tWheOxOWWrATOl5LikVCiclPIn6ofmTtSTMgJ06dHaF71I eBwdgyiyB9IePaYkO9ejVx5FpjXjYe+DWtbxemPIeWBRhyGY4EFBEzv/r6X2DZIXGtfV JLhwiZD98V6jk3zMzLc6/ZrH5FNTXg2ItGull+U/dBj5fQwXsyKf3ceHWvFOteDePpug H2+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4zDFloCj9rgMgs814sk6iHyK+0scrrPI7574Vsd0boA=; b=iiiGXV4tbUGCd+itsK1WWfPdgr5G1TXWBPms0yjeoVad//BcALYOpirGHQZoLa0e1I 2PN03s+q0zyccxo+ivMoQyjRlqJiZW5mgbwJPMqlW2daFI9wxp6DKWiZKJNKLX47z+Qf EeVedQcXARGsuZFw6YwkFXy9QsnHjnh0xUTH2EJEM39qXRrGNFQ1lIKbYHAaTgdG0KUf vvG4kKNjr7THPwBV68l5G1mPoZOJ/JJqMr+8Ci2Rv5SSEC95K83Jcm0wKTT+Gh2hvyxS MSF6JoBfzZXEeSJidAxTm+yWVcq+ijCRBOQeuwzMXKQ2utyYt++637QBNjvVjB/MzOai 767g== X-Gm-Message-State: AOAM533FKgnOfnetLa0Y0cwwHKkJvhQk2PnlKn41ndHdAesElAD2ad6b Tp8JGAyofdLdP6+NktRDmtxKdULIQio= X-Google-Smtp-Source: ABdhPJzAGcukdpxJtSRBMyQPsWD35Lrw5UkvFny1m2RAll+qfS3rZA8N/stH+BPM11tmyzSXpuhYaA== X-Received: by 2002:a05:6e02:198d:: with SMTP id g13mr378215ilf.319.1631053906230; Tue, 07 Sep 2021 15:31:46 -0700 (PDT) Received: from uranus.home.sansel.ca (bras-vprn-tnhlon4053w-lp130-02-70-51-223-174.dsl.bell.ca. [70.51.223.174]) by smtp.gmail.com with ESMTPSA id b10sm224405ils.13.2021.09.07.15.31.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Sep 2021 15:31:45 -0700 (PDT) From: selva.nair@gmail.com To: openvpn-devel@lists.sourceforge.net Date: Tue, 7 Sep 2021 18:31:25 -0400 Message-Id: <20210907223126.8440-2-selva.nair@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210907223126.8440-1-selva.nair@gmail.com> References: <20210825210232.22509-1-selva.nair@gmail.com> <20210907223126.8440-1-selva.nair@gmail.com> MIME-Version: 1.0 X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (selva.nair[at]gmail.com) -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.166.173 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.166.173 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-Headers-End: 1mNjd9-0005kt-Uf Subject: [Openvpn-devel] [PATCH v3 2/3] Permit unlimited connection entries and remotes 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 From: Selva Nair Currently we allow a max of 64 connection entries and remotes. A larger number would allow users with 100's of independent config files for different end points of same provider to consolidate them to connection entries. v2,v3: no change Signed-off-by: Selva Nair Acked-By: Arne Schwabe@rfc2549.org --- Changes.rst | 2 ++ src/openvpn/options.c | 34 ++++++++++++++++++++++++++++------ src/openvpn/options.h | 6 ++++-- 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/Changes.rst b/Changes.rst index fa5d5ffa..9b1fb294 100644 --- a/Changes.rst +++ b/Changes.rst @@ -4,6 +4,8 @@ Overview of changes in 2.6 New features ------------ +Support unlimited number of connection entries and remote entries + New management commands to enumerate and list remote entries Use ``remote-entry-count`` and ``remote-entry-get`` commands from the management interface to get the number of diff --git a/src/openvpn/options.c b/src/openvpn/options.c index f00b3019..38f97a39 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -888,6 +888,14 @@ init_options(struct options *o, const bool init_gc) void uninit_options(struct options *o) { + if (o->connection_list) { + free(o->connection_list->array); + CLEAR(*o->connection_list); + } + if (o->remote_list) { + free(o->remote_list->array); + CLEAR(*o->remote_list); + } if (o->gc_owned) { gc_free(&o->gc); @@ -1946,10 +1954,17 @@ alloc_connection_entry(struct options *options, const int msglevel) struct connection_list *l = alloc_connection_list_if_undef(options); struct connection_entry *e; - if (l->len >= CONNECTION_LIST_SIZE) + if (l->len == l->capacity) { - msg(msglevel, "Maximum number of 'connection' options (%d) exceeded", CONNECTION_LIST_SIZE); - return NULL; + int capacity = l->capacity + CONNECTION_LIST_SIZE; + struct connection_entry **ce = realloc(l->array, capacity*sizeof(struct connection_entry *)); + if (ce == NULL) + { + msg(msglevel, "Unable to process more connection options: out of memory. Number of entries = %d", l->len); + return NULL; + } + l->array = ce; + l->capacity = capacity; } ALLOC_OBJ_GC(e, struct connection_entry, &options->gc); l->array[l->len++] = e; @@ -1972,10 +1987,17 @@ alloc_remote_entry(struct options *options, const int msglevel) struct remote_list *l = alloc_remote_list_if_undef(options); struct remote_entry *e; - if (l->len >= CONNECTION_LIST_SIZE) + if (l->len == l->capacity) { - msg(msglevel, "Maximum number of 'remote' options (%d) exceeded", CONNECTION_LIST_SIZE); - return NULL; + int capacity = l->capacity + CONNECTION_LIST_SIZE; + struct remote_entry **re = realloc(l->array, capacity*sizeof(struct remote_entry *)); + if (re == NULL) + { + msg(msglevel, "Unable to process more remote options: out of memory. Number of entries = %d", l->len); + return NULL; + } + l->array = re; + l->capacity = capacity; } ALLOC_OBJ_GC(e, struct remote_entry, &options->gc); l->array[l->len++] = e; diff --git a/src/openvpn/options.h b/src/openvpn/options.h index b0e40cb7..98977d41 100644 --- a/src/openvpn/options.h +++ b/src/openvpn/options.h @@ -168,15 +168,17 @@ struct remote_entry struct connection_list { + int capacity; int len; int current; - struct connection_entry *array[CONNECTION_LIST_SIZE]; + struct connection_entry **array; }; struct remote_list { + int capacity; int len; - struct remote_entry *array[CONNECTION_LIST_SIZE]; + struct remote_entry **array; }; enum vlan_acceptable_frames