mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-05 03:53:44 +02:00
Revert to ancient path redundancy check logic
This commit is contained in:
parent
a23b6d09c0
commit
29e7fa5c4b
1 changed files with 30 additions and 25 deletions
|
@ -115,45 +115,50 @@ void Peer::received(
|
||||||
}
|
}
|
||||||
|
|
||||||
bool attemptToContact = false;
|
bool attemptToContact = false;
|
||||||
|
|
||||||
int replaceIdx = ZT_MAX_PEER_NETWORK_PATHS;
|
|
||||||
if ((!havePath)&&(RR->node->shouldUsePathForZeroTierTraffic(tPtr,_id.address(),path->localSocket(),path->address()))) {
|
if ((!havePath)&&(RR->node->shouldUsePathForZeroTierTraffic(tPtr,_id.address(),path->localSocket(),path->address()))) {
|
||||||
Mutex::Lock _l(_paths_m);
|
Mutex::Lock _l(_paths_m);
|
||||||
|
|
||||||
|
// Paths are redunant if they duplicate an alive path to the same IP or
|
||||||
|
// with the same local socket and address family.
|
||||||
|
bool redundant = false;
|
||||||
for(unsigned int i=0;i<ZT_MAX_PEER_NETWORK_PATHS;++i) {
|
for(unsigned int i=0;i<ZT_MAX_PEER_NETWORK_PATHS;++i) {
|
||||||
if (_paths[i].p) {
|
if (_paths[i].p) {
|
||||||
// match addr
|
if ( (_paths[i].p->alive(now)) && ( ((_paths[i].p->localSocket() == path->localSocket())&&(_paths[i].p->address().ss_family == path->address().ss_family)) || (_paths[i].p->address().ipsEqual2(path->address())) ) ) {
|
||||||
if ( (_paths[i].p->alive(now)) && ( ((_paths[i].p->localSocket() == path->localSocket())&&(_paths[i].p->address().ss_family == path->address().ss_family)) && (_paths[i].p->address().ipsEqual2(path->address())) ) ) {
|
redundant = true;
|
||||||
// port
|
break;
|
||||||
if (_paths[i].p->address().port() == path->address().port()) {
|
|
||||||
replaceIdx = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
} else break;
|
||||||
}
|
}
|
||||||
if (replaceIdx == ZT_MAX_PEER_NETWORK_PATHS) {
|
|
||||||
|
if (!redundant) {
|
||||||
|
unsigned int replacePath = ZT_MAX_PEER_NETWORK_PATHS;
|
||||||
|
int replacePathQuality = 0;
|
||||||
for(unsigned int i=0;i<ZT_MAX_PEER_NETWORK_PATHS;++i) {
|
for(unsigned int i=0;i<ZT_MAX_PEER_NETWORK_PATHS;++i) {
|
||||||
if (!_paths[i].p) {
|
if (_paths[i].p) {
|
||||||
replaceIdx = i;
|
const int q = _paths[i].p->quality(now);
|
||||||
|
if (q > replacePathQuality) {
|
||||||
|
replacePathQuality = q;
|
||||||
|
replacePath = i;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
replacePath = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (replaceIdx != ZT_MAX_PEER_NETWORK_PATHS) {
|
if (replacePath != ZT_MAX_PEER_NETWORK_PATHS) {
|
||||||
if (verb == Packet::VERB_OK) {
|
if (verb == Packet::VERB_OK) {
|
||||||
RR->t->peerLearnedNewPath(tPtr,networkId,*this,path,packetId);
|
RR->t->peerLearnedNewPath(tPtr,networkId,*this,path,packetId);
|
||||||
performMultipathStateCheck(now);
|
_paths[replacePath].lr = now;
|
||||||
if (_bondToPeer) {
|
_paths[replacePath].p = path;
|
||||||
_bondToPeer->nominatePath(path, now);
|
_paths[replacePath].priority = 1;
|
||||||
|
} else {
|
||||||
|
attemptToContact = true;
|
||||||
}
|
}
|
||||||
_paths[replaceIdx].lr = now;
|
|
||||||
_paths[replaceIdx].p = path;
|
|
||||||
_paths[replaceIdx].priority = 1;
|
|
||||||
} else {
|
|
||||||
attemptToContact = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attemptToContact) {
|
if (attemptToContact) {
|
||||||
attemptToContactAt(tPtr,path->localSocket(),path->address(),now,true);
|
attemptToContactAt(tPtr,path->localSocket(),path->address(),now,true);
|
||||||
path->sent(now);
|
path->sent(now);
|
||||||
|
|
Loading…
Add table
Reference in a new issue