summaryrefslogtreecommitdiff
path: root/node/Peer.cpp
diff options
context:
space:
mode:
authorGrant Limberg <grant.limberg@zerotier.com>2019-06-17 15:32:27 -0700
committerGrant Limberg <grant.limberg@zerotier.com>2019-06-17 15:32:27 -0700
commit21e844cd82f8b6bb03f51de996f5fb91cd3fe1f6 (patch)
treefc76dc87732d90e81472caa2bf1a478e400cb99d /node/Peer.cpp
parent4e2439bd127c399bc31a44611c5226ed51681728 (diff)
parentc5a07c7f20dc54d88a2f6b8b5c4462510b042325 (diff)
downloadinfinitytier-21e844cd82f8b6bb03f51de996f5fb91cd3fe1f6.tar.gz
infinitytier-21e844cd82f8b6bb03f51de996f5fb91cd3fe1f6.zip
Merge branch 'dev' of http://git.int.zerotier.com/ZeroTier/ZeroTierOne into dev
Diffstat (limited to 'node/Peer.cpp')
-rw-r--r--node/Peer.cpp41
1 files changed, 21 insertions, 20 deletions
diff --git a/node/Peer.cpp b/node/Peer.cpp
index 029e45e7..cbd07799 100644
--- a/node/Peer.cpp
+++ b/node/Peer.cpp
@@ -212,10 +212,10 @@ void Peer::received(
if (pathsToPush.size() > 0) {
std::vector<InetAddress>::const_iterator p(pathsToPush.begin());
while (p != pathsToPush.end()) {
- Packet outp(_id.address(),RR->identity.address(),Packet::VERB_PUSH_DIRECT_PATHS);
- outp.addSize(2); // leave room for count
+ Packet *outp = new Packet(_id.address(),RR->identity.address(),Packet::VERB_PUSH_DIRECT_PATHS);
+ outp->addSize(2); // leave room for count
unsigned int count = 0;
- while ((p != pathsToPush.end())&&((outp.size() + 24) < 1200)) {
+ while ((p != pathsToPush.end())&&((outp->size() + 24) < 1200)) {
uint8_t addressType = 4;
switch(p->ss_family) {
case AF_INET:
@@ -228,22 +228,23 @@ void Peer::received(
continue;
}
- outp.append((uint8_t)0); // no flags
- outp.append((uint16_t)0); // no extensions
- outp.append(addressType);
- outp.append((uint8_t)((addressType == 4) ? 6 : 18));
- outp.append(p->rawIpData(),((addressType == 4) ? 4 : 16));
- outp.append((uint16_t)p->port());
+ outp->append((uint8_t)0); // no flags
+ outp->append((uint16_t)0); // no extensions
+ outp->append(addressType);
+ outp->append((uint8_t)((addressType == 4) ? 6 : 18));
+ outp->append(p->rawIpData(),((addressType == 4) ? 4 : 16));
+ outp->append((uint16_t)p->port());
++count;
++p;
}
if (count) {
- outp.setAt(ZT_PACKET_IDX_PAYLOAD,(uint16_t)count);
- outp.compress();
- outp.armor(_key,true);
- path->send(RR,tPtr,outp.data(),outp.size(),now);
+ outp->setAt(ZT_PACKET_IDX_PAYLOAD,(uint16_t)count);
+ outp->compress();
+ outp->armor(_key,true);
+ path->send(RR,tPtr,outp->data(),outp->size(),now);
}
+ delete outp;
}
}
}
@@ -300,13 +301,13 @@ void Peer::computeAggregateProportionalAllocation(int64_t now)
float age_contrib = exp((-1)*normalized_ma);
float relScope = ((float)(_paths[i].p->ipScope()+1) / (maxScope + 1));
float relQuality =
- (relStability[i] * ZT_PATH_CONTRIB_STABILITY)
- + (fmax(1, relThroughput[i]) * ZT_PATH_CONTRIB_THROUGHPUT)
- + relScope * ZT_PATH_CONTRIB_SCOPE;
+ (relStability[i] * (float)ZT_PATH_CONTRIB_STABILITY)
+ + (fmaxf(1.0f, relThroughput[i]) * (float)ZT_PATH_CONTRIB_THROUGHPUT)
+ + relScope * (float)ZT_PATH_CONTRIB_SCOPE;
relQuality *= age_contrib;
// Arbitrary cutoffs
- relQuality = relQuality > (1.00 / 100.0) ? relQuality : 0.0;
- relQuality = relQuality < (99.0 / 100.0) ? relQuality : 1.0;
+ relQuality = relQuality > (1.00f / 100.0f) ? relQuality : 0.0f;
+ relQuality = relQuality < (99.0f / 100.0f) ? relQuality : 1.0f;
totalRelativeQuality += relQuality;
_paths[i].p->updateRelativeQuality(relQuality);
}
@@ -479,8 +480,8 @@ char *Peer::interfaceListStr()
if (_paths[i].p && _paths[i].p->alive(now)) {
int ipv = _paths[i].p->address().isV4();
// If this is acting as an aggregate link, check allocations
- float targetAllocation = 1.0 / alivePathCount;
- float currentAllocation = 1.0;
+ float targetAllocation = 1.0f / (float)alivePathCount;
+ float currentAllocation = 1.0f;
if (alivePathCount > 1) {
currentAllocation = (float)_pathChoiceHist.countValue(i) / (float)_pathChoiceHist.count();
if (fabs(targetAllocation - currentAllocation) > ZT_PATH_IMBALANCE_THRESHOLD) {