Quit when there are too many consecutive errors on the tun/tap device.
Although transient errors sometimes happen on the tun/tap device (for example, if the kernel is temporarily out of buffer space), there are situations where the tun/tap device becomes permanently broken. Instead of endlessly spamming the syslog, we now sleep an increasing amount of time between consecutive read errors, and if reads still fail after 10 attempts (approximately 3 seconds), tinc will quit.
This commit is contained in:
parent
aca70cd3c3
commit
a91bf2dfcd
1 changed files with 9 additions and 0 deletions
|
@ -280,12 +280,21 @@ static void check_network_activity(fd_set * readset, fd_set * writeset) {
|
|||
int result, i;
|
||||
socklen_t len = sizeof(result);
|
||||
vpn_packet_t packet;
|
||||
int errors = 0;
|
||||
|
||||
/* check input from kernel */
|
||||
if(device_fd >= 0 && FD_ISSET(device_fd, readset)) {
|
||||
if(read_packet(&packet)) {
|
||||
errors = 0;
|
||||
packet.priority = 0;
|
||||
route(myself, &packet);
|
||||
} else {
|
||||
usleep(errors * 50000);
|
||||
errors++;
|
||||
if(errors > 10) {
|
||||
logger(LOG_ERR, "Too many errors from %s, exiting!", device);
|
||||
running = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue