From: Guus Sliepen Date: Sun, 11 Oct 2020 13:40:34 +0000 (+0200) Subject: Don't reset the UDP SPTPS session when a node becomes reachable. X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=77315aaa984e9a5821cf3ddbf3017db98204728c;p=meshlink Don't reset the UDP SPTPS session when a node becomes reachable. 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. --- diff --git a/src/graph.c b/src/graph.c index 1efdb26c..56ef11db 100644 --- a/src/graph.c +++ b/src/graph.c @@ -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;