Forward-port tinc 1.0's handling of device errors.
authorGuus Sliepen <guus@tinc-vpn.org>
Thu, 27 Jul 2017 08:06:13 +0000 (10:06 +0200)
committerGuus Sliepen <guus@tinc-vpn.org>
Thu, 27 Jul 2017 08:06:42 +0000 (10:06 +0200)
src/net_packet.c

index 71f02a1..ed04a85 100644 (file)
@@ -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();
+               }
        }
 }