From e4544dbc6989e4a146c19519924e52c116bfc343 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Thu, 27 Jul 2017 10:06:13 +0200 Subject: [PATCH] Forward-port tinc 1.0's handling of device errors. --- src/net_packet.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/net_packet.c b/src/net_packet.c index 71f02a1e..ed04a85d 100644 --- a/src/net_packet.c +++ b/src/net_packet.c @@ -1573,10 +1573,19 @@ void handle_device_data(void *data, int flags) { vpn_packet_t packet; packet.offset = DEFAULT_PACKET_OFFSET; packet.priority = 0; + static int errors = 0; if(devops.read(&packet)) { + errors = 0; myself->in_packets++; myself->in_bytes += packet.len; route(myself, &packet); + } else { + usleep(errors * 50000); + errors++; + if(errors > 10) { + logger(DEBUG_ALWAYS, LOG_ERR, "Too many errors from %s, exiting!", device); + event_exit(); + } } } -- 2.20.1