Add basic bond health status reporting (listbonds)

This commit is contained in:
Joseph Henry 2020-07-27 23:01:12 -07:00
parent c92e030a4b
commit 9f4985b11a
6 changed files with 199 additions and 6 deletions

View file

@ -730,6 +730,9 @@ void Bond::curateBond(const int64_t now, bool rebuildBond)
{
//fprintf(stderr, "%lu curateBond (rebuildBond=%d), _numBondedPaths=%d\n", ((now - RR->bc->getBondStartTime())), rebuildBond, _numBondedPaths);
char pathStr[128];
uint8_t tmpNumAliveLinks = 0;
uint8_t tmpNumTotalLinks = 0;
/**
* Update path states
*/
@ -737,6 +740,10 @@ void Bond::curateBond(const int64_t now, bool rebuildBond)
if (!_paths[i]) {
continue;
}
tmpNumTotalLinks++;
if (_paths[i]->alive(now, true)) {
tmpNumAliveLinks++;
}
bool currEligibility = _paths[i]->eligible(now,_ackSendInterval);
//_paths[i]->address().toString(pathStr);
//fprintf(stderr, "\n\n%ld path eligibility (for %s, %s):\n", (RR->node->now() - RR->bc->getBondStartTime()), getLink(_paths[i])->ifname().c_str(), pathStr);
@ -764,6 +771,46 @@ void Bond::curateBond(const int64_t now, bool rebuildBond)
}
_paths[i]->_lastEligibilityState = currEligibility;
}
_numAliveLinks = tmpNumAliveLinks;
_numTotalLinks = tmpNumTotalLinks;
/* Determine health status to report to user */
bool tmpHealthStatus = true;
if (_bondingPolicy == ZT_BONDING_POLICY_ACTIVE_BACKUP) {
if (_numAliveLinks < 2) {
// Considered healthy if there is at least one failover link
tmpHealthStatus = false;
}
}
if (_bondingPolicy == ZT_BONDING_POLICY_BROADCAST) {
if (_numAliveLinks < 1) {
// Considerd healthy if we're able to send frames at all
tmpHealthStatus = false;
}
}
if (_bondingPolicy == ZT_BONDING_POLICY_BALANCE_RR) {
if (_numAliveLinks < _numTotalLinks) {
// Considerd healthy if all known paths are alive, this should be refined to account for user bond config settings
tmpHealthStatus = false;
}
}
if (_bondingPolicy == ZT_BONDING_POLICY_BALANCE_XOR) {
if (_numAliveLinks < _numTotalLinks) {
// Considerd healthy if all known paths are alive, this should be refined to account for user bond config settings
tmpHealthStatus = false;
}
}
if (_bondingPolicy == ZT_BONDING_POLICY_BALANCE_AWARE) {
if (_numAliveLinks < _numTotalLinks) {
// Considerd healthy if all known paths are alive, this should be refined to account for user bond config settings
tmpHealthStatus = false;
}
}
_isHealthy = tmpHealthStatus;
/**
* Curate the set of paths that are part of the bond proper. Selects a single path
* per logical link according to eligibility and user-specified constraints.
@ -1509,6 +1556,10 @@ void Bond::setReasonableDefaults(int policy, SharedPtr<Bond> templateBond, bool
_lastCheckUserPreferences = 0;
_lastBackgroundTaskCheck = 0;
_isHealthy = false;
_numAliveLinks = 0;
_numTotalLinks = 0;
_downDelay = 0;
_upDelay = 0;
_allowFlowHashing=false;

View file

@ -485,6 +485,21 @@ public:
*/
inline uint8_t getPolicy() { return _bondingPolicy; }
/**
* @return the health status of the bond
*/
inline bool isHealthy() { return _isHealthy; }
/**
* @return the number of links comprising this bond which are considered alive
*/
inline uint8_t getNumAliveLinks() { return _numAliveLinks; };
/**
* @return the number of links comprising this bond
*/
inline uint8_t getNumTotalLinks() { return _numTotalLinks; }
/**
*
* @param allowFlowHashing
@ -626,6 +641,10 @@ private:
uint16_t _maxAcceptablePacketDelayVariance;
uint8_t _minAcceptableAllocation;
bool _isHealthy;
uint8_t _numAliveLinks;
uint8_t _numTotalLinks;
/**
* Default initial punishment inflicted on misbehaving paths. Punishment slowly
* drains linearly. For each eligibility change the remaining punishment is doubled.

View file

@ -513,6 +513,9 @@ ZT_PeerList *Node::peers() const
if (pi->second->bond()) {
p->isBonded = pi->second->bond();
p->bondingPolicy = pi->second->bond()->getPolicy();
p->isHealthy = pi->second->bond()->isHealthy();
p->numAliveLinks = pi->second->bond()->getNumAliveLinks();
p->numTotalLinks = pi->second->bond()->getNumTotalLinks();
}
}