Skip to content

Commit 8eb453e

Browse files
committed
Revert to ancient path redundancy check logic
1 parent d0aacfd commit 8eb453e

File tree

1 file changed

+14
-38
lines changed

1 file changed

+14
-38
lines changed

node/Peer.cpp

Lines changed: 14 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -93,28 +93,11 @@ void Peer::received(
9393
break;
9494
}
9595

96-
if (trustEstablished) {
96+
if (trustEstablished) {
9797
_lastTrustEstablishedPacketReceived = now;
9898
path->trustedPacketReceived(now);
9999
}
100100

101-
{
102-
Mutex::Lock _l(_paths_m);
103-
104-
recordIncomingPacket(tPtr, path, packetId, payloadLength, verb, now);
105-
106-
if (_canUseMultipath) {
107-
if (path->needsToSendQoS(now)) {
108-
sendQOS_MEASUREMENT(tPtr, path, path->localSocket(), path->address(), now);
109-
}
110-
for(unsigned int i=0;i<ZT_MAX_PEER_NETWORK_PATHS;++i) {
111-
if (_paths[i].p) {
112-
_paths[i].p->processBackgroundPathMeasurements(now);
113-
}
114-
}
115-
}
116-
}
117-
118101
if (hops == 0) {
119102
// If this is a direct packet (no hops), update existing paths or learn new ones
120103
bool havePath = false;
@@ -135,27 +118,20 @@ void Peer::received(
135118
if ((!havePath)&&(RR->node->shouldUsePathForZeroTierTraffic(tPtr,_id.address(),path->localSocket(),path->address()))) {
136119
Mutex::Lock _l(_paths_m);
137120

138-
// Paths are redundant if they duplicate an alive path to the same IP or
121+
// Paths are redunant if they duplicate an alive path to the same IP or
139122
// with the same local socket and address family.
140123
bool redundant = false;
141-
unsigned int replacePath = ZT_MAX_PEER_NETWORK_PATHS;
142124
for(unsigned int i=0;i<ZT_MAX_PEER_NETWORK_PATHS;++i) {
143125
if (_paths[i].p) {
144-
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())) ) ) {
126+
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())) ) ) {
145127
redundant = true;
146128
break;
147129
}
148-
// If the path is the same address and port, simply assume this is a replacement
149-
if ( (_paths[i].p->address().ipsEqual2(path->address()))) {
150-
replacePath = i;
151-
break;
152-
}
153130
} else break;
154131
}
155132

156-
// If the path isn't a duplicate of the same localSocket AND we haven't already determined a replacePath,
157-
// then find the worst path and replace it.
158-
if (!redundant && replacePath == ZT_MAX_PEER_NETWORK_PATHS) {
133+
if (!redundant) {
134+
unsigned int replacePath = ZT_MAX_PEER_NETWORK_PATHS;
159135
int replacePathQuality = 0;
160136
for(unsigned int i=0;i<ZT_MAX_PEER_NETWORK_PATHS;++i) {
161137
if (_paths[i].p) {
@@ -169,16 +145,16 @@ void Peer::received(
169145
break;
170146
}
171147
}
172-
}
173148

174-
if (replacePath != ZT_MAX_PEER_NETWORK_PATHS) {
175-
if (verb == Packet::VERB_OK) {
176-
RR->t->peerLearnedNewPath(tPtr,networkId,*this,path,packetId);
177-
_paths[replacePath].lr = now;
178-
_paths[replacePath].p = path;
179-
_paths[replacePath].priority = 1;
180-
} else {
181-
attemptToContact = true;
149+
if (replacePath != ZT_MAX_PEER_NETWORK_PATHS) {
150+
if (verb == Packet::VERB_OK) {
151+
RR->t->peerLearnedNewPath(tPtr,networkId,*this,path,packetId);
152+
_paths[replacePath].lr = now;
153+
_paths[replacePath].p = path;
154+
_paths[replacePath].priority = 1;
155+
} else {
156+
attemptToContact = true;
157+
}
182158
}
183159
}
184160
}

0 commit comments

Comments
 (0)