From 43780742b03ffa69fb1a1868f976ac03edce921b Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Tue, 6 Sep 2016 11:10:04 -0700 Subject: [PATCH] comments, docs --- node/Path.hpp | 2 ++ node/Peer.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/node/Path.hpp b/node/Path.hpp index 718e1cddb..8151ed279 100644 --- a/node/Path.hpp +++ b/node/Path.hpp @@ -156,6 +156,8 @@ public: */ inline unsigned int preferenceRank() const { + // This causes us to rank paths in order of IP scope rank (see InetAdddress.hpp) but + // within each IP scope class to prefer IPv6 over IPv4. return ( ((unsigned int)_ipScope << 1) | (unsigned int)(_addr.ss_family == AF_INET6) ); } diff --git a/node/Peer.cpp b/node/Peer.cpp index 3701d9a1a..110d67fdf 100644 --- a/node/Peer.cpp +++ b/node/Peer.cpp @@ -138,6 +138,7 @@ void Peer::received( if (verb == Packet::VERB_OK) { Mutex::Lock _l(_paths_m); + // Since this is a new path, figure out where to put it (possibly replacing an old/dead one) unsigned int slot; if (_numPaths < ZT_MAX_PEER_NETWORK_PATHS) { slot = _numPaths++; @@ -157,6 +158,7 @@ void Peer::received( if (worstSlot >= 0) { slot = (unsigned int)worstSlot; } else { + // If we can't find one with the same family, replace the worst of any family slot = ZT_MAX_PEER_NETWORK_PATHS - 1; for(unsigned int p=0;p<_numPaths;++p) { const uint64_t s = _pathScore(p);