From patchwork Wed Aug 25 11:02:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Selva Nair X-Patchwork-Id: 1923 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director13.mail.ord1d.rsapps.net ([172.27.255.54]) by backend30.mail.ord1d.rsapps.net with LMTP id gAxHOziwJmHSRQAAIUCqbw (envelope-from ) for ; Wed, 25 Aug 2021 17:03:52 -0400 Received: from proxy1.mail.iad3a.rsapps.net ([172.27.255.54]) by director13.mail.ord1d.rsapps.net with LMTP id mM8ROziwJmE+EAAA91zNiA (envelope-from ) for ; Wed, 25 Aug 2021 17:03:52 -0400 Received: from smtp39.gate.iad3a ([172.27.255.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy1.mail.iad3a.rsapps.net with LMTPS id mMZ1NTiwJmEtFwAA8TVjwQ (envelope-from ) for ; Wed, 25 Aug 2021 17:03:52 -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; 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: f31fd758-05e7-11ec-866f-525400eea4e4-1-1 Received: from [216.105.38.7] ([216.105.38.7:57598] helo=lists.sourceforge.net) by smtp39.gate.iad3a.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 18/5B-03332-830B6216; Wed, 25 Aug 2021 17:03:52 -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 1mJ030-0003lh-O3; Wed, 25 Aug 2021 21:02:58 +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 1mJ02z-0003lb-Sv for openvpn-devel@lists.sourceforge.net; Wed, 25 Aug 2021 21:02:57 +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=cfgGutxLLr5XpUiqGET1aZdJvz/CM2oqLykj1Bn2U/s=; b=ciDxq5uuBywyXUqd/leMqQLUWR 1VnXAqxHSibS8FHKYbBVIBeRTTYg/OBdfltZwz3kbx5yVi/K9foLOvfrCad0gVZMj8SwHX/rPziz6 FH/vp07/web5GL+jkZGAwbuAxdeR6UfqMmTqC2XRWr45dXjc4uCfwqQRuKvvm53Q5jOE=; 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=cfgGutxLLr5XpUiqGET1aZdJvz/CM2oqLykj1Bn2U/s=; b=iME4V8gE+0U/G77rGmL3iH4Ytq HmsDDgl5o0MUPt8hf1P/Ff6tUCnjUYG4Ab1X8nVg4zRP8N0xNLSidKFr9cKGV7a7qR4HoYrDQ5p1B ub3lwHiNXC3ru302GSV614IwiNGrx41z0PBUi91/VikYwI9sU5AYmz6wN9fpoWMPt9LI=; Received: from mail-qt1-f175.google.com ([209.85.160.175]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92.3) id 1mJ02y-00060y-8W for openvpn-devel@lists.sourceforge.net; Wed, 25 Aug 2021 21:02:57 +0000 Received: by mail-qt1-f175.google.com with SMTP id l3so649260qtk.10 for ; Wed, 25 Aug 2021 14:02:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cfgGutxLLr5XpUiqGET1aZdJvz/CM2oqLykj1Bn2U/s=; b=S7Mxvb9MybCkkKOaza23ekcK5GOztHvsYcgCjHLT2CRLZOKVon8b7/8kuswO0Od4fd eiwaHfwnhWzQ0haHIotUNx+tWFi5vC16SLMO259tB8jHmNaA8IxVlhtvy0ho43JikHlk Irp5hKZJa97v4/ZPAws7LNbmUZ74BL39g3ZOpILZ07nXD9uV424QdeqTai2NxRcUHPhk YKIhHLEi2uI8TmDgoPDT8PsmCkiVfPyYpyCHaoLp2XZkoAF784MHK3OquykfOCThtXBv aPjVtk4LjBv31JvGL++UZ/WdRD9YJUH2alMZ4d887ZLE8IOPrsHneK81HFhLY6lOAiwV sdZQ== 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=cfgGutxLLr5XpUiqGET1aZdJvz/CM2oqLykj1Bn2U/s=; b=IUu5qL9+sGSKNUTc/hySxPEs55SQ2iJaoh2EXyRjxLX+/ZRg7mwoGXDwR6HX23WixP 8qU0gCeK+0e9x6WmcG+SCcoDWYd3UmwsrhFU/3g0YqdJq7L/QT33IeIDh6TDJyF6+u3d IWB4wJLvgOHMKMVM9/e/34jjZEHjsWPQ4ZFOJzKOAOnt9Ew4xi+Z9h/kNtsYoASTz8N6 +l8a78+qy3NavREZpII809c9IzN+S8MWz9AHTF77JciETfk4O8Jp+I3iP6wTTN6eFyL6 2c/MEIjS11D3uhaHZaEvakTjV4RJeiXqVpkX/iz7zqxR5Yh14Qgo7t6q0bK+v8W0GO6z UOwQ== X-Gm-Message-State: AOAM533Vm/jpzT9tO/sGQ9PlAs7gnGgIWIRCFSKAGatEmGL4M/Ei3uhl iDh1ZiO0IuQ+He2ieS5SdAjUsHvQsHK103cT X-Google-Smtp-Source: ABdhPJwpO7UPMgWYUptSMMZs8rDRWTFkEX3aPSHGFQqXUNz8h+Ni8NK0fpXJ3dUB3zrNEz9+iSZzzA== X-Received: by 2002:ac8:7ca3:: with SMTP id z3mr212661qtv.109.1629925370200; Wed, 25 Aug 2021 14:02:50 -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 o7sm527549qtw.87.2021.08.25.14.02.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Aug 2021 14:02:49 -0700 (PDT) From: selva.nair@gmail.com To: openvpn-devel@lists.sourceforge.net Date: Wed, 25 Aug 2021 17:02:31 -0400 Message-Id: <20210825210232.22509-2-selva.nair@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210825210232.22509-1-selva.nair@gmail.com> References: <20210825040122.14244-1-selva.nair@gmail.com> <20210825210232.22509-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.160.175 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.160.175 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 0.0 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1mJ02y-00060y-8W Subject: [Openvpn-devel] [PATCH v2 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. Signed-off-by: Selva Nair --- 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 e5ac8098..6e3c535e 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 index`` commands from the management interface to get the number of diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 0e398c0f..5d0aa8af 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -889,6 +889,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); @@ -1947,10 +1955,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; @@ -1973,10 +1988,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