From: "cron2 (Code Review)" Date: Wed, 18 Jun 2025 14:08:28 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., gianmarco@...2726..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <796eec542393d11b4ae6f23187c86c736bc43b49-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="/Yipibhmu2Q="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: Multi-socket: local_list clean-up List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: its_Giaan , plaisthos , flichtenheld Cc: openvpn-devel --/Yipibhmu2Q= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has uploaded a new patch set (#2) to the change originally created by= its_Giaan. ( http://gerrit.openvpn.net/c/openvpn/+/1039?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+2 by cron2 Change subject: Multi-socket: local_list clean-up ...................................................................... Multi-socket: local_list clean-up 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: OpenVPN/openvpn#682 Change-Id: I32effed9e273fbe8986d1f4e8da4a4d0ac216463 Signed-off-by: Gianmarco De Gregori Acked-by: Gert Doering Message-Id: <20250618140016.2766-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31= 927.html Signed-off-by: Gert Doering --- M src/openvpn/options.c M src/openvpn/options.h 2 files changed, 14 insertions(+), 5 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/39/1039/2 diff --git a/src/openvpn/options.c b/src/openvpn/options.c index d758a67..3cf8c2a 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -2067,12 +2067,20 @@ struct local_list *l =3D alloc_local_list_if_undef(ce, gc); struct local_entry *e; - if (l->len >=3D CONNECTION_LIST_SIZE) + if (l->len >=3D l->capacity) { - msg(msglevel, "Maximum number of 'local' options (%d) exceeded", - CONNECTION_LIST_SIZE); + const int new_cap =3D l->capacity + 1; + const size_t elem_size =3D sizeof(*l->array); - return NULL; + struct local_entry **new_array =3D gc_realloc(l->array, new_cap * = elem_size, gc); + if (!new_array) + { + msg(msglevel, "Unable to process more local options: out of me= mory. Number of entries =3D %d", l->len); + return NULL; + } + + l->array =3D new_array; + l->capacity =3D 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 -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1039?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I32effed9e273fbe8986d1f4e8da4a4d0ac216463 Gerrit-Change-Number: 1039 Gerrit-PatchSet: 2 Gerrit-Owner: its_Giaan Gerrit-Reviewer: cron2 Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-MessageType: newpatchset --/Yipibhmu2Q= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 uploaded patch set #2 to the change originally cr= eated by its_Giaan.

View Change

The following approvals got outdate= d and were removed: Code-Review+2 by cron2

Multi-socket: local_list clean-up

Optimize th= e current local_list implementation
by replacing the static array with a= resizable
one, as the static allocation serves no real
purpose, part= icularly on the client side.

Github: OpenVPN/openvpn#682

Chan= ge-Id: I32effed9e273fbe8986d1f4e8da4a4d0ac216463
Signed-off-by: Gianmarc= o De Gregori <gianmarco@...2726...>
Acked-by: Gert Doering <ger= t@...1296...>
Message-Id: <20250618140016.2766-1-gert@...1296...&g= t;
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net= /msg31927.html
Signed-off-by: Gert Doering <gert@...1296...>
--= -
M src/openvpn/options.c
M src/openvpn/options.h
2 files changed,= 14 insertions(+), 5 deletions(-)

git pull ssh://gerrit.openvpn.n=
et:29418/openvpn refs/changes/39/1039/2
diff --git a/src/openvpn/op=
tions.c b/src/openvpn/options.c
index d758a67..3cf8c2a 1006= 44
--- a/src/openvpn/options.c
+++ b/src/op= envpn/options.c
@@ -2067,12 +2067,20 @@
= struct local_list *l =3D alloc_local_list_if_undef(ce, gc);
struct local_entry *e;

- if (l->len >=3D CONNECTION_LIST_SIZE)<= /span>
+ if (l->len &g= t;=3D l->capacity)
{
- msg(msglevel, "Maximum number of 'l= ocal' options (%d) exceeded",
- CONNECTION_LIST_SIZE);
+ const int new_cap =3D l->capac= ity + 1;
+ con= st size_t elem_size =3D sizeof(*l->array);

<= span style=3D"color: hsl(0, 100%, 40%);">- return NULL;

+ struct local_entry **new= _array =3D gc_realloc(l->array, new_cap * elem_size, gc);
+ if (!new_array)
= + {
+ msg(msglevel, "Unable t= o process more local options: out of memory. Number of entries =3D %d"= , l->len);
+ = return NULL;
+ = }
+
= + l->array =3D new_ar= ray;
+ l->c= apacity =3D new_cap;
}

ALLOC_OBJ_CLEAR_GC(e, struct local_entry, gc);
diff= --git a/src/openvpn/options.h b/src/openvpn/options.h
inde= x b28ad58..46ec32b 100644
--- a/src/openvpn/options.h
+++ b/src/openvpn/options.h
@@ -188,8 +188,9 @@<= /span>

struct local_list
{

+ int capacity;
int len;
+ struct local_entry **array;<= br> };

struct connection_list


To view, visit change 1039. To unsubscribe, or = for help writing mail filters, visit settings.

<= /div>
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I32effed9e273fbe8986d1f4e8da= 4a4d0ac216463
Gerrit-Change-Number: 1039
Gerrit-PatchSet: 2
Gerrit-Owner: its_Giaan <gianmarco@...2786...= ..>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-MessageType: newpatchset
--/Yipibhmu2Q=--