mirror of
https://github.com/ZeroTier/ZeroTierOne
synced 2025-08-20 13:24:09 -07:00
Add new bond control commands to CLI
This commit is contained in:
parent
8af4eff43e
commit
ecfac0601a
7 changed files with 395 additions and 42 deletions
|
@ -414,6 +414,16 @@ bool Bond::assignFlowToBondedPath(SharedPtr<Flow> &flow, int64_t now)
|
|||
return false;
|
||||
}
|
||||
}
|
||||
if (_bondingPolicy == ZT_BONDING_POLICY_ACTIVE_BACKUP) {
|
||||
if (_abOverflowEnabled) {
|
||||
flow->assignPath(_abPath, now);
|
||||
} else {
|
||||
sprintf(traceMsg, "%s (bond) Unable to assign outgoing flow %x to peer %llx, no active overflow link",
|
||||
OSUtils::humanReadableTimestamp().c_str(), flow->id(), _peer->_id.address().toInt());
|
||||
RR->t->bondStateMessage(NULL, traceMsg);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
flow->assignedPath()->address().toString(curPathStr);
|
||||
SharedPtr<Link> link = RR->bc->getLinkBySocket(_policyAlias, flow->assignedPath()->localSocket());
|
||||
sprintf(traceMsg, "%s (bond) Assigned outgoing flow %x to peer %llx to link %s/%s, %lu active flow(s)",
|
||||
|
@ -1240,6 +1250,29 @@ void Bond::dequeueNextActiveBackupPath(const uint64_t now)
|
|||
}
|
||||
}
|
||||
|
||||
bool Bond::abForciblyRotateLink()
|
||||
{
|
||||
char traceMsg[256];
|
||||
char prevPathStr[128];
|
||||
char curPathStr[128];
|
||||
if (_bondingPolicy == ZT_BONDING_POLICY_ACTIVE_BACKUP) {
|
||||
SharedPtr<Path> prevPath = _abPath;
|
||||
_abPath->address().toString(prevPathStr);
|
||||
dequeueNextActiveBackupPath(RR->node->now());
|
||||
_abPath->address().toString(curPathStr);
|
||||
sprintf(traceMsg, "%s (active-backup) Forcibly rotating peer %llx link from %s/%s to %s/%s",
|
||||
OSUtils::humanReadableTimestamp().c_str(),
|
||||
_peer->_id.address().toInt(),
|
||||
getLink(prevPath)->ifname().c_str(),
|
||||
prevPathStr,
|
||||
getLink(_abPath)->ifname().c_str(),
|
||||
curPathStr);
|
||||
RR->t->bondStateMessage(NULL, traceMsg);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Bond::processActiveBackupTasks(void *tPtr, const int64_t now)
|
||||
{
|
||||
char traceMsg[256];
|
||||
|
@ -1302,9 +1335,9 @@ void Bond::processActiveBackupTasks(void *tPtr, const int64_t now)
|
|||
}
|
||||
}
|
||||
/**
|
||||
* [Manual mode]
|
||||
* The user has specified links or failover rules that the bonding policy should adhere to.
|
||||
*/
|
||||
* [Manual mode]
|
||||
* The user has specified links or failover rules that the bonding policy should adhere to.
|
||||
*/
|
||||
else if (userHasSpecifiedLinks()) {
|
||||
if (userHasSpecifiedPrimaryLink()) {
|
||||
//sprintf(traceMsg, "%s (active-backup) Checking local.conf for user-specified primary link\n", OSUtils::humanReadableTimestamp().c_str());
|
||||
|
@ -1507,7 +1540,7 @@ void Bond::processActiveBackupTasks(void *tPtr, const int64_t now)
|
|||
if (!bFoundPathInQueue) {
|
||||
_abFailoverQueue.push_front(_paths[i]);
|
||||
_paths[i]->address().toString(curPathStr);
|
||||
sprintf(traceMsg, "%s (active-backup) Added link %s/%s to peer %llx, there are %zu links in the queue",
|
||||
sprintf(traceMsg, "%s (active-backup) Added link %s/%s to peer %llx to failover queue, there are %zu links in the queue",
|
||||
OSUtils::humanReadableTimestamp().c_str(), getLink(_paths[i])->ifname().c_str(), curPathStr, _peer->_id.address().toInt(), _abFailoverQueue.size());
|
||||
RR->t->bondStateMessage(NULL, traceMsg);
|
||||
}
|
||||
|
@ -1747,7 +1780,7 @@ void Bond::setReasonableDefaults(int policy, SharedPtr<Bond> templateBond, bool
|
|||
them onto the defaults that were previously set */
|
||||
if (useTemplate) {
|
||||
_policyAlias = templateBond->_policyAlias;
|
||||
_failoverInterval = templateBond->_failoverInterval;
|
||||
_failoverInterval = templateBond->_failoverInterval >= 250 ? templateBond->_failoverInterval : _failoverInterval;
|
||||
_downDelay = templateBond->_downDelay;
|
||||
_upDelay = templateBond->_upDelay;
|
||||
if (templateBond->_linkMonitorStrategy == ZT_MULTIPATH_SLAVE_MONITOR_STRATEGY_PASSIVE
|
||||
|
|
|
@ -436,6 +436,11 @@ public:
|
|||
*/
|
||||
inline void setFailoverInterval(uint32_t interval) { _failoverInterval = interval; }
|
||||
|
||||
/**
|
||||
* @param interval Maximum amount of time user expects a failover to take on this bond.
|
||||
*/
|
||||
inline uint32_t getFailoverInterval() { return _failoverInterval; }
|
||||
|
||||
/**
|
||||
* @param strategy Strategy that the bond uses to re-assign protocol flows.
|
||||
*/
|
||||
|
@ -446,6 +451,11 @@ public:
|
|||
*/
|
||||
inline void setLinkMonitorStrategy(uint8_t strategy) { _linkMonitorStrategy = strategy; }
|
||||
|
||||
/**
|
||||
* @param abOverflowEnabled Whether "overflow" mode is enabled for this active-backup bond
|
||||
*/
|
||||
inline void setOverflowMode(bool abOverflowEnabled) { _abOverflowEnabled = abOverflowEnabled; }
|
||||
|
||||
/**
|
||||
* @return the current up delay parameter
|
||||
*/
|
||||
|
@ -520,6 +530,11 @@ public:
|
|||
*/
|
||||
inline void setPacketsPerLink(int packetsPerLink) { _packetsPerLink = packetsPerLink; }
|
||||
|
||||
/**
|
||||
* @return Number of packets to be sent on each interface in a balance-rr bond
|
||||
*/
|
||||
inline int getPacketsPerLink() { return _packetsPerLink; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @param linkSelectMethod
|
||||
|
@ -544,6 +559,15 @@ public:
|
|||
*/
|
||||
inline bool allowPathNegotiation() { return _allowPathNegotiation; }
|
||||
|
||||
/**
|
||||
* Forcibly rotates the currently active link used in an active-backup bond to the next link in the failover queue
|
||||
*
|
||||
* @return True if this operation succeeded, false if otherwise
|
||||
*/
|
||||
bool abForciblyRotateLink();
|
||||
|
||||
SharedPtr<Peer> getPeer() { return _peer; }
|
||||
|
||||
private:
|
||||
|
||||
const RuntimeEnvironment *RR;
|
||||
|
@ -587,6 +611,7 @@ private:
|
|||
SharedPtr<Path> _abPath; // current active path
|
||||
std::list<SharedPtr<Path> > _abFailoverQueue;
|
||||
uint8_t _abLinkSelectMethod; // link re-selection policy for the primary link in active-backup
|
||||
bool _abOverflowEnabled;
|
||||
|
||||
// balance-rr
|
||||
uint8_t _rrIdx; // index to path currently in use during Round Robin operation
|
||||
|
|
|
@ -76,6 +76,12 @@ bool BondController::assignBondingPolicyToPeer(int64_t identity, const std::stri
|
|||
return false;
|
||||
}
|
||||
|
||||
SharedPtr<Bond> BondController::getBondByPeerId(int64_t identity)
|
||||
{
|
||||
Mutex::Lock _l(_bonds_m);
|
||||
return _bonds.count(identity) ? _bonds[identity] : SharedPtr<Bond>();
|
||||
}
|
||||
|
||||
SharedPtr<Bond> BondController::createTransportTriggeredBond(const RuntimeEnvironment *renv, const SharedPtr<Peer>& peer)
|
||||
{
|
||||
Mutex::Lock _l(_bonds_m);
|
||||
|
|
|
@ -127,6 +127,14 @@ public:
|
|||
*/
|
||||
bool assignBondingPolicyToPeer(int64_t identity, const std::string& policyAlias);
|
||||
|
||||
/**
|
||||
* Get pointer to bond by a given peer ID
|
||||
*
|
||||
* @param peer Remote peer ID
|
||||
* @return A pointer to the Bond
|
||||
*/
|
||||
SharedPtr<Bond> getBondByPeerId(int64_t identity);
|
||||
|
||||
/**
|
||||
* Add a new bond to the bond controller.
|
||||
*
|
||||
|
|
|
@ -467,6 +467,32 @@ public:
|
|||
_packetsOut = 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The mean latency (computed from a sliding window.)
|
||||
*/
|
||||
float latencyMean() { return _latencyMean; }
|
||||
|
||||
/**
|
||||
* Packet delay variance (computed from a sliding window.)
|
||||
*/
|
||||
float latencyVariance() { return _latencyVariance; }
|
||||
|
||||
/**
|
||||
* The ratio of lost packets to received packets.
|
||||
*/
|
||||
float packetLossRatio() { return _packetLossRatio; }
|
||||
|
||||
/**
|
||||
* The ratio of packets that failed their MAC/CRC checks to those that did not.
|
||||
*/
|
||||
float packetErrorRatio() { return _packetErrorRatio; }
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
uint8_t allocation() { return _allocation; }
|
||||
|
||||
private:
|
||||
|
||||
volatile int64_t _lastOut;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue