From: "ralf_lici (Code Review)" Date: Mon, 20 Apr 2026 16:15:51 +0000 References: Reply-To: ralf@...2726..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="ru70m9ft8LQ="; 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: plaisthos Cc: openvpn-devel --ru70m9ft8LQ= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: plaisthos. Hello plaisthos, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/1631?usp=3Demail to review the following change. 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 . Change-Id: I974e10ec91a0b63f52387f1406ce1b49145eb0be Signed-off-by: Ralf Lici --- 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(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/31/1631/1 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: newchange Gerrit-Project: openvpn Gerrit-Branch: release/2.6 Gerrit-Change-Id: I974e10ec91a0b63f52387f1406ce1b49145eb0be Gerrit-Change-Number: 1631 Gerrit-PatchSet: 1 Gerrit-Owner: ralf_lici Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos --ru70m9ft8LQ= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: plaisthos.

ralf_lici would like plaisthos to review this change.

V= iew Change

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

Change ovpn_dco_init() to take a re= ference to struct context, add a
backlink from the platform DCO contexts= to the owning openvpn context,
and store the top multi context in struc= t context for server mode.

This prepares the tree for the follow-up = backend changes from commit
7791f53 ("dco: process messages immedia= tely 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 <nicksh= v13@...2314...>.

Change-Id: I974e10ec91a0b63f52387f1406ce1b49145e= b0be
Signed-off-by: Ralf Lici <ralf@...2726...>
---
M src/op= envpn/dco.h
M src/openvpn/dco_freebsd.c
M src/openvpn/dco_freebsd.hM src/openvpn/dco_linux.c
M src/openvpn/dco_linux.h
M src/openvpn/d= co_win.c
M src/openvpn/init.c
M src/openvpn/mtcp.c
M src/openvpn/m= udp.c
M src/openvpn/openvpn.h
10 files changed, 25 insertions(+), 10 = deletions(-)

git pull ssh://gerrit.openvpn.net:2=
9418/openvpn refs/changes/31/1631/1
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 (P= 2P or multi-peer)
- * @= param dco the context to initialize
+ * @param c the main instance context<= br> * @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<= br>@@ -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.cindex 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;
+
<= span style=3D"color: hsl(120, 100%, 40%);">+ if (open_fd(&c->c1.t= untap->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_fr= eebsd.h
@@ -57,6 +57,7 @@
int dco_mess= age_peer_id;
int dco_del_peer_reason;
= struct sockaddr_storage dco_float_peer_ss;
+ struct context *c;
uin= t64_t dco_read_bytes;
uint64_t dco_write_bytes;=
} dco_context_t;
diff --git a/src/openvpn/dco_li= nux.c b/src/openvpn/dco_linux.c
index b2584b9..493fce6 1006= 44
--- 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 OV= PN_MODE_MP;
@@ -407,6 +409,10 @@
= ASSERT(false);
}

+ /* store pointer to context as i= t 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 @@<= /span>
struct nl_cb *nl_cb;
int status;<= /span>

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

<= span> 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 @@
}
<= span>
bool
-ovpn_dco_init(int mode, dco_context_t *dco)
+ovpn_dco_init(struct context *c)
<= span> {
return true;
}
diff --git a/src/openvpn/init.c b/src/openvpn/init.c
inde= x 1476737..c2cfd24 100644
--- a/src/openvpn/init.c+++ b/src/openvpn/init.c
@@ -1882,7 +1882,7 @@

#endif
if (dco_enabled(&c->opt= ions))
{
- ovpn_dco_init(c->mode, &c->c1.tuntap->= dco);
+ ov= pn_dco_init(c);
}

/* open the tun device */
diff --git a/src/openv= pn/mtcp.c b/src/openvpn/mtcp.c
index 3e33b15..38c938e 10064= 4
--- a/src/openvpn/mtcp.c
+++ b/src/openvp= n/mtcp.c
@@ -792,6 +792,7 @@
int statu= s;

top->mode =3D CM_TOP;+ top->multi =3D &m= ulti;
context_clear_2(top);
/* initialize top-tunnel instance */
diff --gi= t 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/openvp= n.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_c= ontext *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 1631. To unsubscribe, or for help writing ma= il filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: release/2.6
Gerrit-Change-Id: I974e10ec91a0b63f52387f1406c= e1b49145eb0be
Gerrit-Change-Number: 1631
Gerrit-PatchSet: 1
Gerrit-Owner: ralf_lici <ralf@...2726...>= ;
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
= --ru70m9ft8LQ=--