diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-10-23 14:05:12 -0700 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-10-23 14:05:12 -0700 |
commit | e9648a6cdf5bd1d9f9e08c7cfef50265114c09d3 (patch) | |
tree | 75d16a2359ae5b143bfed0a907b6c53269922daa /node | |
parent | e6a63f5547f928f4908b7436210340c9db752284 (diff) | |
download | infinitytier-e9648a6cdf5bd1d9f9e08c7cfef50265114c09d3.tar.gz infinitytier-e9648a6cdf5bd1d9f9e08c7cfef50265114c09d3.zip |
Clarify logic in pinging, and prevent roots from pinging "down."
Diffstat (limited to 'node')
-rw-r--r-- | node/Node.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/node/Node.cpp b/node/Node.cpp index 6eea3d3d..c54d783f 100644 --- a/node/Node.cpp +++ b/node/Node.cpp @@ -211,8 +211,15 @@ public: } } - // If this is a network preferred relay, also always ping and if a stable endpoint is specified use that if not alive if (!upstream) { + // If I am a root server, only ping other root servers -- roots don't ping "down" + // since that would just be a waste of bandwidth and could potentially cause route + // flapping in Cluster mode. + if (RR->topology->amRoot()) + return; + + // Check for network preferred relays, also considered 'upstream' and thus always + // pinged to keep links up. If they have stable addresses we will try them there. for(std::vector< std::pair<Address,InetAddress> >::const_iterator r(_relays.begin());r!=_relays.end();++r) { if (r->first == p->address()) { if (r->second.ss_family == AF_INET) @@ -229,18 +236,22 @@ public: // "Upstream" devices are roots and relays and get special treatment -- they stay alive // forever and we try to keep (if available) both IPv4 and IPv6 channels open to them. bool needToContactIndirect = true; - if (!p->doPingAndKeepalive(RR,_now,AF_INET)) { + if (p->doPingAndKeepalive(RR,_now,AF_INET)) { + needToContactIndirect = false; + } else { if (stableEndpoint4) { needToContactIndirect = false; p->attemptToContactAt(RR,InetAddress(),stableEndpoint4,_now); } - } else needToContactIndirect = false; - if (!p->doPingAndKeepalive(RR,_now,AF_INET6)) { + } + if (p->doPingAndKeepalive(RR,_now,AF_INET6)) { + needToContactIndirect = false; + } else { if (stableEndpoint6) { needToContactIndirect = false; p->attemptToContactAt(RR,InetAddress(),stableEndpoint6,_now); } - } else needToContactIndirect = false; + } if (needToContactIndirect) { // If this is an upstream and we have no stable endpoint for either IPv4 or IPv6, |