From 7266550c22103947d058239e52b63585806c6350 Mon Sep 17 00:00:00 2001 From: Joseph Henry Date: Tue, 26 May 2020 17:57:37 -0700 Subject: [PATCH] Remove vestigial constructor, fix typos, clean up code --- node/Bond.cpp | 38 ++++++++++++++++++++++++-------------- node/Bond.hpp | 12 ++---------- node/BondController.hpp | 4 ++-- node/Path.hpp | 20 +++++++------------- service/OneService.cpp | 2 +- 5 files changed, 36 insertions(+), 40 deletions(-) diff --git a/node/Bond.cpp b/node/Bond.cpp index 2f283a696..9aef8f815 100644 --- a/node/Bond.cpp +++ b/node/Bond.cpp @@ -29,7 +29,8 @@ Bond::Bond(const RuntimeEnvironment *renv, int policy, const SharedPtr& pe _policyAlias = BondController::getPolicyStrByCode(policy); } -Bond::Bond(std::string& basePolicy, std::string& policyAlias, const SharedPtr& peer) : +Bond::Bond(const RuntimeEnvironment *renv, std::string& basePolicy, std::string& policyAlias, const SharedPtr& peer) : + RR(renv), _policyAlias(policyAlias), _peer(peer) { @@ -1518,20 +1519,23 @@ void Bond::setReasonableDefaults(int policy) _upDelay = 0; _allowFlowHashing=false; _bondMonitorInterval=0; - _allowPathNegotiation=false; _shouldCollectPathStatistics=false; - _lastPathNegotiationReceived=0; _lastBackgroundTaskCheck=0; + + // Path negotiation + _allowPathNegotiation=false; + _lastPathNegotiationReceived=0; _lastPathNegotiationCheck=0; + _pathNegotiationCutoffCount=0; + _localUtility=0; _lastFlowStatReset=0; _lastFlowExpirationCheck=0; - _localUtility=0; + _numBondedPaths=0; _rrPacketsSentOnCurrSlave=0; _rrIdx=0; - _lastPathNegotiationReceived=0; - _pathNegotiationCutoffCount=0; + _lastFlowRebalance=0; _totalBondUnderload = 0; @@ -1543,12 +1547,6 @@ void Bond::setReasonableDefaults(int policy) _lastFrame=0; - // TODO: Remove - _header=false; - _lastLogTS = 0; - _lastPrintTS = 0; - - /** @@ -1582,7 +1580,7 @@ void Bond::setReasonableDefaults(int policy) case ZT_BONDING_POLICY_BALANCE_RR: _failoverInterval = 5000; _allowFlowHashing = false; - _packetsPerSlave = 512; + _packetsPerSlave = 1024; _slaveMonitorStrategy = ZT_MULTIPATH_SLAVE_MONITOR_STRATEGY_DYNAMIC; _qualityWeights[ZT_QOS_LAT_IDX] = 0.4f; _qualityWeights[ZT_QOS_LTM_IDX] = 0.0f; @@ -1653,11 +1651,23 @@ void Bond::setReasonableDefaults(int policy) _qosSendInterval = _bondMonitorInterval * 4; _qosCutoffCount = 0; _lastQoSRateCheck = 0; + _lastQualityEstimation=0; throughputMeasurementInterval = _ackSendInterval * 2; BondController::setMinReqPathMonitorInterval(_bondMonitorInterval); _defaultPathRefractoryPeriod = 8000; + + + + + // TODO: Remove + _header=false; + _lastLogTS = 0; + _lastPrintTS = 0; + + + fprintf(stderr, "TIMERS: strat=%d, fi= %d, bmi= %d, qos= %d, ack= %d, estimateInt= %d, refractory= %d, ud= %d, dd= %d\n", _slaveMonitorStrategy, _failoverInterval, @@ -1669,7 +1679,7 @@ void Bond::setReasonableDefaults(int policy) _upDelay, _downDelay); - _lastQualityEstimation=0; + } void Bond::setUserQualityWeights(float weights[], int len) diff --git a/node/Bond.hpp b/node/Bond.hpp index 89e4c905a..62195b18e 100644 --- a/node/Bond.hpp +++ b/node/Bond.hpp @@ -54,13 +54,6 @@ public: SharedPtr getSlave(const SharedPtr& path); - /** - * Constructor. For use only in first initialization in Node - * - * @param renv Runtime environment - */ - Bond(const RuntimeEnvironment *renv); - /** * Constructor. Creates a bond based off of ZT defaults * @@ -77,7 +70,7 @@ public: * @param policyAlias * @param peer */ - Bond(std::string& basePolicy, std::string& policyAlias, const SharedPtr& peer); + Bond(const RuntimeEnvironment *renv, std::string& basePolicy, std::string& policyAlias, const SharedPtr& peer); /** * Constructor. Creates a bond based off of a user-defined bond template @@ -89,8 +82,7 @@ public: Bond(const RuntimeEnvironment *renv, const Bond &original, const SharedPtr& peer); /** - * - * @return + * @return The human-readable name of the bonding policy */ std::string policyAlias() { return _policyAlias; } diff --git a/node/BondController.hpp b/node/BondController.hpp index acc70d2ff..95fbf81fc 100644 --- a/node/BondController.hpp +++ b/node/BondController.hpp @@ -36,7 +36,7 @@ public: BondController(const RuntimeEnvironment *renv); /** - * @return The minimum interval required to poll the active bonds to fulfill all active monitoring timing requirements. + * @return Whether this slave is permitted to become a member of a bond. */ bool slaveAllowed(std::string &policyAlias, SharedPtr slave); @@ -46,7 +46,7 @@ public: int minReqPathMonitorInterval() { return _minReqPathMonitorInterval; } /** - * @return The minimum interval required to poll the active bonds to fulfill all active monitoring timing requirements. + * @param minReqPathMonitorInterval The minimum interval required to poll the active bonds to fulfill all active monitoring timing requirements. */ static void setMinReqPathMonitorInterval(int minReqPathMonitorInterval) { _minReqPathMonitorInterval = minReqPathMonitorInterval; } diff --git a/node/Path.hpp b/node/Path.hpp index 22a932edf..1cbd588bc 100644 --- a/node/Path.hpp +++ b/node/Path.hpp @@ -127,8 +127,7 @@ public: _packetsReceivedSinceLastQoS(0), _bytesAckedSinceLastThroughputEstimation(0), _packetsIn(0), - _packetsOut(0), - _prevEligibility(false) + _packetsOut(0) {} Path(const int64_t localSocket,const InetAddress &addr) : @@ -177,8 +176,7 @@ public: _packetsReceivedSinceLastQoS(0), _bytesAckedSinceLastThroughputEstimation(0), _packetsIn(0), - _packetsOut(0), - _prevEligibility(false) + _packetsOut(0) {} /** @@ -187,10 +185,10 @@ public: * @param t Time of receive */ inline void received(const uint64_t t) { - _lastIn = t; - if (!_prevEligibility) { + if (!alive(t,_bonded)) { _lastAliveToggle = _lastIn; } + _lastIn = t; } /** @@ -506,7 +504,7 @@ private: uint64_t _lastQoSMeasurement; /** - * Last time that a the path's throughput was estimated. + * Last time that the path's throughput was estimated. */ uint64_t _lastThroughputEstimation; @@ -531,7 +529,7 @@ private: uint64_t _lastTrialBegin; /** - * Amount of time that this path is prevented from becoming a member of a bond. + * Amount of time that this path will be prevented from becoming a member of a bond. */ uint32_t _refractoryPeriod; @@ -576,7 +574,7 @@ private: bool _bonded; /** - * Whether this path was intentionally _negotiated by either peer. + * Whether this path was intentionally negotiated by either peer. */ bool _negotiated; @@ -684,10 +682,6 @@ private: */ int _packetsIn; int _packetsOut; - - // TODO: Remove - - bool _prevEligibility; }; } // namespace ZeroTier diff --git a/service/OneService.cpp b/service/OneService.cpp index 04734d7e2..ab8594eec 100644 --- a/service/OneService.cpp +++ b/service/OneService.cpp @@ -1596,7 +1596,7 @@ public: continue; } // New bond, used as a copy template for new instances - SharedPtr newTemplateBond = new Bond(basePolicyStr, customPolicyStr, SharedPtr()); + SharedPtr newTemplateBond = new Bond(NULL, basePolicyStr, customPolicyStr, SharedPtr()); // Acceptable ranges newTemplateBond->setMaxAcceptableLatency(OSUtils::jsonInt(customPolicy["maxAcceptableLatency"],-1)); newTemplateBond->setMaxAcceptableMeanLatency(OSUtils::jsonInt(customPolicy["maxAcceptableMeanLatency"],-1));