From: "ordex (Code Review)" Date: Tue, 22 Jul 2025 20:22:18 +0000 References: Reply-To: antonio@...2726..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="hKLjB2HHgDE="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: dco: only pass struct context to init function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --hKLjB2HHgDE= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld, plaisthos. Hello plaisthos, flichtenheld, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/1094?usp=3Demail to review the following change. Change subject: dco: only pass struct context to init function ...................................................................... dco: only pass struct context to init function Future DCO code will require accessing the `multi` member of the context object. For this reason a pointer to the context has to be stored in the DCO context along with the rest. At this point, rather than making the call to ovpn_dco_init() longer with more and more parameters, pass the struct context only and let the implementation extract the needed fields. Change-Id: I673a17f8c5dec66cc6c28c1ed44780a7a63927d7 Signed-off-by: Antonio Quartulli --- M src/openvpn/dco.h M src/openvpn/dco_freebsd.c M src/openvpn/dco_linux.c M src/openvpn/init.c 4 files changed, 13 insertions(+), 9 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/94/1094/1 diff --git a/src/openvpn/dco.h b/src/openvpn/dco.h index f38316d..9c5c01a 100644 --- a/src/openvpn/dco.h +++ b/src/openvpn/dco.h @@ -104,12 +104,10 @@ /** * Initialize the DCO context * - * @param mode the instance operating mode (P2P or multi-peer) - * @param dco the context to initialize - * @param dev_node device node, used on Windows to specify certain DCO ad= apter + * @param c the main instance context * @return true on success, false otherwise */ -bool ovpn_dco_init(int mode, dco_context_t *dco, const char *dev_node); +bool ovpn_dco_init(struct context *c); /** * Open/create a DCO interface diff --git a/src/openvpn/dco_freebsd.c b/src/openvpn/dco_freebsd.c index b8816c6..98d8fb5 100644 --- a/src/openvpn/dco_freebsd.c +++ b/src/openvpn/dco_freebsd.c @@ -165,9 +165,9 @@ } bool -ovpn_dco_init(int mode, dco_context_t *dco, const char *dev_node) +ovpn_dco_init(struct context *c) { - if (open_fd(dco) < 0) + if (open_fd(&c->c1.tuntap->dco) < 0) { msg(M_ERR, "Failed to open socket"); return false; diff --git a/src/openvpn/dco_linux.c b/src/openvpn/dco_linux.c index f04ebfe..c92c196 100644 --- a/src/openvpn/dco_linux.c +++ b/src/openvpn/dco_linux.c @@ -438,9 +438,11 @@ } bool -ovpn_dco_init(int mode, dco_context_t *dco, const char *dev_node) +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; @@ -454,6 +456,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/init.c b/src/openvpn/init.c index 77747a2..aac8a6a 100644 --- a/src/openvpn/init.c +++ b/src/openvpn/init.c @@ -2007,7 +2007,7 @@ if (dco_enabled(&c->options)) { - ovpn_dco_init(c->mode, &c->c1.tuntap->dco, c->options.dev_node= ); + ovpn_dco_init(c); } /* open the tun device */ -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1094?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: I673a17f8c5dec66cc6c28c1ed44780a7a63927d7 Gerrit-Change-Number: 1094 Gerrit-PatchSet: 1 Gerrit-Owner: ordex Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: flichtenheld Gerrit-MessageType: newchange --hKLjB2HHgDE= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld, plaisthos.

ordex would like plaisthos and flichtenheld to review t= his change.

V= iew Change

dco: only pass struct context to init function

Future= DCO code will require accessing the `multi` member of the
context objec= t.

For this reason a pointer to the context has to be stored in the<= br>DCO context along with the rest.

At this point, rather than makin= g the call to ovpn_dco_init()
longer with more and more parameters, pass= the struct context
only and let the implementation extract the needed f= ields.

Change-Id: I673a17f8c5dec66cc6c28c1ed44780a7a63927d7
Signe= d-off-by: Antonio Quartulli <antonio@...2726...>
---
M src/open= vpn/dco.h
M src/openvpn/dco_freebsd.c
M src/openvpn/dco_linux.c
M = src/openvpn/init.c
4 files changed, 13 insertions(+), 9 deletions(-)
=
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/94/1094=
/1
diff --git a/src/openvpn/dco.h b/src/openvpn/dco.h
index f38316d..9c5c01a 100644
--- a/src/openvpn/dco.h
+++ b/src/openvpn/dco.h
@@ -104,12 +104,10 @@=
/**
* Initialize the DCO context=
*
- * @para= m mode the instance operating mode (P2P or multi-peer)
- * @param dco the context to in= itialize

- * @param dev= _node device node, used on Windows to specify certain DCO adapter+ * @param c the main= instance context
* @return true on success, fal= se otherwise
*/
-bool ovpn_dco_init(int mode, dco_context_t *dco, const char *de= v_node);
+bool ovpn_d= co_init(struct context *c);

/** * Open/create a DCO interface
diff --git a/src/op= envpn/dco_freebsd.c b/src/openvpn/dco_freebsd.c
index b8816= c6..98d8fb5 100644
--- a/src/openvpn/dco_freebsd.c+++ b/src/openvpn/dco_freebsd.c
@@ -165,9 +165,9 @@=
}

bool
-ovpn_dco_init(int mode, dco_context_t= *dco, const char *dev_node)
+ovpn_dco_init(struct context *c)
{
- if (open_fd(dco) < 0)<= br>+ if (open_fd(&c->= c1.tuntap->dco) < 0)
{
= msg(M_ERR, "Failed to open socket");
ret= urn false;
diff --git a/src/openvpn/dco_linux.c b/src/openv= pn/dco_linux.c
index f04ebfe..c92c196 100644
--- a/src/openvpn/dco_linux.c
+++ b/src/openvpn/dco_linux= .c
@@ -438,9 +438,11 @@
}
=
bool
-ovpn_dco_init(int mode, dco_context_t *dco, const char *dev_node)<= br>+ovpn_dco_init(struct contex= t *c)
{
= + dco_context_t *dco =3D &c->c1.tuntap->dco;
+
+ switch (c->mode)
{ case CM_TOP:
dco->ifmode = =3D OVPN_MODE_MP;
@@ -454,6 +456,10 @@
= ASSERT(false);
}

= + /* store pointer to contex= t 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/init.c b/src/openvpn/init.c
index 7774= 7a2..aac8a6a 100644
--- a/src/openvpn/init.c
+++ b/src/openvpn/init.c
@@ -2007,7 +2007,7 @@
=
if (dco_enabled(&c->options))

{
-= ovpn_dco_init(c->mode, &c->c1.tuntap->dco, c->o= ptions.dev_node);
+ = ovpn_dco_init(c);
}

/* open the tun device */

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

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I673a17f8c5dec66cc6c28c1ed44= 780a7a63927d7
Gerrit-Change-Number: 1094
Gerrit-PatchSet: 1
Gerrit-Owner: ordex <antonio@...2726...>=
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
Gerrit-MessageType: newchange
--hKLjB2HHgDE=--