From bb1aebd963fcf970bf1c4473199fbda6c99e2d6a Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Mon, 26 Aug 2019 13:44:41 +0200 Subject: [PATCH] Import Upstream version 1.0.16 --- ChangeLog | 38 ++++++++++++++++++++++++++++++++++++++ NEWS | 7 +++++++ README | 4 ++-- configure | 2 +- configure.in | 2 +- doc/sample-config.tar.gz | Bin 1246 -> 1242 bytes lib/dropin.c | 2 +- lib/dropin.h | 2 +- m4/ev.m4 | 33 --------------------------------- src/net.c | 28 ++++++++++++++++++---------- src/protocol_misc.c | 2 +- 11 files changed, 70 insertions(+), 50 deletions(-) delete mode 100644 m4/ev.m4 diff --git a/ChangeLog b/ChangeLog index bf7ec06..e7e70d3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,41 @@ +commit 0f2aa4bd8b698608876bec141c5aef1aa619730b +Author: Guus Sliepen +Date: Sat Jul 23 14:12:23 2011 +0200 + + Releasing 1.0.16. + +commit e16ead8dd9d4600664058069f0695832dfe068b2 +Author: Guus Sliepen +Date: Sat Jul 23 14:11:44 2011 +0200 + + Use usleep() instead of sleep(), MinGW complained. + +commit 50fcfea127c9d2fdf8894498a9fdcc6fb3bbb2ce +Author: Guus Sliepen +Date: Sun Jul 17 19:34:01 2011 +0200 + + Flush output buffer in send_tcppacket(). + + This is mainly important for Windows, where the select() call in the + main thread is not being woken up when the tapreader thread calls + route(), causing a delay of up to 1 second before the output buffer is + flushed. This would cause bad performance when UDP communication is not + possible. + +commit be2fc8b0458b1e2ced3b5de410356d8d8639acff +Author: Guus Sliepen +Date: Sat Jul 16 10:47:35 2011 +0200 + + Make code to detect two nodes with the same Name less triggerhappy. + + First of all, if there really are two nodes with the same name, much + more than 10 contradicting ADD_EDGE and DEL_EDGE messages will be sent. + Also, we forgot to reset the counters when nothing happened. + + In case there is a ADD_EDGE/DEL_EDGE storm, we do not shut down, but + sleep an increasing amount of time, allowing tinc to recover gracefully + from temporary failures. + commit 05260f941c2a24eb3f09070a2550cf15e431266a Author: Guus Sliepen Date: Fri Jun 24 14:50:20 2011 +0200 diff --git a/NEWS b/NEWS index 20a98d8..ab36c23 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,10 @@ +Version 1.0.16 July 23 2011 + + * Fixed a performance issue with TCP communication under Windows. + + * Fixed code that, during network outages, would cause tinc to exit when it + thought two nodes with identical Names were on the VPN. + Version 1.0.15 June 24 2011 * Improved logging to file. diff --git a/README b/README index 52b3356..338f23c 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -This is the README file for tinc version 1.0.15. Installation +This is the README file for tinc version 1.0.16. Installation instructions may be found in the INSTALL file. tinc is Copyright (C) 1998-2011 by: @@ -55,7 +55,7 @@ should be changed into "Device", and "Device" should be changed into Compatibility ------------- -Version 1.0.15 is compatible with 1.0pre8, 1.0 and later, but not with older +Version 1.0.16 is compatible with 1.0pre8, 1.0 and later, but not with older versions of tinc. diff --git a/configure b/configure index 22cdcfd..c9ce6d8 100755 --- a/configure +++ b/configure @@ -2731,7 +2731,7 @@ fi # Define the identity of the package. PACKAGE=tinc - VERSION=1.0.15 + VERSION=1.0.16 cat >>confdefs.h <<_ACEOF diff --git a/configure.in b/configure.in index 12938da..65b5c4c 100644 --- a/configure.in +++ b/configure.in @@ -3,7 +3,7 @@ dnl Process this file with autoconf to produce a configure script. AC_PREREQ(2.61) AC_INIT AC_CONFIG_SRCDIR([src/tincd.c]) -AM_INIT_AUTOMAKE(tinc, 1.0.15) +AM_INIT_AUTOMAKE(tinc, 1.0.16) AC_CONFIG_HEADERS([config.h]) AM_MAINTAINER_MODE diff --git a/doc/sample-config.tar.gz b/doc/sample-config.tar.gz index 17d7c43291d7b9343786247a56eea46bde9fac7a..581c238fa246f550ea449abd38f876a5799a6008 100644 GIT binary patch literal 1242 zcmV<01SR_)iwFS6vnoyi1MQemZ`(KwfcuV_ zO}3Rps4e*r#%wupb6dFN(t6Q4j|4pmzlEe!|(0EGM$Oz7Vl%>+hsW8Qt%649Z782!6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un=}e^FQ;+Lbn_TR+UpK*e$0iYQyshW;7SZa@kfA(^5OY)T8w` zN<)R7D>SxiQ8KCUR<8w$+J9ie5>C1qTIE*wC8ZQhl*Tk=mCTq-anfgglpBQ;O1Qn7 zk7Xrfd@j;@FDyi!lS6WU&L<4L(kAGjP6u^E=a^F{WQo@wHRq?}^CQ&vN|p3VW0m8o z_`ULH$z`oXw@wk0NXkz4i;&e1z`M?UJVEQ+$924+-}=96=QYUV{@>2jLhf{oC;ESg zjsH>q?+=^){~U7orjrQSF|$>lr=|~St_-#g+6k`rtk+^oO#E(v-$s`=7uO$8&Mus0 zQ;#oDw$y)B?s$x+>VG)wKCJ(+;lJmR?e%ZCHBgn0YX1;M7N&y8i!hBIPw=guse;%h zQ^a#fQF7`Y6TvweLS!S`uQkb}N^1foM>O=(-yG&c4J2I7g;vrr)O>|?Ydr^p#W-nT zve#ld^DfaG;k6(tD|2RXfWjO>g8U^W1do~G4o4SC-y$3?$pbmUM+K7=%k!l}!%xCf z=e>7PI%q-uD44k=KrDEXcy`64RSDss14#;E4X7N*A)g@!O$ps*jQT2DDI-f}VlFZq z8^+FyAwI$e%qK!3(h1*&9ceyh^fy~ua`e6%M1yxh6hy0tp&Q2m{f9wVck9ji*M|Ll z%a=i^#e8>r?5X<4U;7X0zZVXorv9HpaGP_t54TkYcb4zjvI*y;9HNhqr%7bze~ZKiA6EA_48SgSOu zU?O;{O>%niX>;M1& diff --git a/lib/dropin.c b/lib/dropin.c index 4aed74e..eb17aca 100644 --- a/lib/dropin.c +++ b/lib/dropin.c @@ -165,7 +165,7 @@ int gettimeofday(struct timeval *tv, void *tz) { #endif #ifndef HAVE_USLEEP -int usleep(long usec) { +int usleep(long long usec) { struct timeval tv = {usec / 1000000, (usec / 1000) % 1000}; select(0, NULL, NULL, NULL, &tv); return 0; diff --git a/lib/dropin.h b/lib/dropin.h index 22fe36d..dc7dbee 100644 --- a/lib/dropin.h +++ b/lib/dropin.h @@ -42,7 +42,7 @@ extern int gettimeofday(struct timeval *, void *); #endif #ifndef HAVE_USLEEP -extern int usleep(long); +extern int usleep(long long); #endif #endif /* __DROPIN_H__ */ diff --git a/m4/ev.m4 b/m4/ev.m4 deleted file mode 100644 index 59d767b..0000000 --- a/m4/ev.m4 +++ /dev/null @@ -1,33 +0,0 @@ -dnl Check to find the libev headers/libraries - -AC_DEFUN([tinc_LIBEV], -[ - AC_ARG_WITH(libev, - AS_HELP_STRING([--with-libev=DIR], [libev base directory, or:]), - [libev="$withval" - CPPFLAGS="$CPPFLAGS -I$withval/include" - LDFLAGS="$LDFLAGS -L$withval/lib"] - ) - - AC_ARG_WITH(libev-include, - AS_HELP_STRING([--with-libev-include=DIR], [libev headers directory]), - [libev_include="$withval" - CPPFLAGS="$CPPFLAGS -I$withval"] - ) - - AC_ARG_WITH(libev-lib, - AS_HELP_STRING([--with-libev-lib=DIR], [libev library directory]), - [libev_lib="$withval" - LDFLAGS="$LDFLAGS -L$withval"] - ) - - AC_CHECK_HEADERS(ev.h, - [], - [AC_MSG_ERROR("ev header files not found."); break] - ) - - AC_CHECK_LIB(ev, ev_loop, - [LIBS="$LIBS -lev"], - [AC_MSG_ERROR("libev libraries not found.")] - ) -]) diff --git a/src/net.c b/src/net.c index c5193c5..8762db3 100644 --- a/src/net.c +++ b/src/net.c @@ -50,6 +50,7 @@ bool graph_dump = false; time_t now = 0; int contradicting_add_edge = 0; int contradicting_del_edge = 0; +static int sleeptime = 10; /* Purge edges and subnets of unreachable nodes. Use carefully. */ @@ -464,18 +465,25 @@ int main_loop(void) { keyexpires = now + keylifetime; } - if(contradicting_del_edge > 10 && contradicting_add_edge > 10) { - logger(LOG_WARNING, "Possible node with same Name as us!"); + /* Detect ADD_EDGE/DEL_EDGE storms that are caused when + * two tinc daemons with the same name are on the VPN. + * If so, sleep a while. If this happens multiple times + * in a row, sleep longer. */ - if(rand() % 3 == 0) { - logger(LOG_ERR, "Shutting down, check configuration of all nodes for duplicate Names!"); - running = false; - break; - } - - contradicting_add_edge = 0; - contradicting_del_edge = 0; + if(contradicting_del_edge > 100 && contradicting_add_edge > 100) { + logger(LOG_WARNING, "Possible node with same Name as us! Sleeping %d seconds.", sleeptime); + usleep(sleeptime * 1000000LL); + sleeptime *= 2; + if(sleeptime < 0) + sleeptime = 3600; + } else { + sleeptime /= 2; + if(sleeptime < 10) + sleeptime = 10; } + + contradicting_add_edge = 0; + contradicting_del_edge = 0; } if(sigalrm) { diff --git a/src/protocol_misc.c b/src/protocol_misc.c index 6f7ab03..3d405bc 100644 --- a/src/protocol_misc.c +++ b/src/protocol_misc.c @@ -129,7 +129,7 @@ bool send_tcppacket(connection_t *c, const vpn_packet_t *packet) { if(!send_request(c, "%d %hd", PACKET, packet->len)) return false; - return send_meta(c, (char *)packet->data, packet->len); + return send_meta(c, (char *)packet->data, packet->len) && flush_meta(c); } bool tcppacket_h(connection_t *c) {