mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-01 23:10:52 +00:00
Fix for cluster handoff.
This commit is contained in:
parent
139c4b5633
commit
f1c0563c40
@ -1206,6 +1206,8 @@ bool IncomingPacket::_doPUSH_DIRECT_PATHS(const RuntimeEnvironment *RR,void *tPt
|
|||||||
(!( ((flags & ZT_PUSH_DIRECT_PATHS_FLAG_CLUSTER_REDIRECT) == 0) && (peer->hasActivePathTo(now,a)) )) && // not already known
|
(!( ((flags & ZT_PUSH_DIRECT_PATHS_FLAG_CLUSTER_REDIRECT) == 0) && (peer->hasActivePathTo(now,a)) )) && // not already known
|
||||||
(RR->node->shouldUsePathForZeroTierTraffic(tPtr,peer->address(),_path->localAddress(),a)) ) // should use path
|
(RR->node->shouldUsePathForZeroTierTraffic(tPtr,peer->address(),_path->localAddress(),a)) ) // should use path
|
||||||
{
|
{
|
||||||
|
if ((flags & ZT_PUSH_DIRECT_PATHS_FLAG_CLUSTER_REDIRECT) != 0)
|
||||||
|
peer->setClusterPreferred(a);
|
||||||
if (++countPerScope[(int)a.ipScope()][0] <= ZT_PUSH_DIRECT_PATHS_MAX_PER_SCOPE_AND_FAMILY) {
|
if (++countPerScope[(int)a.ipScope()][0] <= ZT_PUSH_DIRECT_PATHS_MAX_PER_SCOPE_AND_FAMILY) {
|
||||||
TRACE("attempting to contact %s at pushed direct path %s",peer->address().toString().c_str(),a.toString().c_str());
|
TRACE("attempting to contact %s at pushed direct path %s",peer->address().toString().c_str(),a.toString().c_str());
|
||||||
peer->attemptToContactAt(tPtr,InetAddress(),a,now,false,0);
|
peer->attemptToContactAt(tPtr,InetAddress(),a,now,false,0);
|
||||||
@ -1221,6 +1223,8 @@ bool IncomingPacket::_doPUSH_DIRECT_PATHS(const RuntimeEnvironment *RR,void *tPt
|
|||||||
(!( ((flags & ZT_PUSH_DIRECT_PATHS_FLAG_CLUSTER_REDIRECT) == 0) && (peer->hasActivePathTo(now,a)) )) && // not already known
|
(!( ((flags & ZT_PUSH_DIRECT_PATHS_FLAG_CLUSTER_REDIRECT) == 0) && (peer->hasActivePathTo(now,a)) )) && // not already known
|
||||||
(RR->node->shouldUsePathForZeroTierTraffic(tPtr,peer->address(),_path->localAddress(),a)) ) // should use path
|
(RR->node->shouldUsePathForZeroTierTraffic(tPtr,peer->address(),_path->localAddress(),a)) ) // should use path
|
||||||
{
|
{
|
||||||
|
if ((flags & ZT_PUSH_DIRECT_PATHS_FLAG_CLUSTER_REDIRECT) != 0)
|
||||||
|
peer->setClusterPreferred(a);
|
||||||
if (++countPerScope[(int)a.ipScope()][1] <= ZT_PUSH_DIRECT_PATHS_MAX_PER_SCOPE_AND_FAMILY) {
|
if (++countPerScope[(int)a.ipScope()][1] <= ZT_PUSH_DIRECT_PATHS_MAX_PER_SCOPE_AND_FAMILY) {
|
||||||
TRACE("attempting to contact %s at pushed direct path %s",peer->address().toString().c_str(),a.toString().c_str());
|
TRACE("attempting to contact %s at pushed direct path %s",peer->address().toString().c_str(),a.toString().c_str());
|
||||||
peer->attemptToContactAt(tPtr,InetAddress(),a,now,false,0);
|
peer->attemptToContactAt(tPtr,InetAddress(),a,now,false,0);
|
||||||
|
@ -169,7 +169,7 @@ void Peer::received(
|
|||||||
if (verb == Packet::VERB_OK) {
|
if (verb == Packet::VERB_OK) {
|
||||||
Mutex::Lock _l(_paths_m);
|
Mutex::Lock _l(_paths_m);
|
||||||
if (path->address().ss_family == AF_INET) {
|
if (path->address().ss_family == AF_INET) {
|
||||||
if ((!_v4Path.p)||(!_v4Path.p->alive(now))||(path->preferenceRank() >= _v4Path.p->preferenceRank())) {
|
if ( (!_v4Path.p) || (!_v4Path.p->alive(now)) || ((_v4Path.p->address() != _v4ClusterPreferred)&&(path->preferenceRank() >= _v4Path.p->preferenceRank())) ) {
|
||||||
_v4Path.lr = now;
|
_v4Path.lr = now;
|
||||||
_v4Path.p = path;
|
_v4Path.p = path;
|
||||||
#ifdef ZT_ENABLE_CLUSTER
|
#ifdef ZT_ENABLE_CLUSTER
|
||||||
@ -179,7 +179,7 @@ void Peer::received(
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
} else if (path->address().ss_family == AF_INET6) {
|
} else if (path->address().ss_family == AF_INET6) {
|
||||||
if ((!_v6Path.p)||(!_v6Path.p->alive(now))||(path->preferenceRank() >= _v6Path.p->preferenceRank())) {
|
if ( (!_v6Path.p) || (!_v6Path.p->alive(now)) || ((_v6Path.p->address() != _v6ClusterPreferred)&&(path->preferenceRank() >= _v6Path.p->preferenceRank())) ) {
|
||||||
_v6Path.lr = now;
|
_v6Path.lr = now;
|
||||||
_v6Path.p = path;
|
_v6Path.p = path;
|
||||||
#ifdef ZT_ENABLE_CLUSTER
|
#ifdef ZT_ENABLE_CLUSTER
|
||||||
|
@ -210,6 +210,19 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicate that the given address was provided by a cluster as a preferred destination
|
||||||
|
*
|
||||||
|
* @param addr Address cluster prefers that we use
|
||||||
|
*/
|
||||||
|
inline void setClusterPreferred(const InetAddress &addr)
|
||||||
|
{
|
||||||
|
if (addr.ss_family == AF_INET)
|
||||||
|
_v4ClusterPreferred = addr;
|
||||||
|
else if (addr.ss_family == AF_INET6)
|
||||||
|
_v6ClusterPreferred = addr;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fill parameters with V4 and V6 addresses if known and alive
|
* Fill parameters with V4 and V6 addresses if known and alive
|
||||||
*
|
*
|
||||||
@ -465,6 +478,9 @@ private:
|
|||||||
uint16_t _vMinor;
|
uint16_t _vMinor;
|
||||||
uint16_t _vRevision;
|
uint16_t _vRevision;
|
||||||
|
|
||||||
|
InetAddress _v4ClusterPreferred;
|
||||||
|
InetAddress _v6ClusterPreferred;
|
||||||
|
|
||||||
_PeerPath _v4Path; // IPv4 direct path
|
_PeerPath _v4Path; // IPv4 direct path
|
||||||
_PeerPath _v6Path; // IPv6 direct path
|
_PeerPath _v6Path; // IPv6 direct path
|
||||||
Mutex _paths_m;
|
Mutex _paths_m;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user