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-2023 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, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 */
23
24#ifdef HAVE_CONFIG_H
25#include "config.h"
26#endif
27
28#include "syshead.h"
29
30#include "memdbg.h"
31
32#include "multi.h"
33#include "forward.h"
34#include "multi_io.h"
35
36#ifdef HAVE_SYS_INOTIFY_H
37#include <sys/inotify.h>
38#endif
39
40/*
41 * Special tags passed to event.[ch] functions
42 */
43#define MULTI_IO_SOCKET ((void *)1)
44#define MULTI_IO_TUN ((void *)2)
45#define MULTI_IO_SIG ((void *)3) /* Only on Windows */
46#define MULTI_IO_MANAGEMENT ((void *)4)
47#define MULTI_IO_FILE_CLOSE_WRITE ((void *)5)
48#define MULTI_IO_DCO ((void *)6)
49
50struct ta_iow_flags
51{
52 unsigned int flags;
53 unsigned int ret;
54 unsigned int tun;
55 unsigned int sock;
56};
57
58#ifdef ENABLE_DEBUG
59static const char *
60pract(int action)
61{
62 switch (action)
63 {
64 case TA_UNDEF:
65 return "TA_UNDEF";
66
67 case TA_SOCKET_READ:
68 return "TA_SOCKET_READ";
69
71 return "TA_SOCKET_READ_RESIDUAL";
72
73 case TA_SOCKET_WRITE:
74 return "TA_SOCKET_WRITE";
75
77 return "TA_SOCKET_WRITE_READY";
78
80 return "TA_SOCKET_WRITE_DEFERRED";
81
82 case TA_TUN_READ:
83 return "TA_TUN_READ";
84
85 case TA_TUN_WRITE:
86 return "TA_TUN_WRITE";
87
88 case TA_INITIAL:
89 return "TA_INITIAL";
90
91 case TA_TIMEOUT:
92 return "TA_TIMEOUT";
93
95 return "TA_TUN_WRITE_TIMEOUT";
96
97 default:
98 return "?";
99 }
100}
101#endif /* ENABLE_DEBUG */
102
103static inline struct context *
105{
106 if (mi)
107 {
108 return &mi->context;
109 }
110 else
111 {
112 return &m->top;
113 }
114}
115
116struct multi_io *
117multi_io_init(int maxevents, int *maxclients)
118{
119 struct multi_io *multi_io;
120 const int extra_events = BASE_N_EVENTS;
121
122 ASSERT(maxevents >= 1);
123 ASSERT(maxclients);
124
126 multi_io->maxevents = maxevents + extra_events;
130 *maxclients = max_int(min_int(multi_io->maxevents - extra_events, *maxclients), 1);
131 msg(D_MULTI_LOW, "MULTI IO: MULTI_IO INIT maxclients=%d maxevents=%d", *maxclients, multi_io->maxevents);
132 return multi_io;
133}
134
135void
137{
138 if (!mi)
139 {
140 return;
141 }
142
143 mi->socket_set_called = true;
145 {
147 m->multi_io->es,
149 &mi->context.c2.link_sockets[0]->ev_arg,
150 NULL);
151 }
152 else
153 {
155 m->multi_io->es,
157 &mi->ev_arg,
158 &mi->tcp_rwflags);
159 }
160}
161
162void
164{
165 if (multi_io)
166 {
168 free(multi_io->esr);
169 free(multi_io);
170 }
171}
172
173int
175{
176 int status, i;
177 unsigned int *persistent = &m->multi_io->tun_rwflags;
178
179 for (i = 0; i < m->top.c1.link_sockets_num; i++)
180 {
182 &m->top.c2.link_sockets[i]->ev_arg);
183 }
184
186 {
188 }
189
190#ifdef _WIN32
192 {
194 {
195 /* there is data in wintun ring buffer, read it immediately */
196 m->multi_io->esr[0].arg = MULTI_IO_TUN;
198 m->multi_io->n_esr = 1;
199 return 1;
200 }
201 persistent = NULL;
202 }
203#endif
204 tun_set(m->top.c1.tuntap, m->multi_io->es, EVENT_READ, MULTI_IO_TUN, persistent);
205#if defined(TARGET_LINUX) || defined(TARGET_FREEBSD)
207#endif
208
209#ifdef ENABLE_MANAGEMENT
210 if (management)
211 {
213 }
214#endif
215
216#ifdef ENABLE_ASYNC_PUSH
217 /* arm inotify watcher */
219#endif
220
222 update_time();
223 m->multi_io->n_esr = 0;
224 if (status > 0)
225 {
226 m->multi_io->n_esr = status;
227 }
228 return status;
229}
230
231static int
232multi_io_wait_lite(struct multi_context *m, struct multi_instance *mi, const int action, bool *tun_input_pending)
233{
234 struct context *c = multi_get_context(m, mi);
235 unsigned int looking_for = 0;
236
237 dmsg(D_MULTI_DEBUG, "MULTI IO: multi_io_wait_lite a=%s mi=" ptr_format,
238 pract(action),
239 (ptr_type)mi);
240
241 tv_clear(&c->c2.timeval); /* ZERO-TIMEOUT */
242
243 switch (action)
244 {
245 case TA_TUN_READ:
246 looking_for = TUN_READ;
247 tun_input_pending = NULL;
249 break;
250
251 case TA_SOCKET_READ:
252 looking_for = SOCKET_READ;
253 tun_input_pending = NULL;
255 break;
256
257 case TA_TUN_WRITE:
258 looking_for = TUN_WRITE;
259 tun_input_pending = NULL;
260 c->c2.timeval.tv_sec = 1; /* For some reason, the Linux 2.2 TUN/TAP driver hits this timeout */
263 perf_pop();
264 break;
265
266 case TA_SOCKET_WRITE:
267 looking_for = SOCKET_WRITE;
269 break;
270
271 default:
272 msg(M_FATAL, "MULTI IO: multi_io_wait_lite, unhandled action=%d", action);
273 }
274
275 if (tun_input_pending && (c->c2.event_set_status & TUN_READ))
276 {
277 *tun_input_pending = true;
278 }
279
280 if (c->c2.event_set_status & looking_for)
281 {
282 return action;
283 }
284 else
285 {
286 switch (action)
287 {
288 /* MULTI PROTOCOL socket output buffer is full */
289 case TA_SOCKET_WRITE:
291
292 /* TUN device timed out on accepting write */
293 case TA_TUN_WRITE:
295 }
296
297 return TA_UNDEF;
298 }
299}
300
301static struct multi_instance *
302multi_io_dispatch(struct multi_context *m, struct multi_instance *mi, const int action)
303{
304 const unsigned int mpp_flags = MPP_PRE_SELECT|MPP_RECORD_TOUCH;
305 struct multi_instance *touched = mi;
306 m->mpp_touched = &touched;
307
308 dmsg(D_MULTI_DEBUG, "MULTI IO: multi_io_dispatch a=%s mi=" ptr_format,
309 pract(action),
310 (ptr_type)mi);
311
312 switch (action)
313 {
314 case TA_TUN_READ:
316 if (!IS_SIG(&m->top))
317 {
318 multi_process_incoming_tun(m, mpp_flags);
319 }
320 break;
321
322 case TA_SOCKET_READ:
324 ASSERT(mi);
327 set_prefix(mi);
329 clear_prefix();
330 if (!IS_SIG(&mi->context))
331 {
332 multi_process_incoming_link(m, mi, mpp_flags,
333 mi->context.c2.link_sockets[0]);
334 if (!IS_SIG(&mi->context))
335 {
337 }
338 }
339 break;
340
341 case TA_TIMEOUT:
342 multi_process_timeout(m, mpp_flags);
343 break;
344
345 case TA_TUN_WRITE:
346 multi_process_outgoing_tun(m, mpp_flags);
347 break;
348
351 break;
352
354 ASSERT(mi);
356 break;
357
358 case TA_SOCKET_WRITE:
359 multi_tcp_process_outgoing_link(m, false, mpp_flags);
360 break;
361
363 multi_tcp_process_outgoing_link(m, true, mpp_flags);
364 break;
365
366 case TA_INITIAL:
367 ASSERT(mi);
369 multi_process_post(m, mi, mpp_flags);
370 break;
371
372 default:
373 msg(M_FATAL, "MULTI IO: multi_io_dispatch, unhandled action=%d", action);
374 }
375
376 m->mpp_touched = NULL;
377 return touched;
378}
379
380static int
381multi_io_post(struct multi_context *m, struct multi_instance *mi, const int action)
382{
383 struct context *c = multi_get_context(m, mi);
384 int newaction = TA_UNDEF;
385
386#define MTP_NONE 0
387#define MTP_TUN_OUT (1<<0)
388#define MTP_LINK_OUT (1<<1)
389 unsigned int flags = MTP_NONE;
390
391 if (TUN_OUT(c))
392 {
393 flags |= MTP_TUN_OUT;
394 }
395 if (LINK_OUT(c))
396 {
397 flags |= MTP_LINK_OUT;
398 }
399
400 switch (flags)
401 {
403 case MTP_TUN_OUT:
404 newaction = TA_TUN_WRITE;
405 break;
406
407 case MTP_LINK_OUT:
408 newaction = TA_SOCKET_WRITE;
409 break;
410
411 case MTP_NONE:
412 if (mi && sockets_read_residual(c))
413 {
414 newaction = TA_SOCKET_READ_RESIDUAL;
415 }
416 else
417 {
419 }
420 break;
421
422 default:
423 {
424 struct gc_arena gc = gc_new();
425 msg(M_FATAL, "MULTI IO: multi_io_post bad state, mi=%s flags=%d",
426 multi_instance_string(mi, false, &gc),
427 flags);
428 gc_free(&gc);
429 break;
430 }
431 }
432
433 dmsg(D_MULTI_DEBUG, "MULTI IO: multi_io_post %s -> %s",
434 pract(action),
435 pract(newaction));
436
437 return newaction;
438}
439
440void
442{
443 struct multi_io *multi_io = m->multi_io;
444 int i;
445
446 for (i = 0; i < multi_io->n_esr; ++i)
447 {
448 struct event_set_return *e = &multi_io->esr[i];
449 struct event_arg *ev_arg = (struct event_arg *)e->arg;
450
451 /* incoming data for instance or listening socket? */
452 if (e->arg >= MULTI_N)
453 {
454 switch (ev_arg->type)
455 {
456 struct multi_instance *mi;
457
458 /* react to event on child instance */
460 if (!ev_arg->u.mi)
461 {
462 msg(D_MULTI_ERRORS, "MULTI IO: multi_io_proc_io: null minstance");
463 break;
464 }
465
466 mi = ev_arg->u.mi;
467 if (e->rwflags & EVENT_WRITE)
468 {
470 }
471 else if (e->rwflags & EVENT_READ)
472 {
473 multi_io_action(m, mi, TA_SOCKET_READ, false);
474 }
475 break;
476
478 if (!ev_arg->u.sock)
479 {
480 msg(D_MULTI_ERRORS, "MULTI IO: multi_io_proc_io: null socket");
481 break;
482 }
483 /* new incoming TCP client attempting to connect? */
485 {
488 }
489 else
490 {
492 mi = m->pending;
493 }
494 /* monitor and/or handle events that are
495 * triggered in succession by the first one
496 * before returning to the main loop. */
497 if (mi)
498 {
499 multi_io_action(m, mi, TA_INITIAL, false);
500 }
501 break;
502 }
503 }
504 else
505 {
506#ifdef ENABLE_MANAGEMENT
507 if (e->arg == MULTI_IO_MANAGEMENT)
508 {
511 }
512 else
513#endif
514 /* incoming data on TUN? */
515 if (e->arg == MULTI_IO_TUN)
516 {
517 if (e->rwflags & EVENT_WRITE)
518 {
519 multi_io_action(m, NULL, TA_TUN_WRITE, false);
520 }
521 else if (e->rwflags & EVENT_READ)
522 {
523 multi_io_action(m, NULL, TA_TUN_READ, false);
524 }
525 }
526 /* new incoming TCP client attempting to connect? */
527 else if (e->arg == MULTI_IO_SOCKET)
528 {
529 struct multi_instance *mi;
530 ASSERT(m->top.c2.link_sockets[0]);
533 if (mi)
534 {
535 multi_io_action(m, mi, TA_INITIAL, false);
536 }
537 }
538#if defined(ENABLE_DCO) && (defined(TARGET_LINUX) || defined(TARGET_FREEBSD))
539 /* incoming data on DCO? */
540 else if (e->arg == MULTI_IO_DCO)
541 {
543 }
544#endif
545 /* signal received? */
546 else if (e->arg == MULTI_IO_SIG)
547 {
549 }
550#ifdef ENABLE_ASYNC_PUSH
551 else if (e->arg == MULTI_IO_FILE_CLOSE_WRITE)
552 {
553 multi_process_file_closed(m, MPP_PRE_SELECT | MPP_RECORD_TOUCH);
554 }
555#endif
556 }
557 if (IS_SIG(&m->top))
558 {
559 break;
560 }
561 }
562 multi_io->n_esr = 0;
563
564 /*
565 * Process queued mbuf packets destined for TCP socket
566 */
567 {
568 struct multi_instance *mi;
569 while (!IS_SIG(&m->top) && (mi = mbuf_peek(m->mbuf)) != NULL)
570 {
571 multi_io_action(m, mi, TA_SOCKET_WRITE, true);
572 }
573 }
574}
575
576void
577multi_io_action(struct multi_context *m, struct multi_instance *mi, int action, bool poll)
578{
579 bool tun_input_pending = false;
580
581 do
582 {
583 dmsg(D_MULTI_DEBUG, "MULTI IO: multi_io_action a=%s p=%d",
584 pract(action),
585 poll);
586
587 /*
588 * If TA_SOCKET_READ_RESIDUAL, it means we still have pending
589 * input packets which were read by a prior recv.
590 *
591 * Otherwise do a "lite" wait, which means we wait with 0 timeout
592 * on I/O events only related to the current instance, not
593 * the big list of events.
594 *
595 * On our first pass, poll will be false because we already know
596 * that input is available, and to call io_wait would be redundant.
597 */
598 if (poll && action != TA_SOCKET_READ_RESIDUAL)
599 {
600 const int orig_action = action;
601 action = multi_io_wait_lite(m, mi, action, &tun_input_pending);
602 if (action == TA_UNDEF)
603 {
604 msg(M_FATAL, "MULTI IO: I/O wait required blocking in multi_io_action, action=%d", orig_action);
605 }
606 }
607
608 /*
609 * Dispatch the action
610 */
611 struct multi_instance *touched = multi_io_dispatch(m, mi, action);
612
613 /*
614 * Signal received or connection
615 * reset by peer?
616 */
617 if (touched && IS_SIG(&touched->context))
618 {
619 if (mi == touched)
620 {
621 mi = NULL;
622 }
624 }
625
626
627 /*
628 * If dispatch produced any pending output
629 * for a particular instance, point to
630 * that instance.
631 */
632 if (m->pending)
633 {
634 mi = m->pending;
635 }
636
637 /*
638 * Based on the effects of the action,
639 * such as generating pending output,
640 * possibly transition to a new action state.
641 */
642 action = multi_io_post(m, mi, action);
643
644 /*
645 * If we are finished processing the original action,
646 * check if we have any TUN input. If so, transition
647 * our action state to processing this input.
648 */
649 if (tun_input_pending && action == TA_UNDEF)
650 {
651 action = TA_TUN_READ;
652 mi = NULL;
653 tun_input_pending = false;
654 poll = false;
655 }
656 else
657 {
658 poll = true;
659 }
660
661 } while (action != TA_UNDEF);
662}
663
664void
666{
667 if (multi_io && multi_io->es)
668 {
669 event_del(multi_io->es, event);
670 }
671}
static void gc_free(struct gc_arena *a)
Definition buffer.h:1033
#define ALLOC_OBJ_CLEAR(dptr, type)
Definition buffer.h:1060
#define ALLOC_ARRAY(dptr, type, n)
Definition buffer.h:1066
static struct gc_arena gc_new(void)
Definition buffer.h:1025
unsigned long ptr_type
Definition common.h:58
#define ptr_format
Definition common.h:49
static void dco_event_set(dco_context_t *dco, struct event_set *es, void *arg)
Definition dco.h:324
#define D_MULTI_ERRORS
Definition errlevel.h:65
#define D_MULTI_DEBUG
Definition errlevel.h:127
#define D_MULTI_LOW
Definition errlevel.h:86
struct event_set * event_set_init(int *maxevents, unsigned int flags)
Definition event.c:1186
#define TUN_WRITE
Definition event.h:66
static void event_free(struct event_set *es)
Definition event.h:160
static void event_del(struct event_set *es, event_t event)
Definition event.h:175
#define SOCKET_READ
Definition event.h:62
static int event_wait(struct event_set *es, const struct timeval *tv, struct event_set_return *out, int outlen)
Definition event.h:187
#define SOCKET_WRITE
Definition event.h:63
#define EVENT_WRITE
Definition event.h:40
#define MULTI_N
Definition event.h:89
#define EVENT_READ
Definition event.h:39
#define TUN_READ
Definition event.h:65
static void wait_signal(struct event_set *es, void *arg)
Definition event.h:206
@ EVENT_ARG_LINK_SOCKET
Definition event.h:137
@ EVENT_ARG_MULTI_INSTANCE
Definition event.h:136
static void event_ctl(struct event_set *es, event_t event, unsigned int rwflags, void *arg)
Definition event.h:181
void get_io_flags_udp(struct context *c, struct multi_io *multi_io, const unsigned int flags)
Definition forward.c:2201
Interface functions to the internal and external multiplexers.
#define IOW_READ_TUN
Definition forward.h:57
static void io_wait(struct context *c, const unsigned int flags)
Definition forward.h:377
#define IOW_READ_LINK
Definition forward.h:58
#define LINK_OUT(c)
Definition forward.h:39
#define TUN_OUT(c)
Definition forward.h:38
#define IOW_TO_TUN
Definition forward.h:55
#define IOW_READ_TUN_FORCE
Definition forward.h:63
#define IOW_TO_LINK
Definition forward.h:56
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:934
void read_incoming_tun(struct context *c)
Read a packet from the virtual tun/tap network interface.
Definition forward.c:1299
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:659
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:3556
#define BASE_N_EVENTS
Definition init.h:33
static int min_int(int x, int y)
Definition integer.h:102
static int max_int(int x, int y)
Definition integer.h:89
static SERVICE_STATUS status
Definition interactive.c:53
void management_socket_set(struct management *man, struct event_set *es, void *arg, unsigned int *persistent)
Definition manage.c:3127
void management_io(struct management *man)
Definition manage.c:3167
static struct multi_instance * mbuf_peek(struct mbuf_set *ms)
Definition mbuf.h:100
static bool mbuf_defined(const struct mbuf_set *ms)
Definition mbuf.h:80
struct multi_instance * multi_create_instance_tcp(struct multi_context *m, struct link_socket *sock)
Definition mtcp.c:50
bool multi_tcp_process_outgoing_link(struct multi_context *m, bool defer, const unsigned int mpp_flags)
Definition mtcp.c:177
bool multi_tcp_process_outgoing_link_ready(struct multi_context *m, struct multi_instance *mi, const unsigned int mpp_flags)
Definition mtcp.c:153
unsigned int p2mp_iow_flags(const struct multi_context *m)
Definition mudp.c:434
void multi_process_io_udp(struct multi_context *m, struct link_socket *sock)
Definition mudp.c:335
void multi_close_instance_on_signal(struct multi_context *m, struct multi_instance *mi)
Definition multi.c:3223
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:3048
bool multi_process_timeout(struct multi_context *m, const unsigned int mpp_flags)
Definition multi.c:3685
const char * multi_instance_string(const struct multi_instance *mi, bool null, struct gc_arena *gc)
Definition multi.c:464
void multi_process_drop_outgoing_tun(struct multi_context *m, const unsigned int mpp_flags)
Definition multi.c:3716
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:544
static void clear_prefix(void)
Definition multi.h:556
#define MPP_RECORD_TOUCH
Definition multi.h:295
#define MPP_PRE_SELECT
Definition multi.h:292
#define MULTI_IO_SIG
Definition multi_io.c:45
void multi_io_process_io(struct multi_context *m)
Definition multi_io.c:441
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:232
#define MULTI_IO_TUN
Definition multi_io.c:44
struct multi_io * multi_io_init(int maxevents, int *maxclients)
Definition multi_io.c:117
void multi_io_free(struct multi_io *multi_io)
Definition multi_io.c:163
#define MTP_NONE
#define MTP_TUN_OUT
#define MULTI_IO_DCO
Definition multi_io.c:48
#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:174
#define MULTI_IO_FILE_CLOSE_WRITE
Definition multi_io.c:47
static struct multi_instance * multi_io_dispatch(struct multi_context *m, struct multi_instance *mi, const int action)
Definition multi_io.c:302
void multi_io_delete_event(struct multi_io *multi_io, event_t event)
Definition multi_io.c:665
static struct context * multi_get_context(struct multi_context *m, struct multi_instance *mi)
Definition multi_io.c:104
static int multi_io_post(struct multi_context *m, struct multi_instance *mi, const int action)
Definition multi_io.c:381
void multi_io_action(struct multi_context *m, struct multi_instance *mi, int action, bool poll)
Definition multi_io.c:577
#define MULTI_IO_MANAGEMENT
Definition multi_io.c:46
#define MULTI_IO_SOCKET
Definition multi_io.c:43
#define TA_UNDEF
Definition multi_io.h:37
#define TA_SOCKET_WRITE_READY
Definition multi_io.h:41
#define TA_SOCKET_READ_RESIDUAL
Definition multi_io.h:39
#define TA_SOCKET_READ
Definition multi_io.h:38
#define TA_INITIAL
Definition multi_io.h:45
#define TA_TUN_WRITE
Definition multi_io.h:44
#define TA_TIMEOUT
Definition multi_io.h:46
#define TA_SOCKET_WRITE_DEFERRED
Definition multi_io.h:42
#define TA_TUN_WRITE_TIMEOUT
Definition multi_io.h:47
#define TA_TUN_READ
Definition multi_io.h:43
#define TA_SOCKET_WRITE
Definition multi_io.h:40
#define M_FATAL
Definition error.h:89
#define dmsg(flags,...)
Definition error.h:148
#define msg(flags,...)
Definition error.h:144
#define ASSERT(x)
Definition error.h:195
bool has_udp_in_local_list(const struct options *options)
Definition options.c:9671
static void update_time(void)
Definition otime.h:77
static void tv_clear(struct timeval *tv)
Definition otime.h:101
static void perf_push(int type)
Definition perf.h:78
#define PERF_PROC_OUT_TUN_MTCP
Definition perf.h:57
static void perf_pop(void)
Definition perf.h:82
#define IS_SIG(c)
Definition sig.h:48
static void get_signal(volatile int *sig)
Copy the global signal_received (if non-zero) to the passed-in argument sig.
Definition sig.h:110
unsigned int socket_set(struct link_socket *s, struct event_set *es, unsigned int rwflags, void *arg, unsigned int *persistent)
Definition socket.c:4000
bool sockets_read_residual(const struct context *c)
Definition socket.c:46
static void socket_set_listen_persistent(struct link_socket *sock, struct event_set *es, void *arg)
Definition socket.h:1278
static bool stream_buf_read_setup(struct link_socket *sock)
Definition socket.h:1009
static void socket_reset_listen_persistent(struct link_socket *sock)
Definition socket.h:1290
static bool proto_is_dgram(int proto)
Return if the protocol is datagram (UDP)
Definition socket.h:597
int link_sockets_num
Definition openvpn.h:157
struct tuntap * tuntap
Tun/tap virtual network interface.
Definition openvpn.h:171
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:500
struct context_2 c2
Level 2 context.
Definition openvpn.h:514
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:513
struct link_socket * sock
Definition event.h:146
struct multi_instance * mi
Definition event.h:145
union event_arg::@1 u
event_arg_t type
Definition event.h:143
unsigned int rwflags
Definition event.h:126
Garbage collection arena used to keep track of dynamically allocated memory.
Definition buffer.h:117
Main OpenVPN server state structure.
Definition multi.h:163
struct mbuf_set * mbuf
Set of buffers for passing data channel packets between VPN tunnel instances.
Definition multi.h:175
struct multi_io * multi_io
I/O state and events tracker.
Definition multi.h:178
struct context top
Storage structure for process-wide configuration.
Definition multi.h:202
struct multi_instance * pending
Definition multi.h:196
struct multi_instance ** mpp_touched
Definition multi.h:198
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:54
int n_esr
Definition multi_io.h:56
struct event_set_return * esr
Definition multi_io.h:55
unsigned int tun_rwflags
Definition multi_io.h:58
int maxevents
Definition multi_io.h:57
unsigned int management_persist_flags
Definition multi_io.h:61
volatile int signal_received
Definition sig.h:43
unsigned int flags
Definition mtcp.c:43
unsigned int ret
Definition mtcp.c:44
unsigned int tun
Definition mtcp.c:45
unsigned int sock
Definition mtcp.c:46
dco_context_t dco
Definition tun.h:249
struct gc_arena gc
Definition test_ssl.c:155
static bool tuntap_is_wintun(struct tuntap *tt)
Definition tun.h:265
static bool tuntap_ring_empty(struct tuntap *tt)
Definition tun.h:271
static void tun_set(struct tuntap *tt, struct event_set *es, unsigned int rwflags, void *arg, unsigned int *persistent)
Definition tun.h:748