|
47 | 47 | #include "mstats.h"
|
48 | 48 |
|
49 | 49 | #include <sys/select.h>
|
| 50 | +#include <sys/socket.h> |
50 | 51 | #include <sys/time.h>
|
| 52 | +#include <pthread.h> |
51 | 53 |
|
52 | 54 | counter_type link_read_bytes_global; /* GLOBAL */
|
53 | 55 | counter_type link_write_bytes_global; /* GLOBAL */
|
@@ -2513,8 +2515,24 @@ io_wait_dowork(struct context *c, const unsigned int flags)
|
2513 | 2515 | dmsg(D_EVENT_WAIT, "I/O WAIT status=0x%04x", c->c2.event_set_status);
|
2514 | 2516 | }
|
2515 | 2517 |
|
| 2518 | +void threaded_fwd_in_tun(struct context *c, struct link_socket *sock, struct thread_pointer *b) |
| 2519 | +{ |
| 2520 | + if (b->p->h == b->p->n) |
| 2521 | + { |
| 2522 | + int size; |
| 2523 | + uint8_t temp[1]; |
| 2524 | + size = read(c->c1.tuntap->fd, temp, 1); |
| 2525 | + if (size < 1) { /* no-op */ } |
| 2526 | + if (!IS_SIG(c)) |
| 2527 | + { |
| 2528 | + process_incoming_tun(c, sock); |
| 2529 | + } |
| 2530 | + size = write(c->c1.tuntap->fz, temp, 1); |
| 2531 | + } |
| 2532 | +} |
| 2533 | + |
2516 | 2534 | void
|
2517 |
| -process_io(struct context *c, struct link_socket *sock) |
| 2535 | +process_io(struct context *c, struct link_socket *sock, struct thread_pointer *b) |
2518 | 2536 | {
|
2519 | 2537 | const unsigned int status = c->c2.event_set_status;
|
2520 | 2538 |
|
@@ -2548,11 +2566,7 @@ process_io(struct context *c, struct link_socket *sock)
|
2548 | 2566 | /* Incoming data on TUN device */
|
2549 | 2567 | else if (status & TUN_READ)
|
2550 | 2568 | {
|
2551 |
| - read_incoming_tun(c); |
2552 |
| - if (!IS_SIG(c)) |
2553 |
| - { |
2554 |
| - process_incoming_tun(c, sock); |
2555 |
| - } |
| 2569 | + threaded_fwd_in_tun(c, sock, b); |
2556 | 2570 | }
|
2557 | 2571 | else if (status & DCO_READ)
|
2558 | 2572 | {
|
|
0 commit comments