OpenVPN
multi_io.c
Go to the documentation of this file.
1/*
2 * OpenVPN -- An application to securely tunnel IP networks
3 * over a single TCP/UDP port, with support for SSL/TLS-based
4 * session authentication and key exchange,
5 * packet encryption, packet authentication, and
6 * packet compression.
7 *
8 * Copyright (C) 2002-2025 OpenVPN Inc <sales@openvpn.net>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2
12 * as published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, see <https://www.gnu.org/licenses/>.
21 */
22
23#ifdef HAVE_CONFIG_H
24#include "config.h"
25#endif
26
27#include "syshead.h"
28
29#include "memdbg.h"
30
31#include "multi.h"
32#include "forward.h"
33#include "multi_io.h"
34
35#ifdef HAVE_SYS_INOTIFY_H
36#include <sys/inotify.h>
37#endif
38
39/*
40 * Special tags passed to event.[ch] functions
41 */
42#define MULTI_IO_SOCKET ((void *)1)
43#define MULTI_IO_TUN ((void *)2)
44#define MULTI_IO_SIG ((void *)3) /* Only on Windows */
45#define MULTI_IO_MANAGEMENT ((void *)4)
46#define MULTI_IO_FILE_CLOSE_WRITE ((void *)5)
47#define MULTI_IO_DCO ((void *)6)
48
49struct ta_iow_flags
50{
51 unsigned int flags;
52 unsigned int ret;
53 unsigned int tun;
54 unsigned int sock;
55};
56
57#ifdef ENABLE_DEBUG
58static const char *
59pract(int action)
60{
61 switch (action)
62 {
63 case TA_UNDEF:
64 return "TA_UNDEF";
65
66 case TA_SOCKET_READ:
67 return "TA_SOCKET_READ";
68
70 return "TA_SOCKET_READ_RESIDUAL";
71
72 case TA_SOCKET_WRITE:
73 return "TA_SOCKET_WRITE";
74
76 return "TA_SOCKET_WRITE_READY";
77
79 return "TA_SOCKET_WRITE_DEFERRED";
80
81 case TA_TUN_READ:
82 return "TA_TUN_READ";
83
84 case TA_TUN_WRITE:
85 return "TA_TUN_WRITE";
86
87 case TA_INITIAL:
88 return "TA_INITIAL";
89
90 case TA_TIMEOUT:
91 return "TA_TIMEOUT";
92
94 return "TA_TUN_WRITE_TIMEOUT";
95
96 default:
97 return "?";
98 }
99}
100#endif /* ENABLE_DEBUG */
101
102static inline struct context *
104{
105 if (mi)
106 {
107 return &mi->context;
108 }
109 else
110 {
111 return &m->top;
112 }
113}
114
115struct multi_io *
116multi_io_init(int maxevents, int *maxclients)
117{
118 struct multi_io *multi_io;
119 const int extra_events = BASE_N_EVENTS;
120
121 ASSERT(maxevents >= 1);
122 ASSERT(maxclients);
123
125 multi_io->maxevents = maxevents + extra_events;
129 *maxclients = max_int(min_int(multi_io->maxevents - extra_events, *maxclients), 1);
130 msg(D_MULTI_LOW, "MULTI IO: MULTI_IO INIT maxclients=%d maxevents=%d", *maxclients,
132 return multi_io;
133}
134
135void
137{
138 if (!mi)
139 {
140 return;
141 }
142
143 mi->socket_set_called = true;
145 {
147 &mi->context.c2.link_sockets[0]->ev_arg, NULL);
148 }
149 else
150 {
153 &mi->tcp_rwflags);
154 }
155}
156
157void
159{
160 if (multi_io)
161 {
163 free(multi_io->esr);
164 free(multi_io);
165 }
166}
167
168int
170{
171 int status, i;
172 unsigned int *persistent = &m->multi_io->tun_rwflags;
173
175 {
176 for (i = 0; i < m->top.c1.link_sockets_num; i++)
177 {
179 &m->top.c2.link_sockets[i]->ev_arg);
180 }
181 }
182
184 {
186 }
187
188 tun_set(m->top.c1.tuntap, m->multi_io->es, EVENT_READ, MULTI_IO_TUN, persistent);
189#if defined(ENABLE_DCO)
191#endif
192
193#ifdef ENABLE_MANAGEMENT
194 if (management)
195 {
198 }
199#endif
200
201#ifdef ENABLE_ASYNC_PUSH
202 /* arm inotify watcher */
204#endif
205
206 status =
208 update_time();
209 m->multi_io->n_esr = 0;
210 if (status > 0)
211 {
212 m->multi_io->n_esr = status;
213 }
214 return status;
215}
216
217static int
218multi_io_wait_lite(struct multi_context *m, struct multi_instance *mi, const int action,
219 bool *tun_input_pending)
220{
221 struct context *c = multi_get_context(m, mi);
222 unsigned int looking_for = 0;
223
224 dmsg(D_MULTI_DEBUG, "MULTI IO: multi_io_wait_lite a=%s mi=" ptr_format, pract(action),
225 (ptr_type)mi);
226
227 tv_clear(&c->c2.timeval); /* ZERO-TIMEOUT */
228
229 switch (action)
230 {
231 case TA_TUN_READ:
232 looking_for = TUN_READ;
233 tun_input_pending = NULL;
235 break;
236
237 case TA_SOCKET_READ:
238 looking_for = SOCKET_READ;
239 tun_input_pending = NULL;
241 break;
242
243 case TA_TUN_WRITE:
244 looking_for = TUN_WRITE;
245 tun_input_pending = NULL;
246 /* For some reason, the Linux 2.2 TUN/TAP driver hits this timeout */
247 c->c2.timeval.tv_sec = 1;
250 perf_pop();
251 break;
252
253 case TA_SOCKET_WRITE:
254 looking_for = SOCKET_WRITE;
256 break;
257
258 default:
259 msg(M_FATAL, "MULTI IO: multi_io_wait_lite, unhandled action=%d", action);
260 }
261
262 if (tun_input_pending && (c->c2.event_set_status & TUN_READ))
263 {
264 *tun_input_pending = true;
265 }
266
267 if (c->c2.event_set_status & looking_for)
268 {
269 return action;
270 }
271 else
272 {
273 switch (action)
274 {
275 /* MULTI PROTOCOL socket output buffer is full */
276 case TA_SOCKET_WRITE:
278
279 /* TUN device timed out on accepting write */
280 case TA_TUN_WRITE:
282 }
283
284 return TA_UNDEF;
285 }
286}
287
288static struct multi_instance *
289multi_io_dispatch(struct multi_context *m, struct multi_instance *mi, const int action)
290{
291 const unsigned int mpp_flags = MPP_PRE_SELECT | MPP_RECORD_TOUCH;
292 struct multi_instance *touched = mi;
293 m->mpp_touched = &touched;
294
295 dmsg(D_MULTI_DEBUG, "MULTI IO: multi_io_dispatch a=%s mi=" ptr_format, pract(action),
296 (ptr_type)mi);
297
298 switch (action)
299 {
300 case TA_TUN_READ:
302 if (!IS_SIG(&m->top))
303 {
304 multi_process_incoming_tun(m, mpp_flags);
305 }
306 break;
307
308 case TA_SOCKET_READ:
310 ASSERT(mi);
313 set_prefix(mi);
315 clear_prefix();
316 if (!IS_SIG(&mi->context))
317 {
318 multi_process_incoming_link(m, mi, mpp_flags, mi->context.c2.link_sockets[0]);
319 if (!IS_SIG(&mi->context))
320 {
322 }
323 }
324 break;
325
326 case TA_TIMEOUT:
327 multi_process_timeout(m, mpp_flags);
328 break;
329
330 case TA_TUN_WRITE:
331 multi_process_outgoing_tun(m, mpp_flags);
332 break;
333
336 break;
337
339 ASSERT(mi);
341 break;
342
343 case TA_SOCKET_WRITE:
344 multi_tcp_process_outgoing_link(m, false, mpp_flags);
345 break;
346
348 multi_tcp_process_outgoing_link(m, true, mpp_flags);
349 break;
350
351 case TA_INITIAL:
352 ASSERT(mi);
354 multi_process_post(m, mi, mpp_flags);
355 break;
356
357 default:
358 msg(M_FATAL, "MULTI IO: multi_io_dispatch, unhandled action=%d", action);
359 }
360
361 m->mpp_touched = NULL;
362 return touched;
363}
364
365static int
366multi_io_post(struct multi_context *m, struct multi_instance *mi, const int action)
367{
368 struct context *c = multi_get_context(m, mi);
369 int newaction = TA_UNDEF;
370
371#define MTP_NONE 0
372#define MTP_TUN_OUT (1 << 0)
373#define MTP_LINK_OUT (1 << 1)
374 unsigned int flags = MTP_NONE;
375
376 if (TUN_OUT(c))
377 {
378 flags |= MTP_TUN_OUT;
379 }
380 if (LINK_OUT(c))
381 {
382 flags |= MTP_LINK_OUT;
383 }
384
385 switch (flags)
386 {
388 case MTP_TUN_OUT:
389 newaction = TA_TUN_WRITE;
390 break;
391
392 case MTP_LINK_OUT:
393 newaction = TA_SOCKET_WRITE;
394 break;
395
396 case MTP_NONE:
397 if (mi && sockets_read_residual(c))
398 {
399 newaction = TA_SOCKET_READ_RESIDUAL;
400 }
401 else
402 {
404 }
405 break;
406
407 default:
408 {
409 struct gc_arena gc = gc_new();
410 msg(M_FATAL, "MULTI IO: multi_io_post bad state, mi=%s flags=%d",
411 multi_instance_string(mi, false, &gc), flags);
412 gc_free(&gc);
413 break;
414 }
415 }
416
417 dmsg(D_MULTI_DEBUG, "MULTI IO: multi_io_post %s -> %s", pract(action), pract(newaction));
418
419 return newaction;
420}
421
422void
424{
425 struct multi_io *multi_io = m->multi_io;
426 int i;
427
428 for (i = 0; i < multi_io->n_esr; ++i)
429 {
430 struct event_set_return *e = &multi_io->esr[i];
431 struct event_arg *ev_arg = (struct event_arg *)e->arg;
432
433 /* incoming data for instance or listening socket? */
434 if (e->arg >= MULTI_N)
435 {
436 switch (ev_arg->type)
437 {
438 struct multi_instance *mi;
439
440 /* react to event on child instance */
442 if (!ev_arg->u.mi)
443 {
444 msg(D_MULTI_ERRORS, "MULTI IO: multi_io_proc_io: null minstance");
445 break;
446 }
447
448 mi = ev_arg->u.mi;
449 if (e->rwflags & EVENT_WRITE)
450 {
452 }
453 else if (e->rwflags & EVENT_READ)
454 {
455 multi_io_action(m, mi, TA_SOCKET_READ, false);
456 }
457 break;
458
460 if (!ev_arg->u.sock)
461 {
462 msg(D_MULTI_ERRORS, "MULTI IO: multi_io_proc_io: null socket");
463 break;
464 }
465 /* new incoming TCP client attempting to connect? */
467 {
470 }
471 else
472 {
474 mi = m->pending;
475 }
476 /* monitor and/or handle events that are
477 * triggered in succession by the first one
478 * before returning to the main loop. */
479 if (mi)
480 {
481 multi_io_action(m, mi, TA_INITIAL, false);
482 }
483 break;
484 }
485 }
486 else
487 {
488#ifdef ENABLE_MANAGEMENT
489 if (e->arg == MULTI_IO_MANAGEMENT)
490 {
493 }
494 else
495#endif
496 /* incoming data on TUN? */
497 if (e->arg == MULTI_IO_TUN)
498 {
499 if (e->rwflags & EVENT_WRITE)
500 {
501 multi_io_action(m, NULL, TA_TUN_WRITE, false);
502 }
503 else if (e->rwflags & EVENT_READ)
504 {
505 multi_io_action(m, NULL, TA_TUN_READ, false);
506 }
507 }
508 /* new incoming TCP client attempting to connect? */
509 else if (e->arg == MULTI_IO_SOCKET)
510 {
511 struct multi_instance *mi;
512 ASSERT(m->top.c2.link_sockets[0]);
515 if (mi)
516 {
517 multi_io_action(m, mi, TA_INITIAL, false);
518 }
519 }
520#if defined(ENABLE_DCO)
521 /* incoming data on DCO? */
522 else if (e->arg == MULTI_IO_DCO)
523 {
525 }
526#endif
527 /* signal received? */
528 else if (e->arg == MULTI_IO_SIG)
529 {
531 }
532#ifdef ENABLE_ASYNC_PUSH
533 else if (e->arg == MULTI_IO_FILE_CLOSE_WRITE)
534 {
535 multi_process_file_closed(m, MPP_PRE_SELECT | MPP_RECORD_TOUCH);
536 }
537#endif
538 }
539 if (IS_SIG(&m->top))
540 {
541 break;
542 }
543 }
544 multi_io->n_esr = 0;
545
546 /*
547 * Process queued mbuf packets destined for TCP socket
548 */
549 {
550 struct multi_instance *mi;
551 while (!IS_SIG(&m->top) && (mi = mbuf_peek(m->mbuf)) != NULL)
552 {
553 multi_io_action(m, mi, TA_SOCKET_WRITE, true);
554 }
555 }
556}
557
558void
559multi_io_action(struct multi_context *m, struct multi_instance *mi, int action, bool poll)
560{
561 bool tun_input_pending = false;
562
563 do
564 {
565 dmsg(D_MULTI_DEBUG, "MULTI IO: multi_io_action a=%s p=%d", pract(action), poll);
566
567 /*
568 * If TA_SOCKET_READ_RESIDUAL, it means we still have pending
569 * input packets which were read by a prior recv.
570 *
571 * Otherwise do a "lite" wait, which means we wait with 0 timeout
572 * on I/O events only related to the current instance, not
573 * the big list of events.
574 *
575 * On our first pass, poll will be false because we already know
576 * that input is available, and to call io_wait would be redundant.
577 */
578 if (poll && action != TA_SOCKET_READ_RESIDUAL)
579 {
580 const int orig_action = action;
581 action = multi_io_wait_lite(m, mi, action, &tun_input_pending);
582 if (action == TA_UNDEF)
583 {
584 msg(M_FATAL, "MULTI IO: I/O wait required blocking in multi_io_action, action=%d",
585 orig_action);
586 }
587 }
588
589 /*
590 * Dispatch the action
591 */
592 struct multi_instance *touched = multi_io_dispatch(m, mi, action);
593
594 /*
595 * Signal received or connection
596 * reset by peer?
597 */
598 if (touched && IS_SIG(&touched->context))
599 {
600 if (mi == touched)
601 {
602 mi = NULL;
603 }
605 }
606
607
608 /*
609 * If dispatch produced any pending output
610 * for a particular instance, point to
611 * that instance.
612 */
613 if (m->pending)
614 {
615 mi = m->pending;
616 }
617
618 /*
619 * Based on the effects of the action,
620 * such as generating pending output,
621 * possibly transition to a new action state.
622 */
623 action = multi_io_post(m, mi, action);
624
625 /*
626 * If we are finished processing the original action,
627 * check if we have any TUN input. If so, transition
628 * our action state to processing this input.
629 */
630 if (tun_input_pending && action == TA_UNDEF)
631 {
632 action = TA_TUN_READ;
633 mi = NULL;
634 tun_input_pending = false;
635 poll = false;
636 }
637 else
638 {
639 poll = true;
640 }
641
642 } while (action != TA_UNDEF);
643}
644
645void
647{
648 if (multi_io && multi_io->es)
649 {
650 event_del(multi_io->es, event);
651 }
652}
static void gc_free(struct gc_arena *a)
Definition buffer.h:1015
#define ALLOC_OBJ_CLEAR(dptr, type)
Definition buffer.h:1042
#define ALLOC_ARRAY(dptr, type, n)
Definition buffer.h:1048
static struct gc_arena gc_new(void)
Definition buffer.h:1007
unsigned long ptr_type
Definition common.h:57
#define ptr_format
Definition common.h:48
static void dco_event_set(dco_context_t *dco, struct event_set *es, void *arg)
Definition dco.h:318
#define D_MULTI_ERRORS
Definition errlevel.h:64
#define D_MULTI_DEBUG
Definition errlevel.h:126
#define D_MULTI_LOW
Definition errlevel.h:85
struct event_set * event_set_init(int *maxevents, unsigned int flags)
Definition event.c:1167
#define TUN_WRITE
Definition event.h:65
static void event_free(struct event_set *es)
Definition event.h:162
static void event_del(struct event_set *es, event_t event)
Definition event.h:177
#define SOCKET_READ
Definition event.h:61
static int event_wait(struct event_set *es, const struct timeval *tv, struct event_set_return *out, int outlen)
Definition event.h:189
#define SOCKET_WRITE
Definition event.h:62
#define EVENT_WRITE
Definition event.h:39
#define MULTI_N
Definition event.h:88
#define EVENT_READ
Definition event.h:38
#define TUN_READ
Definition event.h:64
static void wait_signal(struct event_set *es, void *arg)
Definition event.h:208
@ EVENT_ARG_LINK_SOCKET
Definition event.h:138
@ EVENT_ARG_MULTI_INSTANCE
Definition event.h:137
static void event_ctl(struct event_set *es, event_t event, unsigned int rwflags, void *arg)
Definition event.h:183
void get_io_flags_udp(struct context *c, struct multi_io *multi_io, const unsigned int flags)
Definition forward.c:2164
Interface functions to the internal and external multiplexers.
#define IOW_READ_TUN
Definition forward.h:56
static void io_wait(struct context *c, const unsigned int flags)
Definition forward.h:382
#define IOW_READ_LINK
Definition forward.h:57
#define LINK_OUT(c)
Definition forward.h:38
#define TUN_OUT(c)
Definition forward.h:37
#define IOW_TO_TUN
Definition forward.h:54
#define IOW_READ_TUN_FORCE
Definition forward.h:62
#define IOW_TO_LINK
Definition forward.h:55
bool multi_process_incoming_link(struct multi_context *m, struct multi_instance *instance, const unsigned int mpp_flags, struct link_socket *sock)
Demultiplex and process a packet received over the external network interface.
Definition multi.c:3352
void read_incoming_link(struct context *c, struct link_socket *sock)
Read a packet from the external network interface.
Definition forward.c:919
void read_incoming_tun(struct context *c)
Read a packet from the virtual tun/tap network interface.
Definition forward.c:1316
static bool multi_process_outgoing_tun(struct multi_context *m, const unsigned int mpp_flags)
Send a packet over the virtual tun/tap network interface to its locally reachable destination.
Definition multi.h:636
bool multi_process_incoming_tun(struct multi_context *m, const unsigned int mpp_flags)
Determine the destination VPN tunnel of a packet received over the virtual tun/tap network interface ...
Definition multi.c:3552
#define BASE_N_EVENTS
Definition init.h:32
static int min_int(int x, int y)
Definition integer.h:105
static int max_int(int x, int y)
Definition integer.h:92
static SERVICE_STATUS status
Definition interactive.c:51
void management_socket_set(struct management *man, struct event_set *es, void *arg, unsigned int *persistent)
Definition manage.c:3141
void management_io(struct management *man)
Definition manage.c:3179
static struct multi_instance * mbuf_peek(struct mbuf_set *ms)
Definition mbuf.h:99
static bool mbuf_defined(const struct mbuf_set *ms)
Definition mbuf.h:79
struct multi_instance * multi_create_instance_tcp(struct multi_context *m, struct link_socket *sock)
Definition mtcp.c:49
bool multi_tcp_process_outgoing_link(struct multi_context *m, bool defer, const unsigned int mpp_flags)
Definition mtcp.c:176
bool multi_tcp_process_outgoing_link_ready(struct multi_context *m, struct multi_instance *mi, const unsigned int mpp_flags)
Definition mtcp.c:151
unsigned int p2mp_iow_flags(const struct multi_context *m)
Definition mudp.c:437
void multi_process_io_udp(struct multi_context *m, struct link_socket *sock)
Definition mudp.c:339
void multi_close_instance_on_signal(struct multi_context *m, struct multi_instance *mi)
Definition multi.c:3212
bool multi_process_post(struct multi_context *m, struct multi_instance *mi, const unsigned int flags)
Perform postprocessing of a VPN tunnel instance.
Definition multi.c:3013
bool multi_process_timeout(struct multi_context *m, const unsigned int mpp_flags)
Definition multi.c:3680
const char * multi_instance_string(const struct multi_instance *mi, bool null, struct gc_arena *gc)
Definition multi.c:442
void multi_process_drop_outgoing_tun(struct multi_context *m, const unsigned int mpp_flags)
Definition multi.c:3712
Header file for server-mode related structures and functions.
bool multi_process_incoming_dco(struct multi_context *m)
Process an incoming DCO message (from kernel space).
static void set_prefix(struct multi_instance *mi)
Definition multi.h:521
static void clear_prefix(void)
Definition multi.h:533
#define MPP_RECORD_TOUCH
Definition multi.h:278
#define MPP_PRE_SELECT
Definition multi.h:275
#define MULTI_IO_SIG
Definition multi_io.c:44
void multi_io_process_io(struct multi_context *m)
Definition multi_io.c:423
static int multi_io_wait_lite(struct multi_context *m, struct multi_instance *mi, const int action, bool *tun_input_pending)
Definition multi_io.c:218
#define MULTI_IO_TUN
Definition multi_io.c:43
struct multi_io * multi_io_init(int maxevents, int *maxclients)
Definition multi_io.c:116
void multi_io_free(struct multi_io *multi_io)
Definition multi_io.c:158
#define MTP_NONE
#define MTP_TUN_OUT
#define MULTI_IO_DCO
Definition multi_io.c:47
#define MTP_LINK_OUT
void multi_io_set_global_rw_flags(struct multi_context *m, struct multi_instance *mi)
Definition multi_io.c:136
int multi_io_wait(struct multi_context *m)
Definition multi_io.c:169
#define MULTI_IO_FILE_CLOSE_WRITE
Definition multi_io.c:46
static struct multi_instance * multi_io_dispatch(struct multi_context *m, struct multi_instance *mi, const int action)
Definition multi_io.c:289
void multi_io_delete_event(struct multi_io *multi_io, event_t event)
Definition multi_io.c:646
static struct context * multi_get_context(struct multi_context *m, struct multi_instance *mi)
Definition multi_io.c:103
static int multi_io_post(struct multi_context *m, struct multi_instance *mi, const int action)
Definition multi_io.c:366
void multi_io_action(struct multi_context *m, struct multi_instance *mi, int action, bool poll)
Definition multi_io.c:559
#define MULTI_IO_MANAGEMENT
Definition multi_io.c:45
#define MULTI_IO_SOCKET
Definition multi_io.c:42
#define TA_UNDEF
Definition multi_io.h:36
#define TA_SOCKET_WRITE_READY
Definition multi_io.h:40
#define TA_SOCKET_READ_RESIDUAL
Definition multi_io.h:38
#define TA_SOCKET_READ
Definition multi_io.h:37
#define TA_INITIAL
Definition multi_io.h:44
#define TA_TUN_WRITE
Definition multi_io.h:43
#define TA_TIMEOUT
Definition multi_io.h:45
#define TA_SOCKET_WRITE_DEFERRED
Definition multi_io.h:41
#define TA_TUN_WRITE_TIMEOUT
Definition multi_io.h:46
#define TA_TUN_READ
Definition multi_io.h:42
#define TA_SOCKET_WRITE
Definition multi_io.h:39
#define M_FATAL
Definition error.h:88
#define dmsg(flags,...)
Definition error.h:170
#define msg(flags,...)
Definition error.h:150
#define ASSERT(x)
Definition error.h:217
bool has_udp_in_local_list(const struct options *options)
Definition options.c:9911
static void update_time(void)
Definition otime.h:76
static void tv_clear(struct timeval *tv)
Definition otime.h:100
static void perf_push(int type)
Definition perf.h:77
#define PERF_PROC_OUT_TUN_MTCP
Definition perf.h:56
static void perf_pop(void)
Definition perf.h:81
#define IS_SIG(c)
Definition sig.h:47
static void get_signal(volatile int *sig)
Copy the global signal_received (if non-zero) to the passed-in argument sig.
Definition sig.h:109
unsigned int socket_set(struct link_socket *s, struct event_set *es, unsigned int rwflags, void *arg, unsigned int *persistent)
Definition socket.c:2934
bool sockets_read_residual(const struct context *c)
Definition socket.c:45
static void socket_set_listen_persistent(struct link_socket *sock, struct event_set *es, void *arg)
Definition socket.h:753
static bool stream_buf_read_setup(struct link_socket *sock)
Definition socket.h:504
static void socket_reset_listen_persistent(struct link_socket *sock)
Definition socket.h:763
static bool proto_is_dgram(int proto)
Return if the protocol is datagram (UDP)
int link_sockets_num
Definition openvpn.h:158
struct tuntap * tuntap
Tun/tap virtual network interface.
Definition openvpn.h:172
unsigned int event_set_status
Definition openvpn.h:235
struct link_socket ** link_sockets
Definition openvpn.h:237
struct timeval timeval
Time to next event of timers and similar.
Definition openvpn.h:396
Contains all state information for one tunnel.
Definition openvpn.h:474
struct signal_info * sig
Internal error signaling object.
Definition openvpn.h:503
struct context_2 c2
Level 2 context.
Definition openvpn.h:517
struct options options
Options loaded from command line or configuration file.
Definition openvpn.h:475
struct context_1 c1
Level 1 context.
Definition openvpn.h:516
struct link_socket * sock
Definition event.h:148
struct multi_instance * mi
Definition event.h:147
union event_arg::@1 u
event_arg_t type
Definition event.h:144
unsigned int rwflags
Definition event.h:126
Garbage collection arena used to keep track of dynamically allocated memory.
Definition buffer.h:116
Main OpenVPN server state structure.
Definition multi.h:164
struct mbuf_set * mbuf
Set of buffers for passing data channel packets between VPN tunnel instances.
Definition multi.h:176
struct multi_io * multi_io
I/O state and events tracker.
Definition multi.h:179
struct context top
Storage structure for process-wide configuration.
Definition multi.h:203
struct multi_instance * pending
Definition multi.h:197
struct multi_instance ** mpp_touched
Definition multi.h:199
Server-mode state structure for one single VPN tunnel.
Definition multi.h:103
struct mbuf_set * tcp_link_out_deferred
Definition multi.h:129
unsigned int tcp_rwflags
Definition multi.h:128
bool socket_set_called
Definition multi.h:130
struct event_arg ev_arg
this struct will store a pointer to either mi or link_socket, depending on the event type,...
Definition multi.h:108
struct context context
The context structure storing state for this VPN tunnel.
Definition multi.h:144
struct event_set * es
Definition multi_io.h:53
int n_esr
Definition multi_io.h:55
struct event_set_return * esr
Definition multi_io.h:54
unsigned int tun_rwflags
Definition multi_io.h:57
int maxevents
Definition multi_io.h:56
unsigned int management_persist_flags
Definition multi_io.h:60
volatile int signal_received
Definition sig.h:42
unsigned int flags
Definition mtcp.c:42
unsigned int ret
Definition mtcp.c:43
unsigned int tun
Definition mtcp.c:44
unsigned int sock
Definition mtcp.c:45
dco_context_t dco
Definition tun.h:249
struct gc_arena gc
Definition test_ssl.c:154
static bool tuntap_is_dco_win(struct tuntap *tt)
Definition tun.h:532
static void tun_set(struct tuntap *tt, struct event_set *es, unsigned int rwflags, void *arg, unsigned int *persistent)
Definition tun.h:598