mirror of
https://github.com/OpenVPN/openvpn.git
synced 2026-05-28 04:03:29 -04:00
multi: store multi_context address inside top instance
Future modifications to DCO require accessing the server multi_context object. Since it is currently a stack variable that is pointed by no one, we'd need to pass it to all kind of functions to ensure it can reach the DCO code. To make the implementation simpler, it is preferable to simply assign its address to a struct context's field. While at it, make some multi_* functions static as they used only inside multi.c, where they are defined. Change-Id: Ibf64c681e02ac572d339d4d98e75ceb0cd417c45 Signed-off-by: Antonio Quartulli <antonio@mandelbit.com> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <20250723061034.20240-1-gert@greenie.muc.de> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg32266.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
This commit is contained in:
parent
7bcafb316e
commit
7f5a6deae3
3 changed files with 15 additions and 18 deletions
|
|
@ -290,9 +290,10 @@ int_compare_function(const void *key1, const void *key2)
|
|||
/*
|
||||
* Main initialization function, init multi_context object.
|
||||
*/
|
||||
void
|
||||
multi_init(struct multi_context *m, struct context *t)
|
||||
static void
|
||||
multi_init(struct context *t)
|
||||
{
|
||||
struct multi_context *m = t->multi;
|
||||
int dev = DEV_TYPE_UNDEF;
|
||||
|
||||
msg(D_MULTI_LOW, "MULTI: multi_init called, r=%d v=%d",
|
||||
|
|
@ -706,7 +707,7 @@ multi_close_instance(struct multi_context *m,
|
|||
/*
|
||||
* Called on shutdown or restart.
|
||||
*/
|
||||
void
|
||||
static void
|
||||
multi_uninit(struct multi_context *m)
|
||||
{
|
||||
if (m->hash)
|
||||
|
|
@ -3922,14 +3923,14 @@ multi_process_per_second_timers_dowork(struct multi_context *m)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
multi_top_init(struct multi_context *m, struct context *top)
|
||||
static void
|
||||
multi_top_init(struct context *top)
|
||||
{
|
||||
inherit_context_top(&m->top, top);
|
||||
m->top.c2.buffers = init_context_buffers(&top->c2.frame);
|
||||
inherit_context_top(&top->multi->top, top);
|
||||
top->multi->top.c2.buffers = init_context_buffers(&top->c2.frame);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
multi_top_free(struct multi_context *m)
|
||||
{
|
||||
close_context(&m->top, -1, CC_GC_FREE);
|
||||
|
|
@ -4324,6 +4325,7 @@ tunnel_server(struct context *top)
|
|||
struct multi_context multi;
|
||||
|
||||
top->mode = CM_TOP;
|
||||
top->multi = &multi;
|
||||
context_clear_2(top);
|
||||
|
||||
/* initialize top-tunnel instance */
|
||||
|
|
@ -4334,10 +4336,10 @@ tunnel_server(struct context *top)
|
|||
}
|
||||
|
||||
/* initialize global multi_context object */
|
||||
multi_init(&multi, top);
|
||||
multi_init(top);
|
||||
|
||||
/* initialize our cloned top object */
|
||||
multi_top_init(&multi, top);
|
||||
multi_top_init(top);
|
||||
|
||||
/* initialize management interface */
|
||||
init_management_callback_multi(&multi);
|
||||
|
|
|
|||
|
|
@ -263,14 +263,6 @@ const char *multi_instance_string(const struct multi_instance *mi, bool null, st
|
|||
* Called by mtcp.c, mudp.c, or other (to be written) protocol drivers
|
||||
*/
|
||||
|
||||
void multi_init(struct multi_context *m, struct context *t);
|
||||
|
||||
void multi_uninit(struct multi_context *m);
|
||||
|
||||
void multi_top_init(struct multi_context *m, struct context *top);
|
||||
|
||||
void multi_top_free(struct multi_context *m);
|
||||
|
||||
struct multi_instance *multi_create_instance(struct multi_context *m, const struct mroute_addr *real,
|
||||
struct link_socket *sock);
|
||||
|
||||
|
|
|
|||
|
|
@ -491,6 +491,9 @@ struct context
|
|||
* 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. */
|
||||
|
|
|
|||
Loading…
Reference in a new issue