diff options
-rw-r--r-- | src/openvpn/forward.c | 9 | ||||
-rw-r--r-- | src/openvpn/tun.h | 19 |
2 files changed, 28 insertions, 0 deletions
diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c index 39f66e3..27b775f 100644 --- a/src/openvpn/forward.c +++ b/src/openvpn/forward.c @@ -948,6 +948,15 @@ read_incoming_tun (struct context *c) return; } + /* Was TUN/TAP I/O operation aborted? */ + if (tuntap_abort(c->c2.buf.len)) + { + register_signal(c, SIGTERM, "tun-abort"); + msg(M_FATAL, "TUN/TAP I/O operation aborted, exiting"); + perf_pop(); + return; + } + /* Check the status return from read() */ check_status (c->c2.buf.len, "read from TUN/TAP", NULL, c->c1.tuntap); diff --git a/src/openvpn/tun.h b/src/openvpn/tun.h index 631b53c..79e2d18 100644 --- a/src/openvpn/tun.h +++ b/src/openvpn/tun.h @@ -391,6 +391,19 @@ tuntap_stop (int status) return false; } +static inline bool +tuntap_abort(int status) +{ + /* + * Typically generated when driver is halted. + */ + if (status < 0) + { + return openvpn_errno() == ERROR_OPERATION_ABORTED; + } + return false; +} + static inline int tun_write_win32 (struct tuntap *tt, struct buffer *buf) { @@ -432,6 +445,12 @@ tuntap_stop (int status) return false; } +static inline bool +tuntap_abort(int status) +{ + return false; +} + static inline void tun_standby_init (struct tuntap *tt) { |