From: "cron2 (Code Review)" Date: Tue, 21 Apr 2026 08:32:21 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, ralf@...2726... Message-ID: <79d68a79e03e25272396ab260b04602444a0b2e1-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="ONvwhLW2MzA="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[release/2.6]: dco: port core/context infrastructure needed for backport of commit 7... List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: ralf_lici Cc: plaisthos , openvpn-devel --ONvwhLW2MzA= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/16= 31?usp=3Demail ) Change subject: dco: port core/context infrastructure needed for backport o= f commit 7791f53 ...................................................................... dco: port core/context infrastructure needed for backport of commit 7791f53 Change ovpn_dco_init() to take a reference to struct context, add a backlink from the platform DCO contexts to the owning openvpn context, and store the top multi context in struct context for server mode. This prepares the tree for the follow-up backend changes from commit 7791f53 ("dco: process messages immediately after read") where Linux and FreeBSD process DCO notifications directly from their backend read paths. It is part of a reworked backport of PR #945 originally proposed by Nikolai Shelekhov . The original commits in master are commit a699681bb86c6e9a2c9f205543f60400208aea4b Author: Antonio Quartulli Date: Wed Jul 23 15:39:11 2025 +0200 dco: only pass struct context to init function commit 7f5a6deae33a338a23d7e8ff8526db8fdddf4bc2 Author: Antonio Quartulli Date: Wed Jul 23 08:10:25 2025 +0200 multi: store multi_context address inside top instance Change-Id: I974e10ec91a0b63f52387f1406ce1b49145eb0be Signed-off-by: Ralf Lici Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1631 Message-Id: <20260420165923.14226-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg36= 691.html Signed-off-by: Gert Doering --- M src/openvpn/dco.h M src/openvpn/dco_freebsd.c M src/openvpn/dco_freebsd.h M src/openvpn/dco_linux.c M src/openvpn/dco_linux.h M src/openvpn/dco_win.c M src/openvpn/init.c M src/openvpn/mtcp.c M src/openvpn/mudp.c M src/openvpn/openvpn.h 10 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/openvpn/dco.h b/src/openvpn/dco.h index 50ebb35..334d468 100644 --- a/src/openvpn/dco.h +++ b/src/openvpn/dco.h @@ -104,11 +104,10 @@ /** * Initialize the DCO context * - * @param mode the instance operating mode (P2P or multi-peer) - * @param dco the context to initialize + * @param c the main instance context * @return true on success, false otherwise */ -bool ovpn_dco_init(int mode, dco_context_t *dco); +bool ovpn_dco_init(struct context *c); /** * Open/create a DCO interface @@ -284,7 +283,7 @@ } static inline bool -ovpn_dco_init(int mode, dco_context_t *dco) +ovpn_dco_init(struct context *c) { return true; } diff --git a/src/openvpn/dco_freebsd.c b/src/openvpn/dco_freebsd.c index 15add74..b164bd3 100644 --- a/src/openvpn/dco_freebsd.c +++ b/src/openvpn/dco_freebsd.c @@ -220,9 +220,11 @@ } bool -ovpn_dco_init(int mode, dco_context_t *dco) +ovpn_dco_init(struct context *c) { - if (open_fd(dco) < 0) + c->c1.tuntap->dco.c =3D c; + + if (open_fd(&c->c1.tuntap->dco) < 0) { msg(M_ERR, "Failed to open socket"); return false; diff --git a/src/openvpn/dco_freebsd.h b/src/openvpn/dco_freebsd.h index ab5891e8..e8f723e 100644 --- a/src/openvpn/dco_freebsd.h +++ b/src/openvpn/dco_freebsd.h @@ -57,6 +57,7 @@ int dco_message_peer_id; int dco_del_peer_reason; struct sockaddr_storage dco_float_peer_ss; + struct context *c; uint64_t dco_read_bytes; uint64_t dco_write_bytes; } dco_context_t; diff --git a/src/openvpn/dco_linux.c b/src/openvpn/dco_linux.c index b2584b9..493fce6 100644 --- a/src/openvpn/dco_linux.c +++ b/src/openvpn/dco_linux.c @@ -391,9 +391,11 @@ } bool -ovpn_dco_init(int mode, dco_context_t *dco) +ovpn_dco_init(struct context *c) { - switch (mode) + dco_context_t *dco =3D &c->c1.tuntap->dco; + + switch (c->mode) { case CM_TOP: dco->ifmode =3D OVPN_MODE_MP; @@ -407,6 +409,10 @@ ASSERT(false); } + /* store pointer to context as it may be required by message + * parsing routines + */ + dco->c =3D c; ovpn_dco_init_netlink(dco); return true; } diff --git a/src/openvpn/dco_linux.h b/src/openvpn/dco_linux.h index 5179912..cf6bdd4 100644 --- a/src/openvpn/dco_linux.h +++ b/src/openvpn/dco_linux.h @@ -43,6 +43,8 @@ struct nl_cb *nl_cb; int status; + struct context *c; + enum ovpn_mode ifmode; int ovpn_dco_id; diff --git a/src/openvpn/dco_win.c b/src/openvpn/dco_win.c index 0b8f831..bc465db 100644 --- a/src/openvpn/dco_win.c +++ b/src/openvpn/dco_win.c @@ -53,7 +53,7 @@ } bool -ovpn_dco_init(int mode, dco_context_t *dco) +ovpn_dco_init(struct context *c) { return true; } diff --git a/src/openvpn/init.c b/src/openvpn/init.c index 1476737..c2cfd24 100644 --- a/src/openvpn/init.c +++ b/src/openvpn/init.c @@ -1882,7 +1882,7 @@ #endif if (dco_enabled(&c->options)) { - ovpn_dco_init(c->mode, &c->c1.tuntap->dco); + ovpn_dco_init(c); } /* open the tun device */ diff --git a/src/openvpn/mtcp.c b/src/openvpn/mtcp.c index 3e33b15..38c938e 100644 --- a/src/openvpn/mtcp.c +++ b/src/openvpn/mtcp.c @@ -792,6 +792,7 @@ int status; top->mode =3D CM_TOP; + top->multi =3D &multi; context_clear_2(top); /* initialize top-tunnel instance */ diff --git a/src/openvpn/mudp.c b/src/openvpn/mudp.c index f7c9ffd..8cc717b 100644 --- a/src/openvpn/mudp.c +++ b/src/openvpn/mudp.c @@ -466,6 +466,7 @@ struct multi_context multi; top->mode =3D CM_TOP; + top->multi =3D &multi; context_clear_2(top); /* initialize top-tunnel instance */ diff --git a/src/openvpn/openvpn.h b/src/openvpn/openvpn.h index 9cba1c5..3879772 100644 --- a/src/openvpn/openvpn.h +++ b/src/openvpn/openvpn.h @@ -492,6 +492,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/+/1631?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings?usp=3Demail Gerrit-MessageType: merged Gerrit-Project: openvpn Gerrit-Branch: release/2.6 Gerrit-Change-Id: I974e10ec91a0b63f52387f1406ce1b49145eb0be Gerrit-Change-Number: 1631 Gerrit-PatchSet: 2 Gerrit-Owner: ralf_lici Gerrit-Reviewer: cron2 Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel --ONvwhLW2MzA= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 sub= mitted this change.

View Change

dco: port core/context infrastructure needed for=
 backport of commit 7791f53

Change ovpn_dco_init() to take a referen= ce to struct context, add a
backlink from the platform DCO contexts to t= he owning openvpn context,
and store the top multi context in struct con= text for server mode.

This prepares the tree for the follow-up backe= nd changes from commit
7791f53 ("dco: process messages immediately = after read") where Linux and
FreeBSD process DCO notifications dire= ctly from their backend read
paths.

It is part of a reworked back= port of PR #945 originally proposed by
Nikolai Shelekhov <nickshv13@...220...= ..2314...>.

The original commits in master are

commit = a699681bb86c6e9a2c9f205543f60400208aea4b
Author: Antonio Quartulli &= lt;antonio@...2726...>
Date: Wed Jul 23 15:39:11 2025 +0200
=
dco: only pass struct context to init function

commit 7f5a6= deae33a338a23d7e8ff8526db8fdddf4bc2
Author: Antonio Quartulli <an= tonio@...2726...>
Date: Wed Jul 23 08:10:25 2025 +0200

= multi: store multi_context address inside top instance

Change-Id: I9= 74e10ec91a0b63f52387f1406ce1b49145eb0be
Signed-off-by: Ralf Lici <ral= f@...2726...>
Acked-by: Gert Doering <gert@...1296...>
Gerri= t URL: https://gerrit.openvpn.net/c/openvpn/+/1631
Message-Id: <20260= 420165923.14226-1-gert@...1296...>
URL: https://www.mail-archive.com/= openvpn-devel@lists.sourceforge.net/msg36691.html
Signed-off-by: Gert Do= ering <gert@...1296...>
---
M src/openvpn/dco.h
M src/openvp= n/dco_freebsd.c
M src/openvpn/dco_freebsd.h
M src/openvpn/dco_linux.c=
M src/openvpn/dco_linux.h
M src/openvpn/dco_win.c
M src/openvpn/i= nit.c
M src/openvpn/mtcp.c
M src/openvpn/mudp.c
M src/openvpn/open= vpn.h
10 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/src/openvpn/dco.h b/src/openvpn/dco.h
index= 50ebb35..334d468 100644
--- a/src/openvpn/dco.h
= +++ b/src/openvpn/dco.h
@@ -104,11 +104,10 @@<= br> /**
* Initialize the DCO context
*
- * @param mode = the instance operating mode (P2P or multi-peer)
- * @param dco the context to initiali= ze
+ * @param c = the main instance context
* @return true on s= uccess, false otherwise
*/
-bool ovpn_dco_init(int mode, dco_context_t *dco);
+bool ovpn_dco_init(str= uct context *c);

/**
*= Open/create a DCO interface
@@ -284,7 +283,7 @@
= }

static inline bool
-ovpn_dco_init(int mode, dco_contex= t_t *dco)

+ovpn_dco_i= nit(struct context *c)
{
return true;=
}
diff --git a/src/openvpn/dco_freebsd.c = b/src/openvpn/dco_freebsd.c
index 15add74..b164bd3 100644
--- a/src/openvpn/dco_freebsd.c
+++ b/src/op= envpn/dco_freebsd.c
@@ -220,9 +220,11 @@
}=

bool
-ovpn_dco_init(int mode, dco_context_t *dco)
+ovpn_dco_init(struct context *c)=

{
- = if (open_fd(dco) < 0)
+ c->c1.tuntap->dco.c =3D c;
+
+ if (open_fd(&c->c1.tuntap->dco) < 0)
= {
msg(M_ERR, "Failed to open socket"= ;);
return false;
diff --git a/src= /openvpn/dco_freebsd.h b/src/openvpn/dco_freebsd.h
index ab= 5891e8..e8f723e 100644
--- a/src/openvpn/dco_freebsd.h

+++ b/src/openvpn/dco_freebsd.h
@@ -57,6 +57,7 = @@
int dco_message_peer_id;
int d= co_del_peer_reason;
struct sockaddr_storage dco_float_= peer_ss;
+ struct = context *c;
uint64_t dco_read_bytes;
= uint64_t dco_write_bytes;
} dco_context_t;
<= span>diff --git a/src/openvpn/dco_linux.c b/src/openvpn/dco_linux.c<= br>index b2584b9..493fce6 100644
--- a/src/openvpn/dc= o_linux.c
+++ b/src/openvpn/dco_linux.c
@@ = -391,9 +391,11 @@
}

boo= l
-ovpn_dco_init(int mo= de, dco_context_t *dco)
+ovpn_dco_init(struct context *c)
{
- switch (mode)
+ dco_context_t *dco =3D &c->c1.= tuntap->dco;
+

+ switch (c->mode)=
{
case CM_TOP:
dco->ifmode =3D OVPN_MODE_MP;
@@ -407,6 = +409,10 @@
ASSERT(false);
= }

= + /* store pointer to context as it may be required by message+ * parsing routines
+ */
+ dco->c =3D c;
= ovpn_dco_init_netlink(dco);
return true; }
diff --git a/src/openvpn/dco_linux.h b/src/openv= pn/dco_linux.h
index 5179912..cf6bdd4 100644
--- a/src/openvpn/dco_linux.h

+++ b/src/openvpn/dco_linux= .h
@@ -43,6 +43,8 @@
struct nl_cb *nl_= cb;
int status;

+ struct context *c;
+
enum ovpn_mode = ifmode;

int ovpn_dco_id;
<= span>diff --git a/src/openvpn/dco_win.c b/src/openvpn/dco_win.c
<= span>index 0b8f831..bc465db 100644
--- a/src/openvpn/dco_wi= n.c
+++ b/src/openvpn/dco_win.c
@@ -53,7 +5= 3,7 @@
}

bool-ovpn_dco_init(int mode, dco_con= text_t *dco)
+ovpn_dc= o_init(struct context *c)
{
return tr= ue;
}
diff --git a/src/openvpn/init.c b/sr= c/openvpn/init.c
index 1476737..c2cfd24 100644
--- a/src/openvpn/init.c
+++ b/src/openvpn/init.c
@@ -1882,7 +1882,7 @@
#endif
= if (dco_enabled(&c->options))
{
- ovpn_dco_init(= c->mode, &c->c1.tuntap->dco);
+ ovpn_dco_init(c);
= }

/* open the tun device */
diff --git a/src/openvpn/mtcp.c b/src/openvpn/mtcp.c<= br>index 3e33b15..38c938e 100644
--- a/src/openvpn/mt= cp.c
+++ b/src/openvpn/mtcp.c
@@ -792,6 +79= 2,7 @@
int status;

= top->mode =3D CM_TOP;
+ top->multi =3D &multi;
context_cle= ar_2(top);

/* initialize top-tunnel = instance */
diff --git a/src/openvpn/mudp.c b/src/openvpn/m= udp.c
index f7c9ffd..8cc717b 100644
--- a/s= rc/openvpn/mudp.c
+++ b/src/openvpn/mudp.c
= @@ -466,6 +466,7 @@
struct multi_context multi;=

top->mode =3D CM_TOP;
+ top->multi =3D &multi;

context_clear_2(top);

= /* initialize top-tunnel instance */
diff --git a/src/o= penvpn/openvpn.h b/src/openvpn/openvpn.h
index 9cba1c5..387= 9772 100644
--- a/src/openvpn/openvpn.h
+++= b/src/openvpn/openvpn.h
@@ -492,6 +492,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_TOP.= */
+
struct gc_arena gc; /**< Garbage collection arena for

* allocations done in the s= cope of this
* context = structure. */

To view, visit change 1631. T= o unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: release/2.6
Gerrit-Change-Id: I974e10ec91a0b63f52387f1406c= e1b49145eb0be
Gerrit-Change-Number: 1631
Gerrit-PatchSet: 2
Gerrit-Owner: ralf_lici <ralf@...2726...>= ;
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
= --ONvwhLW2MzA=--