Skip to contentSkip to conversation

Change in openvpn[release/2.6]: dco: port core/context infrastructure needed for backport of commit 7...

Openvpn-devel In review ralf_lici (Code Review) 2 participants 6 messages Apr 20 – Apr 21 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1776701747000.I974e10ec91a0b63f52387f1406ce1b49145eb0be@...2715...

#1 lore raw

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=email

to review the following change.

Change subject: dco: port core/context infrastructure needed for backport of 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 <[email protected]...>.

Change-Id I974e10ec91a0b63f52387f1406ce1b49145eb0be

---
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

src/openvpn/dco.h +3 -4
index 50ebb35..334d468 100644
@@ -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;
 }
src/openvpn/dco_freebsd.c +4 -2
index 15add74..b164bd3 100644
@@ -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 = c;
+
+    if (open_fd(&c->c1.tuntap->dco) < 0)
     {
         msg(M_ERR, "Failed to open socket");
         return false;
src/openvpn/dco_freebsd.h +1 -0
index ab5891e8..e8f723e 100644
@@ -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;
src/openvpn/dco_linux.c +8 -2
index b2584b9..493fce6 100644
@@ -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 = &c->c1.tuntap->dco;
+
+    switch (c->mode)
     {
         case CM_TOP:
             dco->ifmode = OVPN_MODE_MP;
@@ -407,6 +409,10 @@
             ASSERT(false);
     }
 
+    /* store pointer to context as it may be required by message
+     * parsing routines
+     */
+    dco->c = c;
     ovpn_dco_init_netlink(dco);
     return true;
 }
src/openvpn/dco_linux.h +2 -0
index 5179912..cf6bdd4 100644
@@ -43,6 +43,8 @@
     struct nl_cb *nl_cb;
     int status;
 
+    struct context *c;
+
     enum ovpn_mode ifmode;
 
     int ovpn_dco_id;
src/openvpn/dco_win.c +1 -1
index 0b8f831..bc465db 100644
@@ -53,7 +53,7 @@
 }
 
 bool
-ovpn_dco_init(int mode, dco_context_t *dco)
+ovpn_dco_init(struct context *c)
 {
     return true;
 }
src/openvpn/init.c +1 -1
index 1476737..c2cfd24 100644
@@ -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 */
src/openvpn/mtcp.c +1 -0
index 3e33b15..38c938e 100644
@@ -792,6 +792,7 @@
     int status;
 
     top->mode = CM_TOP;
+    top->multi = &multi;
     context_clear_2(top);
 
     /* initialize top-tunnel instance */
src/openvpn/mudp.c +1 -0
index f7c9ffd..8cc717b 100644
@@ -466,6 +466,7 @@
     struct multi_context multi;
 
     top->mode = CM_TOP;
+    top->multi = &multi;
     context_clear_2(top);
 
     /* initialize top-tunnel instance */
src/openvpn/openvpn.h +3 -0
index 9cba1c5..3879772 100644
@@ -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 == CM_TOP. */
+
     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=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

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 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: plaisthos, ralf_lici.

cron2 has posted comments on this change by ralf_lici. ( http://gerrit.openvpn.net/c/openvpn/+/1631?usp=email )

Change subject: dco: port core/context infrastructure needed for backport of commit 7791f53
......................................................................

Patch Set 1: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1631?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: release/2.6
Gerrit-Change-Id: I974e10ec91a0b63f52387f1406ce1b49145eb0be
Gerrit-Change-Number: 1631
Gerrit-PatchSet: 1
Gerrit-Owner: ralf_lici <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: ralf_lici <[email protected]...>
Gerrit-Comment-Date: Mon, 20 Apr 2026 16:59:05 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes

#3 lore raw

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

In reply to a message not in the archive

From: Ralf Lici <[email protected]...>

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 <[email protected]...>.

Change-Id I974e10ec91a0b63f52387f1406ce1b49145eb0be

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1631
---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to release/2.6.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1631
This mail reflects revision 1 of this Change.

Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>

src/openvpn/dco.h +3 -4
index 50ebb35..334d468 100644
@@ -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;
 }
src/openvpn/dco_freebsd.c +4 -2
index 15add74..b164bd3 100644
@@ -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 = c;
+
+    if (open_fd(&c->c1.tuntap->dco) < 0)
     {
         msg(M_ERR, "Failed to open socket");
         return false;
src/openvpn/dco_freebsd.h +1 -0
index ab5891e8..e8f723e 100644
@@ -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;
src/openvpn/dco_linux.c +8 -2
index b2584b9..493fce6 100644
@@ -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 = &c->c1.tuntap->dco;
+
+    switch (c->mode)
     {
         case CM_TOP:
             dco->ifmode = OVPN_MODE_MP;
@@ -407,6 +409,10 @@
             ASSERT(false);
     }
 
+    /* store pointer to context as it may be required by message
+     * parsing routines
+     */
+    dco->c = c;
     ovpn_dco_init_netlink(dco);
     return true;
 }
src/openvpn/dco_linux.h +2 -0
index 5179912..cf6bdd4 100644
@@ -43,6 +43,8 @@
     struct nl_cb *nl_cb;
     int status;
 
+    struct context *c;
+
     enum ovpn_mode ifmode;
 
     int ovpn_dco_id;
src/openvpn/dco_win.c +1 -1
index 0b8f831..bc465db 100644
@@ -53,7 +53,7 @@
 }
 
 bool
-ovpn_dco_init(int mode, dco_context_t *dco)
+ovpn_dco_init(struct context *c)
 {
     return true;
 }
src/openvpn/init.c +1 -1
index 1476737..c2cfd24 100644
@@ -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 */
src/openvpn/mtcp.c +1 -0
index 3e33b15..38c938e 100644
@@ -792,6 +792,7 @@
     int status;
 
     top->mode = CM_TOP;
+    top->multi = &multi;
     context_clear_2(top);
 
     /* initialize top-tunnel instance */
src/openvpn/mudp.c +1 -0
index f7c9ffd..8cc717b 100644
@@ -466,6 +466,7 @@
     struct multi_context multi;
 
     top->mode = CM_TOP;
+    top->multi = &multi;
     context_clear_2(top);
 
     /* initialize top-tunnel instance */
src/openvpn/openvpn.h +3 -0
index 9cba1c5..3879772 100644
@@ -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 == CM_TOP. */
+
     struct gc_arena gc;         /**< Garbage collection arena for
                                  *   allocations done in the scope of this
                                  *   context structure. */
#4 lore raw

[Openvpn-devel] [PATCH applied] Re: dco: port core/context infrastructure needed for backport of commit 7791f53

Thanks for digging through this, and backporting what is needed.

I have "git blame"'d master, and compared this backport to the master comments. The first one is

    commit a699681bb86c6e9a2c9f205543f60400208aea4b
    Author: Antonio Quartulli <[email protected]...>
    Date:   Wed Jul 23 15:39:11 2025 +0200

	dco: only pass struct context to init function

.. which is fully included in this commit here, and pretty straightforward.

The second one is

    commit 7f5a6deae33a338a23d7e8ff8526db8fdddf4bc2
    Author: Antonio Quartulli <[email protected]...>
    Date:   Wed Jul 23 08:10:25 2025 +0200

	multi: store multi_context address inside top instance

which is more complex, as the master commit modifies "multi.c" which does not exist in release/2.6 (mudp.c, mtcp.c) - and also changes more things, so this is backporting the change we need (top->multi) to the distinct UDP/TCP server loops.

I have run this with and without DCO on Linux and FreeBSD, client and server setups, and have test compiled the windows version. BB has compiled and client-tested all the rest.

Your patch has been applied to the release/2.6 branch.

commit 876a8cf5fd6166a22bfe6b6f37889d3cff3a17c6

Author: Ralf Lici
Date:   Mon Apr 20 18:59:17 2026 +0200
     dco: port core/context infrastructure needed for backport of commit 7791f53

     Signed-off-by: Ralf Lici <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1631
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg36691.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#5 lore raw
In reply to a message not in the archive

cron2 has uploaded a new patch set (#2) to the change originally created by ralf_lici. ( http://gerrit.openvpn.net/c/openvpn/+/1631?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by cron2

Change subject: dco: port core/context infrastructure needed for backport of 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 <[email protected]...>.

The original commits in master are

    commit a699681bb86c6e9a2c9f205543f60400208aea4b
    Author: Antonio Quartulli <[email protected]...>
    Date:   Wed Jul 23 15:39:11 2025 +0200

	dco: only pass struct context to init function

    commit 7f5a6deae33a338a23d7e8ff8526db8fdddf4bc2
    Author: Antonio Quartulli <[email protected]...>
    Date:   Wed Jul 23 08:10:25 2025 +0200

	multi: store multi_context address inside top instance
Change-Id I974e10ec91a0b63f52387f1406ce1b49145eb0be

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1631
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg36691.html

---
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/2

src/openvpn/dco.h +3 -4
index 50ebb35..334d468 100644
@@ -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;
 }
src/openvpn/dco_freebsd.c +4 -2
index 15add74..b164bd3 100644
@@ -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 = c;
+
+    if (open_fd(&c->c1.tuntap->dco) < 0)
     {
         msg(M_ERR, "Failed to open socket");
         return false;
src/openvpn/dco_freebsd.h +1 -0
index ab5891e8..e8f723e 100644
@@ -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;
src/openvpn/dco_linux.c +8 -2
index b2584b9..493fce6 100644
@@ -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 = &c->c1.tuntap->dco;
+
+    switch (c->mode)
     {
         case CM_TOP:
             dco->ifmode = OVPN_MODE_MP;
@@ -407,6 +409,10 @@
             ASSERT(false);
     }
 
+    /* store pointer to context as it may be required by message
+     * parsing routines
+     */
+    dco->c = c;
     ovpn_dco_init_netlink(dco);
     return true;
 }
src/openvpn/dco_linux.h +2 -0
index 5179912..cf6bdd4 100644
@@ -43,6 +43,8 @@
     struct nl_cb *nl_cb;
     int status;
 
+    struct context *c;
+
     enum ovpn_mode ifmode;
 
     int ovpn_dco_id;
src/openvpn/dco_win.c +1 -1
index 0b8f831..bc465db 100644
@@ -53,7 +53,7 @@
 }
 
 bool
-ovpn_dco_init(int mode, dco_context_t *dco)
+ovpn_dco_init(struct context *c)
 {
     return true;
 }
src/openvpn/init.c +1 -1
index 1476737..c2cfd24 100644
@@ -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 */
src/openvpn/mtcp.c +1 -0
index 3e33b15..38c938e 100644
@@ -792,6 +792,7 @@
     int status;
 
     top->mode = CM_TOP;
+    top->multi = &multi;
     context_clear_2(top);
 
     /* initialize top-tunnel instance */
src/openvpn/mudp.c +1 -0
index f7c9ffd..8cc717b 100644
@@ -466,6 +466,7 @@
     struct multi_context multi;
 
     top->mode = CM_TOP;
+    top->multi = &multi;
     context_clear_2(top);
 
     /* initialize top-tunnel instance */
src/openvpn/openvpn.h +3 -0
index 9cba1c5..3879772 100644
@@ -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 == CM_TOP. */
+
     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=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: release/2.6
Gerrit-Change-Id: I974e10ec91a0b63f52387f1406ce1b49145eb0be
Gerrit-Change-Number: 1631
Gerrit-PatchSet: 2
Gerrit-Owner: ralf_lici <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>

#6 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1631?usp=email )

Change subject: dco: port core/context infrastructure needed for backport of 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 <[email protected]...>.

The original commits in master are

    commit a699681bb86c6e9a2c9f205543f60400208aea4b
    Author: Antonio Quartulli <[email protected]...>
    Date:   Wed Jul 23 15:39:11 2025 +0200

	dco: only pass struct context to init function

    commit 7f5a6deae33a338a23d7e8ff8526db8fdddf4bc2
    Author: Antonio Quartulli <[email protected]...>
    Date:   Wed Jul 23 08:10:25 2025 +0200

	multi: store multi_context address inside top instance
Change-Id I974e10ec91a0b63f52387f1406ce1b49145eb0be

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1631
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg36691.html

---
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(-)
src/openvpn/dco.h +3 -4
index 50ebb35..334d468 100644
@@ -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;
 }
src/openvpn/dco_freebsd.c +4 -2
index 15add74..b164bd3 100644
@@ -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 = c;
+
+    if (open_fd(&c->c1.tuntap->dco) < 0)
     {
         msg(M_ERR, "Failed to open socket");
         return false;
src/openvpn/dco_freebsd.h +1 -0
index ab5891e8..e8f723e 100644
@@ -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;
src/openvpn/dco_linux.c +8 -2
index b2584b9..493fce6 100644
@@ -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 = &c->c1.tuntap->dco;
+
+    switch (c->mode)
     {
         case CM_TOP:
             dco->ifmode = OVPN_MODE_MP;
@@ -407,6 +409,10 @@
             ASSERT(false);
     }
 
+    /* store pointer to context as it may be required by message
+     * parsing routines
+     */
+    dco->c = c;
     ovpn_dco_init_netlink(dco);
     return true;
 }
src/openvpn/dco_linux.h +2 -0
index 5179912..cf6bdd4 100644
@@ -43,6 +43,8 @@
     struct nl_cb *nl_cb;
     int status;
 
+    struct context *c;
+
     enum ovpn_mode ifmode;
 
     int ovpn_dco_id;
src/openvpn/dco_win.c +1 -1
index 0b8f831..bc465db 100644
@@ -53,7 +53,7 @@
 }
 
 bool
-ovpn_dco_init(int mode, dco_context_t *dco)
+ovpn_dco_init(struct context *c)
 {
     return true;
 }
src/openvpn/init.c +1 -1
index 1476737..c2cfd24 100644
@@ -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 */
src/openvpn/mtcp.c +1 -0
index 3e33b15..38c938e 100644
@@ -792,6 +792,7 @@
     int status;
 
     top->mode = CM_TOP;
+    top->multi = &multi;
     context_clear_2(top);
 
     /* initialize top-tunnel instance */
src/openvpn/mudp.c +1 -0
index f7c9ffd..8cc717b 100644
@@ -466,6 +466,7 @@
     struct multi_context multi;
 
     top->mode = CM_TOP;
+    top->multi = &multi;
     context_clear_2(top);
 
     /* initialize top-tunnel instance */
src/openvpn/openvpn.h +3 -0
index 9cba1c5..3879772 100644
@@ -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 == CM_TOP. */
+
     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=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

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 <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>