From patchwork Tue Aug 24 18:01:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Selva Nair X-Patchwork-Id: 1920 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 2Ms6COTAJWG5aQAAIUCqbw (envelope-from ) for ; Wed, 25 Aug 2021 00:02:44 -0400 Received: from proxy4.mail.ord1c.rsapps.net ([172.28.255.1]) by director11.mail.ord1d.rsapps.net with LMTP id wPoeCOTAJWHJPgAAvGGmqA (envelope-from ) for ; Wed, 25 Aug 2021 00:02:44 -0400 Received: from smtp38.gate.ord1c ([172.28.255.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy4.mail.ord1c.rsapps.net with LMTPS id uCYCM+PAJWHiQQAAjcXvpA (envelope-from ) for ; Wed, 25 Aug 2021 00:02:43 -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: smtp38.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: 4c2f8918-0559-11ec-9c72-5452007bdf16-1-1 Received: from [216.105.38.7] ([216.105.38.7:46862] helo=lists.sourceforge.net) by smtp38.gate.ord1c.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 5A/75-05813-3E0C5216; Wed, 25 Aug 2021 00:02:43 -0400 Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1mIk6d-0005FM-Nu; Wed, 25 Aug 2021 04:01:39 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mIk6a-0005Ex-6d for openvpn-devel@lists.sourceforge.net; Wed, 25 Aug 2021 04:01:36 +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=BuW7+KbXbEVOYHuu3FtIs9WkDb aEMTz5EfZ5FMy9eL3SxIH5gP60pCT2YB2ylF982SWqHuEEeuycbF/ClVHpe68ZzZZpE7zQvTfNoco nUwRX9lReHF2GAQl51Oma8Dc2hlsaPgmGnPHvHpDKNQjAfGAgJfla+dvKKc1I9UykPkM=; 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=LZyVIk0SMMqhhiSVnHryUOFHg7 PUhUdueDOyrANMII5PC1jgAxYm+FVsyT4eM9d4ouCgK4SwQo3TNteSe9A9xRuDjmcGJSGDhs0jHnH asXYgVfgdMrTfUoZkLv5JAuo7sH2qpHKnjA7wHOPBFZoEpknJ2B8uo7KwaPkye5tWlRk=; Received: from mail-qk1-f176.google.com ([209.85.222.176]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92.3) id 1mIk6X-000217-Jj for openvpn-devel@lists.sourceforge.net; Wed, 25 Aug 2021 04:01:36 +0000 Received: by mail-qk1-f176.google.com with SMTP id c10so23165660qko.11 for ; Tue, 24 Aug 2021 21:01:33 -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=j9oZ52XFH7DD+x6XMvZTek9+eXxG8SuimaUdCReml/RQTTO/b1QbZ7t7EZyZREv33O DwIGWvQP4WryKJOLstlaWCBqk0aCYD29+/MBMbjiHZusiVmMx17mEP0Ocnl759JS3CnI TvdcPXZDzZtd5C8PKp7/88x2LJSRS72L/V6Jrkv3zO2CHkEH50aLocAupM3MUVXoWIUM MszPST4kJLSyKfUjxk5qP8cpRpJ8NxlqqtegT+njK8xoBnLYXmDgQ7kq7laCWmUNxYDI fqpz36PBMYzm+iQA7zMvwZGpqK3R0dFM7bbx4ZgR/SO7lJQD3T1FxAWEiRVlYSaFT2rG H3YA== 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=UReCogzVbvFXMlD82y0rtrE48QZEarOapUXD1A6ioKwA4fLimvF8bbJfLExRF7v1ok FdNC5u6z0opkFBGg1w8bP8ct+6f5RrS0Z5L0/Ut91WWuYBoKUowXlRkXBG6sB4hwA+8n FlcW0vV18F4/7PPdgxGRhT1lnGAmIFlG//bQRPJlCahoSBjeLjm5odb66VY3GtLIVcFz TtDZAGQChPlXtcPcGJzK/CrxPeyZx47CY2HRmH1fKgMde7oUkBDK7QDxakV2385TaQHH cWUN/KfW/SCoVpZrNZtyLuLH9PgS6s9NyaTSDLq+HZGVFP0KDkV9lZumvgtcR/VXTImX aKQw== X-Gm-Message-State: AOAM530d70eZJhsAOhz8ZL5c38GAaiB6aaBHQNYZUPH1fpj5AgSKoGN4 AYtvkN0CrqEGCua6pmR17T96CFBHwMQfTw== X-Google-Smtp-Source: ABdhPJy4bFIoZcOgbWXUb2Q9Vip7NP258KsA+fyV+TKlQ+zzMa3OmuY99SLvV/cy0S7aaQewTVvaMQ== X-Received: by 2002:a37:453:: with SMTP id 80mr29828069qke.397.1629864087664; Tue, 24 Aug 2021 21:01:27 -0700 (PDT) Received: from uranus.home.sansel.ca ([2600:3c03:e001:3b08::1006]) by smtp.gmail.com with ESMTPSA id i18sm9596652qke.103.2021.08.24.21.01.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Aug 2021 21:01:27 -0700 (PDT) From: selva.nair@gmail.com To: openvpn-devel@lists.sourceforge.net Date: Wed, 25 Aug 2021 00:01:22 -0400 Message-Id: <20210825040122.14244-2-selva.nair@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210825040122.14244-1-selva.nair@gmail.com> References: <20210825040122.14244-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_MSPIKE_H2 RBL: Average reputation (+2) [209.85.222.176 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.222.176 listed in list.dnswl.org] -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: 1mIk6X-000217-Jj Subject: [Openvpn-devel] [PATCH 2/2] 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