From 0bc10923a1fc0c1ac1058d5ba4044afa01bda474 Mon Sep 17 00:00:00 2001 From: travisladuke Date: Mon, 7 Aug 2023 12:42:03 -0700 Subject: [PATCH 1/2] Test that starting zerotier before internet works --- .github/workflows/validate-1m-linux.sh | 47 +++++++++++++++----------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/.github/workflows/validate-1m-linux.sh b/.github/workflows/validate-1m-linux.sh index 25d6bd473..c044245a0 100755 --- a/.github/workflows/validate-1m-linux.sh +++ b/.github/workflows/validate-1m-linux.sh @@ -71,26 +71,6 @@ main() { # Allow forwarding sysctl -w net.ipv4.ip_forward=1 - echo -e "\nPing from host to namespaces" - - ping -c 3 192.168.0.1 - ping -c 3 192.168.1.1 - - echo -e "\nPing from namespace to host" - - $NS1 ping -c 3 192.168.0.1 - $NS1 ping -c 3 192.168.0.1 - $NS2 ping -c 3 192.168.0.2 - $NS2 ping -c 3 192.168.0.2 - - echo -e "\nPing from ns1 to ns2" - - $NS1 ping -c 3 192.168.0.1 - - echo -e "\nPing from ns2 to ns1" - - $NS2 ping -c 3 192.168.0.1 - ################################################################################ # Memory Leak Check # ################################################################################ @@ -113,7 +93,34 @@ main() { ./zerotier-one node1 -p9996 -U >>node_1.log 2>&1 & # Second instance, not run in memory profiler + # Don't set up internet access until _after_ zerotier is running + # This has been a source of stuckness in the past. + $NS2 ip addr del 192.168.1.2/24 dev veth3 $NS2 sudo ./zerotier-one node2 -U -p9997 >>node_2.log 2>&1 & + sleep 1; + $NS2 ip addr add 192.168.1.2/24 dev veth3 + $NS2 ip route add default via 192.168.1.1 + + + echo -e "\nPing from host to namespaces" + + ping -c 3 192.168.0.1 + ping -c 3 192.168.1.1 + + echo -e "\nPing from namespace to host" + + $NS1 ping -c 3 192.168.0.1 + $NS1 ping -c 3 192.168.0.1 + $NS2 ping -c 3 192.168.0.2 + $NS2 ping -c 3 192.168.0.2 + + echo -e "\nPing from ns1 to ns2" + + $NS1 ping -c 3 192.168.0.1 + + echo -e "\nPing from ns2 to ns1" + + $NS2 ping -c 3 192.168.0.1 ################################################################################ # Online Check # From 14671009f89a881676289defa0e126d4f6f6bb5a Mon Sep 17 00:00:00 2001 From: travisladuke Date: Fri, 4 Aug 2023 16:12:36 -0700 Subject: [PATCH 2/2] Don't skip hellos when there are no paths available working on #2082 --- node/Node.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/node/Node.cpp b/node/Node.cpp index e2d5f7bf3..0657cbd0b 100644 --- a/node/Node.cpp +++ b/node/Node.cpp @@ -248,9 +248,15 @@ public: const std::vector *const alwaysContactEndpoints = _alwaysContact.get(p->address()); if (alwaysContactEndpoints) { - // Contact upstream peers as infrequently as possible ZT_PeerRole role = RR->topology->role(p->address()); + + // Contact upstream peers as infrequently as possible int roleBasedTimerScale = (role == ZT_PEER_ROLE_LEAF) ? 2 : 16; + + // Unless we don't any have paths to the roots, then we shouldn't wait a long time to contact them + bool hasPaths = p->paths(RR->node->now()).size() > 0; + roleBasedTimerScale = (role != ZT_PEER_ROLE_LEAF && !hasPaths) ? 0 : roleBasedTimerScale; + if ((RR->node->now() - p->lastSentFullHello()) <= (ZT_PATH_HEARTBEAT_PERIOD * roleBasedTimerScale)) { return; }