From: "cron2 (Code Review)" Date: Wed, 23 Jul 2025 15:00:14 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641..., lstipakov@...277..., antonio@...2726... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="rG/rSXynNDY="; 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 , stipa --rG/rSXynNDY= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has uploaded a new patch set (#5) to the change originally created by= ordex. ( http://gerrit.openvpn.net/c/openvpn/+/1094?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+2 by cron2 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 Acked-by: Gert Doering Message-Id: <20250723133918.19431-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg32= 293.html Signed-off-by: Gert Doering --- M src/openvpn/dco.h M src/openvpn/dco_freebsd.c M src/openvpn/dco_linux.c M src/openvpn/dco_linux.h M src/openvpn/dco_win.c M src/openvpn/init.c 6 files changed, 21 insertions(+), 13 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/94/1094/5 diff --git a/src/openvpn/dco.h b/src/openvpn/dco.h index f38316d..9078417 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 @@ -297,7 +295,7 @@ } static inline bool -ovpn_dco_init(int mode, dco_context_t *dco, const char *dev_node) +ovpn_dco_init(struct context *c) { return true; } 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 3652a49..ec6efaa 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/dco_linux.h b/src/openvpn/dco_linux.h index 676b8cd..5e61cf1 100644 --- a/src/openvpn/dco_linux.h +++ b/src/openvpn/dco_linux.h @@ -65,6 +65,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 83db739..e5a33a0 100644 --- a/src/openvpn/dco_win.c +++ b/src/openvpn/dco_win.c @@ -188,9 +188,11 @@ * state. The server socket should be initialized later by dco_mp_start_vp= n(). */ 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 MODE_POINT_TO_POINT: dco->ifmode =3D DCO_MODE_P2P; @@ -198,7 +200,7 @@ break; case MODE_SERVER: - ovpn_dco_init_mp(dco, dev_node); + ovpn_dco_init_mp(dco, c->options.dev_node); break; default: 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: 5 Gerrit-Owner: ordex Gerrit-Reviewer: cron2 Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-CC: stipa Gerrit-MessageType: newpatchset --rG/rSXynNDY= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

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

View Change

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

dco: only pass struct context to init function
Future DCO code will require accessing the `multi` member of the
conte= xt 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 th= an making the call to ovpn_dco_init()
longer with more and more paramete= rs, pass the struct context
only and let the implementation extract the = needed fields.

Change-Id: I673a17f8c5dec66cc6c28c1ed44780a7a63927d7<= br>Signed-off-by: Antonio Quartulli <antonio@...2726...>
Acked-by:= Gert Doering <gert@...1296...>
Message-Id: <20250723133918.194= 31-1-gert@...1296...>
URL: https://www.mail-archive.com/openvpn-devel= @lists.sourceforge.net/msg32293.html
Signed-off-by: Gert Doering <ger= t@...1296...>
---
M src/openvpn/dco.h
M src/openvpn/dco_freebsd= .c
M src/openvpn/dco_linux.c
M src/openvpn/dco_linux.h
M src/openv= pn/dco_win.c
M src/openvpn/init.c
6 files changed, 21 insertions(+), = 13 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn r=
efs/changes/94/1094/5
diff --git a/src/openvpn/dco.h b/src/openvpn/=
dco.h
index f38316d..9078417 100644
--- a/s= rc/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-pe= er)
- * @param dco = the context to initialize
- * @param dev_node device node, used on Windows to specify certain D= CO adapter
+ * @param= c the main instance context
* @return t= rue 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
@@ -297,7 +295,7 @@
}

= static inline bool
-ovp= n_dco_init(int mode, dco_context_t *dco, const char *dev_node)
+ovpn_dco_init(struct context *c)=
{
return true;
}

diff --git a/src/openvpn/dco_freebsd.c b/src/openvpn/dco_free= bsd.c
index b8816c6..98d8fb5 100644
--- a/s= rc/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)<= /span>
{
- = if (open_fd(dco) < 0)
+ if (open_fd(&c->c1.tuntap->dco) < 0)
{

msg(M_ERR, "Failed to open socket&quo= t;);
return false;
diff --git a/sr= c/openvpn/dco_linux.c b/src/openvpn/dco_linux.c
index 3652a= 49..ec6efaa 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 *d= co, 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/dco_linux.h b/src/openv= pn/dco_linux.h
index 676b8cd..5e61cf1 100644
--- a/src/openvpn/dco_linux.h
+++ b/src/openvpn/dco_linux= .h
@@ -65,6 +65,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 83db739..e5a33a0 100644
--- a/src/openvpn/dco_wi= n.c
+++ b/src/openvpn/dco_win.c
@@ -188,9 += 188,11 @@
* state. The server socket should be initialize= d later by dco_mp_start_vpn().
*/
bool
-ovpn_dco_init(int mode,= dco_context_t *dco, const char *dev_node)
+ovpn_dco_init(struct context *c)
{<= /span>
- switch (mode)

+ dco_context_t *dco = =3D &c->c1.tuntap->dco;
+
+ s= witch (c->mode)
{
case MOD= E_POINT_TO_POINT:
dco->ifmode =3D DCO_MODE_= P2P;
@@ -198,7 +200,7 @@
break= ;

case MODE_SERVER:
- ovpn_dco_init_mp(dco, = dev_node);
+ = ovpn_dco_init_mp(dco, c->options.dev_node);
= break;

default:
diff --git a/src/openvpn/init.c b/src/openvpn/init.c
in= dex 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 change 1094. To unsubscribe, or for help writi= ng mail filters, visit setti= ngs.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I673a17f8c5dec66cc6c28c1ed44= 780a7a63927d7
Gerrit-Change-Number: 1094
Gerrit-PatchSet: 5
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-CC: stipa <lstipakov@...277...> <= /div>
Gerrit-MessageType: newpatchset
--rG/rSXynNDY=--