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>
| ... | ... |
@@ -290,9 +290,10 @@ int_compare_function(const void *key1, const void *key2) |
| 290 | 290 |
/* |
| 291 | 291 |
* Main initialization function, init multi_context object. |
| 292 | 292 |
*/ |
| 293 |
-void |
|
| 294 |
-multi_init(struct multi_context *m, struct context *t) |
|
| 293 |
+static void |
|
| 294 |
+multi_init(struct context *t) |
|
| 295 | 295 |
{
|
| 296 |
+ struct multi_context *m = t->multi; |
|
| 296 | 297 |
int dev = DEV_TYPE_UNDEF; |
| 297 | 298 |
|
| 298 | 299 |
msg(D_MULTI_LOW, "MULTI: multi_init called, r=%d v=%d", |
| ... | ... |
@@ -706,7 +707,7 @@ multi_close_instance(struct multi_context *m, |
| 706 | 706 |
/* |
| 707 | 707 |
* Called on shutdown or restart. |
| 708 | 708 |
*/ |
| 709 |
-void |
|
| 709 |
+static void |
|
| 710 | 710 |
multi_uninit(struct multi_context *m) |
| 711 | 711 |
{
|
| 712 | 712 |
if (m->hash) |
| ... | ... |
@@ -3922,14 +3923,14 @@ multi_process_per_second_timers_dowork(struct multi_context *m) |
| 3922 | 3922 |
} |
| 3923 | 3923 |
} |
| 3924 | 3924 |
|
| 3925 |
-void |
|
| 3926 |
-multi_top_init(struct multi_context *m, struct context *top) |
|
| 3925 |
+static void |
|
| 3926 |
+multi_top_init(struct context *top) |
|
| 3927 | 3927 |
{
|
| 3928 |
- inherit_context_top(&m->top, top); |
|
| 3929 |
- m->top.c2.buffers = init_context_buffers(&top->c2.frame); |
|
| 3928 |
+ inherit_context_top(&top->multi->top, top); |
|
| 3929 |
+ top->multi->top.c2.buffers = init_context_buffers(&top->c2.frame); |
|
| 3930 | 3930 |
} |
| 3931 | 3931 |
|
| 3932 |
-void |
|
| 3932 |
+static void |
|
| 3933 | 3933 |
multi_top_free(struct multi_context *m) |
| 3934 | 3934 |
{
|
| 3935 | 3935 |
close_context(&m->top, -1, CC_GC_FREE); |
| ... | ... |
@@ -4324,6 +4325,7 @@ tunnel_server(struct context *top) |
| 4324 | 4324 |
struct multi_context multi; |
| 4325 | 4325 |
|
| 4326 | 4326 |
top->mode = CM_TOP; |
| 4327 |
+ top->multi = &multi; |
|
| 4327 | 4328 |
context_clear_2(top); |
| 4328 | 4329 |
|
| 4329 | 4330 |
/* initialize top-tunnel instance */ |
| ... | ... |
@@ -4334,10 +4336,10 @@ tunnel_server(struct context *top) |
| 4334 | 4334 |
} |
| 4335 | 4335 |
|
| 4336 | 4336 |
/* initialize global multi_context object */ |
| 4337 |
- multi_init(&multi, top); |
|
| 4337 |
+ multi_init(top); |
|
| 4338 | 4338 |
|
| 4339 | 4339 |
/* initialize our cloned top object */ |
| 4340 |
- multi_top_init(&multi, top); |
|
| 4340 |
+ multi_top_init(top); |
|
| 4341 | 4341 |
|
| 4342 | 4342 |
/* initialize management interface */ |
| 4343 | 4343 |
init_management_callback_multi(&multi); |
| ... | ... |
@@ -263,14 +263,6 @@ const char *multi_instance_string(const struct multi_instance *mi, bool null, st |
| 263 | 263 |
* Called by mtcp.c, mudp.c, or other (to be written) protocol drivers |
| 264 | 264 |
*/ |
| 265 | 265 |
|
| 266 |
-void multi_init(struct multi_context *m, struct context *t); |
|
| 267 |
- |
|
| 268 |
-void multi_uninit(struct multi_context *m); |
|
| 269 |
- |
|
| 270 |
-void multi_top_init(struct multi_context *m, struct context *top); |
|
| 271 |
- |
|
| 272 |
-void multi_top_free(struct multi_context *m); |
|
| 273 |
- |
|
| 274 | 266 |
struct multi_instance *multi_create_instance(struct multi_context *m, const struct mroute_addr *real, |
| 275 | 267 |
struct link_socket *sock); |
| 276 | 268 |
|
| ... | ... |
@@ -491,6 +491,9 @@ struct context |
| 491 | 491 |
* CM_P2P, \c CM_TOP, \c CM_TOP_CLONE, |
| 492 | 492 |
* \c CM_CHILD_UDP, and \c CM_CHILD_TCP. */ |
| 493 | 493 |
|
| 494 |
+ struct multi_context *multi; /**< Pointer to the main P2MP context. |
|
| 495 |
+ * Non-NULL only when mode == CM_TOP. */ |
|
| 496 |
+ |
|
| 494 | 497 |
struct gc_arena gc; /**< Garbage collection arena for |
| 495 | 498 |
* allocations done in the scope of this |
| 496 | 499 |
* context structure. */ |