@@ -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;
}
@@ -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;
@@ -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;
@@ -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;
}
@@ -43,6 +43,8 @@
struct nl_cb *nl_cb;
int status;
+ struct context *c;
+
enum ovpn_mode ifmode;
int ovpn_dco_id;
@@ -53,7 +53,7 @@
}
bool
-ovpn_dco_init(int mode, dco_context_t *dco)
+ovpn_dco_init(struct context *c)
{
return true;
}
@@ -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 */
@@ -792,6 +792,7 @@
int status;
top->mode = CM_TOP;
+ top->multi = &multi;
context_clear_2(top);
/* initialize top-tunnel instance */
@@ -466,6 +466,7 @@
struct multi_context multi;
top->mode = CM_TOP;
+ top->multi = &multi;
context_clear_2(top);
/* initialize top-tunnel instance */
@@ -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. */