@@ -93,28 +93,11 @@ void Peer::received(
93
93
break ;
94
94
}
95
95
96
- if (trustEstablished) {
96
+ if (trustEstablished) {
97
97
_lastTrustEstablishedPacketReceived = now;
98
98
path->trustedPacketReceived (now);
99
99
}
100
100
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
-
118
101
if (hops == 0 ) {
119
102
// If this is a direct packet (no hops), update existing paths or learn new ones
120
103
bool havePath = false ;
@@ -135,27 +118,20 @@ void Peer::received(
135
118
if ((!havePath)&&(RR->node ->shouldUsePathForZeroTierTraffic (tPtr,_id.address (),path->localSocket (),path->address ()))) {
136
119
Mutex::Lock _l (_paths_m);
137
120
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
139
122
// with the same local socket and address family.
140
123
bool redundant = false ;
141
- unsigned int replacePath = ZT_MAX_PEER_NETWORK_PATHS;
142
124
for (unsigned int i=0 ;i<ZT_MAX_PEER_NETWORK_PATHS;++i) {
143
125
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 ())) ) ) {
145
127
redundant = true ;
146
128
break ;
147
129
}
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
- }
153
130
} else break ;
154
131
}
155
132
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;
159
135
int replacePathQuality = 0 ;
160
136
for (unsigned int i=0 ;i<ZT_MAX_PEER_NETWORK_PATHS;++i) {
161
137
if (_paths[i].p ) {
@@ -169,16 +145,16 @@ void Peer::received(
169
145
break ;
170
146
}
171
147
}
172
- }
173
148
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
+ }
182
158
}
183
159
}
184
160
}
0 commit comments