From patchwork Wed Jun 18 14:00:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 4285 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7001:602d:b0:668:42a9:9967 with SMTP id us45csp3134705mab; Wed, 18 Jun 2025 07:00:30 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUggmFJ2v0ilExADgl7yiORGBbcweE2B46Gl05fF/O+ppaFhr5IOs05jlFdE9LKYRr8ABOJ5fHjK5Q=@openvpn.net X-Google-Smtp-Source: AGHT+IFI/7mOK6J6xp0AhXLeVubxPA6DE494q6eiOQ9ysxWCs88UbcMGc2APsdJu/CSVHwE+GLxS X-Received: by 2002:a05:6820:823:b0:611:2c55:3a4f with SMTP id 006d021491bc7-6112c553b7emr4329766eaf.2.1750255230395; Wed, 18 Jun 2025 07:00:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1750255230; cv=none; d=google.com; s=arc-20240605; b=EC7V5AK9xLXIK5yIz8j9fapm+i1CaGE9EecrsC/uOn3iRraEJkVaXbdHokhFRdJJ4O gqiMxCK1nnLpy72VfeSOGvsIrMZvQ4DAHzpYx3V9e0hTwzR73HftQzV6GLtpZvCrFSax p9d9HryKFtbNClRjDFDVtaO0e9/4TiA1RR+/r3Nb0iuwyfHMJM83/9WAq5XpjNUNyCe4 eUZwdoTE7Qm4v0EhdesEoIAMei4FA5JCuj8IhmLMvhHdVhZqe7ogl3V5hgD/y+fE0eYW 8GBQZ3+gcLBjehYAwGFankoxZgi4AOG5t+5zkFK46AvB1in4qAuNIpDn6/9kO4Han9VU qe5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature:dkim-signature; bh=rW5MEmSSL0ATpOlQr6lRp6jTZJdX8I95RERvXGP/Mbw=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=f69CFgkyUEXpMA5iN8an9ysqW8eiJUYohgCjWOuoHV6JCa5rfu7H8HbozGgHJNByvM NKZOB84/o5Ww0Abc6i89cgzaSqC6/97SIUXlVAkZU+X5HvP7iP0kNLyWuXM7sCM1SF3c 9peQy6bhAu34KJllfIw8NZlRfRvqk5ery4607OGgQOcB/9ks+HYNpUFgQNab7O5+Qmfi s4Vn5cNGN23gXiG2ML64GKB4bD0NYxsIf0tuei7AZ3pkvNqbxJVrR89OxyP8Ut59XuAN W3hyg7D3Qd3Ma7E4qHpZf9WC9hfZoX8755+HJoYvfP2LN6eeGQWOOVGxJphnxgzO3yNS Szig==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=MKngzOld; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=TfF0XeWF; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=Buf1rP6S; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 006d021491bc7-61108ed3f88si6113271eaf.39.2025.06.18.07.00.30 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Jun 2025 07:00:30 -0700 (PDT) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=MKngzOld; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=TfF0XeWF; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=Buf1rP6S; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Subject:MIME-Version:References:In-Reply-To:Message-ID:Date:To:From:Sender: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=rW5MEmSSL0ATpOlQr6lRp6jTZJdX8I95RERvXGP/Mbw=; b=MKngzOldw1EfpTYnEmMt+z7Az9 UNV1+gDu0JOoiKY7AsSPAMPV0s6SUUTvZxKBkuhsc1/C3cmYGxD8vrYUkv7wopA1IWRLF+1bbTm0i Nzd/v1Ri73AXfxEi14eZ2QcvHjuVR2JWO6zU3UODvv9r+ZOHoa2DnV9xGGLGU4cfZ9Z0=; 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.95) (envelope-from ) id 1uRtL0-0006cg-9H; Wed, 18 Jun 2025 14:00:26 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1uRtKz-0006cZ-HM for openvpn-devel@lists.sourceforge.net; Wed, 18 Jun 2025 14:00:25 +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=X4n7TRXK/KSCK2qbVMQDZOgxb02uMOSGRylFbwNGJxs=; b=TfF0XeWFgSlmgm7kiQ50zVZtFD OB7gPlxf5LVIp4laigbO21Jni34Cr4tJH93YuLYog8ugNb2yZ9lUtrQKgr/kP6jHGmdsuWXwYSKM1 VwSWeLh31szYiRQLZ2HJQss48bL0iOIMDj3glNyxgbMWXreUK+O2LK+R5ZeCr+raLQL8=; 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=X4n7TRXK/KSCK2qbVMQDZOgxb02uMOSGRylFbwNGJxs=; b=Buf1rP6SnRieRh41iIuwVRDo3C lAaWWZvzlzTwTZDKCmjnoEugEFPXDVp86OQcR/it853RM3m/s/uuMGspgy7n0l974wLJ021GWKsBs CBk3TOsNAWKYuuUtrEWFNeWfmRei/VgKta6kqnb1VAJfhlKcdkt/bDhgHbKu36npiWlU=; Received: from [193.149.48.143] (helo=blue.greenie.muc.de) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1uRtKy-00035s-Ce for openvpn-devel@lists.sourceforge.net; Wed, 18 Jun 2025 14:00:25 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.17.1.9/8.17.1.9) with ESMTP id 55IE0HOi002788 for ; Wed, 18 Jun 2025 16:00:17 +0200 Received: (from gert@localhost) by blue.greenie.muc.de (8.17.1.9/8.17.1.9/Submit) id 55IE0HLF002786 for openvpn-devel@lists.sourceforge.net; Wed, 18 Jun 2025 16:00:17 +0200 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Wed, 18 Jun 2025 16:00:09 +0200 Message-ID: <20250618140016.2766-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Score: 1.3 (+) X-Spam-Report: Spam detection software, running on the system "sfi-spamd-2.hosts.colo.sdot.me", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Gianmarco De Gregori Optimize the current local_list implementation by replacing the static array with a resizable one, as the static allocation serves no real purpose, particularly on the client side. Content analysis details: (1.3 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS X-Headers-End: 1uRtKy-00035s-Ce Subject: [Openvpn-devel] [PATCH v1] Multi-socket: local_list clean-up 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 X-GMAIL-THRID: =?utf-8?q?1835275628232805834?= X-GMAIL-MSGID: =?utf-8?q?1835275628232805834?= From: Gianmarco De Gregori Optimize the current local_list implementation by replacing the static array with a resizable one, as the static allocation serves no real purpose, particularly on the client side. Github: #682 Change-Id: I32effed9e273fbe8986d1f4e8da4a4d0ac216463 Signed-off-by: Gianmarco De Gregori Acked-by: Gert Doering --- This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1039 This mail reflects revision 1 of this Change. Acked-by according to Gerrit (reflected above): Gert Doering diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 6ea01d4..70337b1 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -2212,12 +2212,20 @@ struct local_list *l = alloc_local_list_if_undef(ce, gc); struct local_entry *e; - if (l->len >= CONNECTION_LIST_SIZE) + if (l->len >= l->capacity) { - msg(msglevel, "Maximum number of 'local' options (%d) exceeded", - CONNECTION_LIST_SIZE); + const int new_cap = l->capacity + 1; + const size_t elem_size = sizeof(*l->array); - return NULL; + struct local_entry **new_array = gc_realloc(l->array, new_cap * elem_size, gc); + if (!new_array) + { + msg(msglevel, "Unable to process more local options: out of memory. Number of entries = %d", l->len); + return NULL; + } + + l->array = new_array; + l->capacity = new_cap; } ALLOC_OBJ_CLEAR_GC(e, struct local_entry, gc); diff --git a/src/openvpn/options.h b/src/openvpn/options.h index b28ad58..46ec32b 100644 --- a/src/openvpn/options.h +++ b/src/openvpn/options.h @@ -188,8 +188,9 @@ struct local_list { + int capacity; int len; - struct local_entry *array[CONNECTION_LIST_SIZE]; + struct local_entry **array; }; struct connection_list