From: "cron2 (Code Review)" Date: Wed, 23 Jul 2025 09:40:02 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641..., antonio@...2726... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="ZjP++Ci1alE="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: multi: store multi_context address inside top instance List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --ZjP++Ci1alE= 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= ordex. ( http://gerrit.openvpn.net/c/openvpn/+/1093?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+2 by cron2 Change subject: multi: store multi_context address inside top instance ...................................................................... multi: store multi_context address inside top instance Future modifications to DCO require accessing the server multi_context object. Since it is currently a stack variable that is pointed by no one, we'd need to pass it to all kind of functions to ensure it can reach the DCO code. To make the implementation simpler, it is preferable to simply assign its address to a struct context's field. While at it, make some multi_* functions static as they used only inside multi.c, where they are defined. Change-Id: Ibf64c681e02ac572d339d4d98e75ceb0cd417c45 Signed-off-by: Antonio Quartulli Acked-by: Gert Doering Message-Id: <20250723061034.20240-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg32= 266.html Signed-off-by: Gert Doering --- M src/openvpn/multi.c M src/openvpn/multi.h M src/openvpn/openvpn.h 3 files changed, 15 insertions(+), 18 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/93/1093/2 diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c index 4696686..ec260a2 100644 --- a/src/openvpn/multi.c +++ b/src/openvpn/multi.c @@ -290,9 +290,10 @@ /* * Main initialization function, init multi_context object. */ -void -multi_init(struct multi_context *m, struct context *t) +static void +multi_init(struct context *t) { + struct multi_context *m =3D t->multi; int dev =3D DEV_TYPE_UNDEF; msg(D_MULTI_LOW, "MULTI: multi_init called, r=3D%d v=3D%d", @@ -706,7 +707,7 @@ /* * Called on shutdown or restart. */ -void +static void multi_uninit(struct multi_context *m) { if (m->hash) @@ -3922,14 +3923,14 @@ } } -void -multi_top_init(struct multi_context *m, struct context *top) +static void +multi_top_init(struct context *top) { - inherit_context_top(&m->top, top); - m->top.c2.buffers =3D init_context_buffers(&top->c2.frame); + inherit_context_top(&top->multi->top, top); + top->multi->top.c2.buffers =3D init_context_buffers(&top->c2.frame); } -void +static void multi_top_free(struct multi_context *m) { close_context(&m->top, -1, CC_GC_FREE); @@ -4324,6 +4325,7 @@ struct multi_context multi; top->mode =3D CM_TOP; + top->multi =3D &multi; context_clear_2(top); /* initialize top-tunnel instance */ @@ -4334,10 +4336,10 @@ } /* initialize global multi_context object */ - multi_init(&multi, top); + multi_init(top); /* initialize our cloned top object */ - multi_top_init(&multi, top); + multi_top_init(top); /* initialize management interface */ init_management_callback_multi(&multi); diff --git a/src/openvpn/multi.h b/src/openvpn/multi.h index fe9e847..8b2704c 100644 --- a/src/openvpn/multi.h +++ b/src/openvpn/multi.h @@ -263,14 +263,6 @@ * Called by mtcp.c, mudp.c, or other (to be written) protocol drivers */ -void multi_init(struct multi_context *m, struct context *t); - -void multi_uninit(struct multi_context *m); - -void multi_top_init(struct multi_context *m, struct context *top); - -void multi_top_free(struct multi_context *m); - struct multi_instance *multi_create_instance(struct multi_context *m, cons= t struct mroute_addr *real, struct link_socket *sock); diff --git a/src/openvpn/openvpn.h b/src/openvpn/openvpn.h index 3c8ce39..7d48888 100644 --- a/src/openvpn/openvpn.h +++ b/src/openvpn/openvpn.h @@ -491,6 +491,9 @@ * CM_P2P, \c CM_TOP, \c CM_TOP_CLONE, * \c CM_CHILD_UDP, and \c CM_CHILD_TCP.= */ + struct multi_context *multi; /**< Pointer to the main P2MP context. + * Non-NULL only when mode =3D=3D CM_TO= P. */ + struct gc_arena gc; /**< Garbage collection arena for * allocations done in the scope of this * context structure. */ -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1093?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: Ibf64c681e02ac572d339d4d98e75ceb0cd417c45 Gerrit-Change-Number: 1093 Gerrit-PatchSet: 2 Gerrit-Owner: ordex Gerrit-Reviewer: cron2 Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-MessageType: newpatchset --ZjP++Ci1alE= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

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

View Change

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

multi: store multi_context address inside top instan=
ce

Future modifications to DCO require accessing the
server multi= _context object.

Since it is currently a stack variable that is poin= ted
by no one, we'd need to pass it to all kind of functions
to e= nsure it can reach the DCO code.

To make the implementation simpler,= it is preferable to
simply assign its address to a struct context's= field.

While at it, make some multi_* functions static as they
u= sed only inside multi.c, where they are defined.

Change-Id: Ibf64c68= 1e02ac572d339d4d98e75ceb0cd417c45
Signed-off-by: Antonio Quartulli <a= ntonio@...2726...>
Acked-by: Gert Doering <gert@...1296...>
= Message-Id: <20250723061034.20240-1-gert@...1296...>
URL: https://= www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg32266.html
S= igned-off-by: Gert Doering <gert@...1296...>
---
M src/openvpn/= multi.c
M src/openvpn/multi.h
M src/openvpn/openvpn.h
3 files chan= ged, 15 insertions(+), 18 deletions(-)

git pull ssh://gerrit.open=
vpn.net:29418/openvpn refs/changes/93/1093/2
diff --git a/src/openv=
pn/multi.c b/src/openvpn/multi.c
index 4696686..ec260a2 100= 644
--- a/src/openvpn/multi.c
+++ b/src/ope= nvpn/multi.c
@@ -290,9 +290,10 @@
/*
* Main initialization function, init multi_context object.
*/
-void=
-multi_init(struct mul= ti_context *m, struct context *t)
+static void
+multi_init(struct context *t)
{
+ struct multi_context *m =3D t->mu= lti;
int dev =3D DEV_TYPE_UNDEF;

msg(D_MULTI_LOW, "MULTI: multi_init called, r=3D%d v= =3D%d",
@@ -706,7 +707,7 @@
/*=
* Called on shutdown or restart.
*/-void
+static void
multi_uninit(stru= ct multi_context *m)
{
if (m->hash= )
@@ -3922,14 +3923,14 @@
}
= }

-void
-multi_top_in= it(struct multi_context *m, struct context *top)
+static void
+multi_top_init(struct context *top)
{=
- inherit_context_t= op(&m->top, top);
+ inherit_contex= t_top(&top->multi->top, top);
+ top->multi->top.c2.buffers =3D init_context_b= uffers(&top->c2.frame);
}
<= br>-void
+static void
multi_top_free(= struct multi_context *m)
{
close_cont= ext(&m->top, -1, CC_GC_FREE);
@@ -4324,6 +4325,7 @@<= /span>
struct multi_context multi;
top->mode =3D CM_TOP;
+ top->multi =3D &multi;
co= ntext_clear_2(top);

/* initialize to= p-tunnel instance */
@@ -4334,10 +4336,10 @@
}


/* initialize global multi_= context object */
- = multi_init(&multi, top);
+ multi_init(top);

/* ini= tialize our cloned top object */
- multi_top_init(&multi, top);
+ multi_top_init(top);

/* initialize management interface */
= init_management_callback_multi(&multi);
diff --git a/s= rc/openvpn/multi.h b/src/openvpn/multi.h
index fe9e847..8b2= 704c 100644
--- a/src/openvpn/multi.h
+++ b= /src/openvpn/multi.h
@@ -263,14 +263,6 @@
= * Called by mtcp.c, mudp.c, or other (to be written) protocol drivers
*/

-void multi_init(struct multi_context *m, struct context *t);
-
-void multi_uninit(struct multi_context *m);=
-
-void multi_top_init(struct multi_context *= m, struct context *top);
-void multi_top_fre= e(struct multi_context *m);
-
struct multi_instance *multi_create_instance(struct= multi_context *m, const struct mroute_addr *real,
= struct link_socket *sock);
=
diff --git a/src/openvpn/openvpn.h b/src/openvpn/op= envpn.h
index 3c8ce39..7d48888 100644
--- a= /src/openvpn/openvpn.h
+++ b/src/openvpn/openvpn.h@@ -491,6 +491,9 @@
= * CM_P2P, \c CM_TOP, \c CM_TOP_CLONE,
= * \c CM_CHILD_UDP, and \c CM_CHILD_TCP. */

+ struct mul= ti_context *multi; /**< Pointer to the main P2MP context.
+ = * Non-NULL only when mode =3D=3D CM_TOP. */

+
struct gc_arena gc; = /**< Garbage collection arena for
= * allocations done in the scope of this
= * context structure. */

To view, visit change 1093. To unsubscribe, or for help writin= g mail filters, visit settin= gs.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ibf64c681e02ac572d339d4d98e7= 5ceb0cd417c45
Gerrit-Change-Number: 1093
Gerrit-PatchSet: 2
Gerrit-Owner: ordex <antonio@...2726...>=
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
--ZjP++Ci1alE=--