]> git.meshlink.io Git - meshlink/commitdiff
Don't reset the UDP SPTPS session when a node becomes reachable.
authorGuus Sliepen <guus@meshlink.io>
Sun, 11 Oct 2020 13:40:34 +0000 (15:40 +0200)
committerGuus Sliepen <guus@meshlink.io>
Sun, 11 Oct 2020 13:40:34 +0000 (15:40 +0200)
Only do this when it becomes unreachable. This fixes an issue where right
after a meta-connection is established, the initiator sends a proactive
REQ_KEY, before the peer really becomes reachable according to the graph.
When the latter happened, it would reset the session so far, causing a new
REQ_KEY to be sent, which could cross the ANS_KEY from the peer. This would
resolve itself after a few seconds, but causes an unnecessary delay that is
easy to trigger.

src/graph.c

index 1efdb26c9b21ad73a809a9fa95ec16076528c8c7..56ef11db382deb39f5268cb0e8a34fcfc198f4a1 100644 (file)
@@ -193,10 +193,13 @@ static void check_reachability(meshlink_handle_t *mesh) {
 
                        /* TODO: only clear status.validkey if node is unreachable? */
 
-                       n->status.validkey = false;
-                       sptps_stop(&n->sptps);
-                       n->status.waitingforkey = false;
-                       n->last_req_key = -3600;
+                       if(!n->status.reachable) {
+                               logger(mesh, MESHLINK_DEBUG, "Resetting validkey/waitingforkey for %s, reachable %d", n->name, n->status.reachable);
+                               n->status.validkey = false;
+                               sptps_stop(&n->sptps);
+                               n->status.waitingforkey = false;
+                               n->last_req_key = -3600;
+                       }
 
                        n->status.udp_confirmed = false;
                        n->maxmtu = MTU;