mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-04-08 11:44:13 +00:00
Merge branch 'dev' of github.com:zerotier/ZeroTierOne into dev
This commit is contained in:
commit
8bb5bc736d
75
.clang-format
Normal file
75
.clang-format
Normal file
@ -0,0 +1,75 @@
|
||||
---
|
||||
BasedOnStyle: LLVM
|
||||
BreakBeforeBraces: Stroustrup
|
||||
IndentWidth: 4
|
||||
TabWidth: 4
|
||||
AlignAfterOpenBracket: AlwaysBreak
|
||||
AlignConsecutiveMacros: 'true'
|
||||
AlignConsecutiveAssignments: 'false'
|
||||
AlignConsecutiveDeclarations: 'false'
|
||||
AlignEscapedNewlines: Right
|
||||
AlignOperands: 'true'
|
||||
AlignTrailingComments: 'true'
|
||||
AllowAllArgumentsOnNextLine: 'false'
|
||||
AllowAllConstructorInitializersOnNextLine: 'false'
|
||||
AllowAllParametersOfDeclarationOnNextLine: 'false'
|
||||
AllowShortBlocksOnASingleLine: 'true'
|
||||
AllowShortCaseLabelsOnASingleLine: 'false'
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AlwaysBreakAfterReturnType: None
|
||||
BinPackArguments: 'false'
|
||||
BinPackParameters: 'false'
|
||||
BreakBeforeBinaryOperators: NonAssignment
|
||||
BreakBeforeTernaryOperators: 'true'
|
||||
BreakConstructorInitializers: BeforeComma
|
||||
BreakInheritanceList: BeforeComma
|
||||
CompactNamespaces: 'false'
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
|
||||
ConstructorInitializerIndentWidth: '4'
|
||||
ContinuationIndentWidth: '4'
|
||||
Cpp11BracedListStyle: 'false'
|
||||
FixNamespaceComments: 'true'
|
||||
IncludeBlocks: Regroup
|
||||
IndentCaseLabels: 'true'
|
||||
IndentPPDirectives: None
|
||||
IndentWrappedFunctionNames: 'false'
|
||||
KeepEmptyLinesAtTheStartOfBlocks: 'false'
|
||||
MaxEmptyLinesToKeep: '1'
|
||||
NamespaceIndentation: None
|
||||
PointerAlignment: Left
|
||||
ReflowComments: 'true'
|
||||
SortIncludes: 'true'
|
||||
SortUsingDeclarations: 'true'
|
||||
SpaceAfterCStyleCast: 'false'
|
||||
SpaceAfterLogicalNot: 'true'
|
||||
SpaceAfterTemplateKeyword: 'true'
|
||||
SpaceBeforeAssignmentOperators: 'true'
|
||||
SpaceBeforeCpp11BracedList: 'true'
|
||||
SpaceBeforeCtorInitializerColon: 'true'
|
||||
SpaceBeforeInheritanceColon: 'true'
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeRangeBasedForLoopColon: 'true'
|
||||
SpaceInEmptyParentheses: 'false'
|
||||
SpacesBeforeTrailingComments: '3'
|
||||
SpacesInAngles: 'false'
|
||||
SpacesInCStyleCastParentheses: 'false'
|
||||
SpacesInContainerLiterals: 'true'
|
||||
SpacesInParentheses: 'false'
|
||||
SpacesInSquareBrackets: 'false'
|
||||
UseTab: 'Always'
|
||||
|
||||
---
|
||||
Language: Cpp
|
||||
Standard: Cpp03
|
||||
ColumnLimit: '240'
|
||||
---
|
||||
Language: ObjC
|
||||
ColumnLimit: '240'
|
||||
---
|
||||
Language: Java
|
||||
ColumnLimit: '240'
|
||||
---
|
||||
Language: CSharp
|
||||
ColumnLimit: '240'
|
||||
...
|
Binary file not shown.
Binary file not shown.
@ -112,7 +112,7 @@ one: $(CORE_OBJS) $(ONE_OBJS) one.o mac-agent
|
||||
zerotier-one: one
|
||||
|
||||
central-controller:
|
||||
make ZT_CONTROLLER=1 one
|
||||
make ARCH_FLAGS="-arch x86_64" ZT_CONTROLLER=1 one
|
||||
|
||||
zerotier-idtool: one
|
||||
|
||||
|
1037
node/Bond.cpp
1037
node/Bond.cpp
File diff suppressed because it is too large
Load Diff
269
node/Bond.hpp
269
node/Bond.hpp
@ -14,37 +14,36 @@
|
||||
#ifndef ZT_BOND_HPP
|
||||
#define ZT_BOND_HPP
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "Flow.hpp"
|
||||
#include "Packet.hpp"
|
||||
#include "Path.hpp"
|
||||
#include "Peer.hpp"
|
||||
#include "../osdep/Link.hpp"
|
||||
#include "Flow.hpp"
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
||||
namespace ZeroTier {
|
||||
|
||||
class RuntimeEnvironment;
|
||||
class Link;
|
||||
class Peer;
|
||||
|
||||
class Bond
|
||||
{
|
||||
class Bond {
|
||||
friend class SharedPtr<Bond>;
|
||||
friend class Peer;
|
||||
friend class BondController;
|
||||
|
||||
struct PathQualityComparator
|
||||
{
|
||||
bool operator ()(const SharedPtr<Path> & a, const SharedPtr<Path> & b)
|
||||
struct PathQualityComparator {
|
||||
bool operator()(const SharedPtr<Path>& a, const SharedPtr<Path>& b)
|
||||
{
|
||||
if(a->_failoverScore == b->_failoverScore) {
|
||||
if (a->_failoverScore == b->_failoverScore) {
|
||||
return a < b;
|
||||
}
|
||||
return a->_failoverScore > b->_failoverScore;
|
||||
}
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
public:
|
||||
// TODO: Remove
|
||||
bool _header;
|
||||
int64_t _lastLogTS;
|
||||
@ -61,7 +60,7 @@ public:
|
||||
* @param policy Bonding policy
|
||||
* @param peer
|
||||
*/
|
||||
Bond(const RuntimeEnvironment *renv, int policy, const SharedPtr<Peer>& peer);
|
||||
Bond(const RuntimeEnvironment* renv, int policy, const SharedPtr<Peer>& peer);
|
||||
|
||||
/**
|
||||
* Constructor. For use when user intends to manually specify parameters
|
||||
@ -70,7 +69,7 @@ public:
|
||||
* @param policyAlias
|
||||
* @param peer
|
||||
*/
|
||||
Bond(const RuntimeEnvironment *renv, std::string& basePolicy, std::string& policyAlias, const SharedPtr<Peer>& peer);
|
||||
Bond(const RuntimeEnvironment* renv, std::string& basePolicy, std::string& policyAlias, const SharedPtr<Peer>& peer);
|
||||
|
||||
/**
|
||||
* Constructor. Creates a bond based off of a user-defined bond template
|
||||
@ -79,12 +78,15 @@ public:
|
||||
* @param original
|
||||
* @param peer
|
||||
*/
|
||||
Bond(const RuntimeEnvironment *renv, SharedPtr<Bond> originalBond, const SharedPtr<Peer>& peer);
|
||||
Bond(const RuntimeEnvironment* renv, SharedPtr<Bond> originalBond, const SharedPtr<Peer>& peer);
|
||||
|
||||
/**
|
||||
* @return The human-readable name of the bonding policy
|
||||
*/
|
||||
std::string policyAlias() { return _policyAlias; }
|
||||
std::string policyAlias()
|
||||
{
|
||||
return _policyAlias;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inform the bond about the path that its peer (owning object) just learned about.
|
||||
@ -135,8 +137,7 @@ public:
|
||||
* @param flowId Flow ID
|
||||
* @param now Current time
|
||||
*/
|
||||
void recordOutgoingPacket(const SharedPtr<Path> &path, uint64_t packetId,
|
||||
uint16_t payloadLength, Packet::Verb verb, int32_t flowId, int64_t now);
|
||||
void recordOutgoingPacket(const SharedPtr<Path>& path, uint64_t packetId, uint16_t payloadLength, Packet::Verb verb, int32_t flowId, int64_t now);
|
||||
|
||||
/**
|
||||
* Process the contents of an inbound VERB_QOS_MEASUREMENT to gather path quality observations.
|
||||
@ -146,7 +147,7 @@ public:
|
||||
* @param rx_id table of packet IDs
|
||||
* @param rx_ts table of holding times
|
||||
*/
|
||||
void receivedQoS(const SharedPtr<Path>& path, int64_t now, int count, uint64_t *rx_id, uint16_t *rx_ts);
|
||||
void receivedQoS(const SharedPtr<Path>& path, int64_t now, int count, uint64_t* rx_id, uint16_t* rx_ts);
|
||||
|
||||
/**
|
||||
* Process the contents of an inbound VERB_ACK to gather path quality observations.
|
||||
@ -164,7 +165,7 @@ public:
|
||||
* @param qosBuffer destination buffer
|
||||
* @return Size of payload
|
||||
*/
|
||||
int32_t generateQoSPacket(const SharedPtr<Path>& path, int64_t now, char *qosBuffer);
|
||||
int32_t generateQoSPacket(const SharedPtr<Path>& path, int64_t now, char* qosBuffer);
|
||||
|
||||
/**
|
||||
* Record statistics for an inbound packet.
|
||||
@ -176,8 +177,7 @@ public:
|
||||
* @param flowId Flow ID
|
||||
* @param now Current time
|
||||
*/
|
||||
void recordIncomingPacket(const SharedPtr<Path>& path, uint64_t packetId, uint16_t payloadLength,
|
||||
Packet::Verb verb, int32_t flowId, int64_t now);
|
||||
void recordIncomingPacket(const SharedPtr<Path>& path, uint64_t packetId, uint16_t payloadLength, Packet::Verb verb, int32_t flowId, int64_t now);
|
||||
|
||||
/**
|
||||
* Determines the most appropriate path for packet and flow egress. This decision is made by
|
||||
@ -198,7 +198,7 @@ public:
|
||||
* @param now Current time
|
||||
* @return Pointer to newly-created Flow
|
||||
*/
|
||||
SharedPtr<Flow> createFlow(const SharedPtr<Path> &path, int32_t flowId, unsigned char entropy, int64_t now);
|
||||
SharedPtr<Flow> createFlow(const SharedPtr<Path>& path, int32_t flowId, unsigned char entropy, int64_t now);
|
||||
|
||||
/**
|
||||
* Removes flow records that are past a certain age limit.
|
||||
@ -215,7 +215,7 @@ public:
|
||||
* @param flow Flow to be assigned
|
||||
* @param now Current time
|
||||
*/
|
||||
bool assignFlowToBondedPath(SharedPtr<Flow> &flow, int64_t now);
|
||||
bool assignFlowToBondedPath(SharedPtr<Flow>& flow, int64_t now);
|
||||
|
||||
/**
|
||||
* Determine whether a path change should occur given the remote peer's reported utility and our
|
||||
@ -226,7 +226,7 @@ public:
|
||||
* @param path Path over which the negotiation request was received
|
||||
* @param remoteUtility How much utility the remote peer claims to gain by using the declared path
|
||||
*/
|
||||
void processIncomingPathNegotiationRequest(uint64_t now, SharedPtr<Path> &path, int16_t remoteUtility);
|
||||
void processIncomingPathNegotiationRequest(uint64_t now, SharedPtr<Path>& path, int16_t remoteUtility);
|
||||
|
||||
/**
|
||||
* Determine state of path synchronization and whether a negotiation request
|
||||
@ -235,7 +235,7 @@ public:
|
||||
* @param tPtr Thread pointer to be handed through to any callbacks called as a result of this call
|
||||
* @param now Current time
|
||||
*/
|
||||
void pathNegotiationCheck(void *tPtr, const int64_t now);
|
||||
void pathNegotiationCheck(void* tPtr, const int64_t now);
|
||||
|
||||
/**
|
||||
* Sends a VERB_ACK to the remote peer.
|
||||
@ -246,8 +246,7 @@ public:
|
||||
* @param atAddress
|
||||
* @param now Current time
|
||||
*/
|
||||
void sendACK(void *tPtr, const SharedPtr<Path> &path,int64_t localSocket,
|
||||
const InetAddress &atAddress,int64_t now);
|
||||
void sendACK(void* tPtr, const SharedPtr<Path>& path, int64_t localSocket, const InetAddress& atAddress, int64_t now);
|
||||
|
||||
/**
|
||||
* Sends a VERB_QOS_MEASUREMENT to the remote peer.
|
||||
@ -258,8 +257,7 @@ public:
|
||||
* @param atAddress
|
||||
* @param now Current time
|
||||
*/
|
||||
void sendQOS_MEASUREMENT(void *tPtr,const SharedPtr<Path> &path,int64_t localSocket,
|
||||
const InetAddress &atAddress,int64_t now);
|
||||
void sendQOS_MEASUREMENT(void* tPtr, const SharedPtr<Path>& path, int64_t localSocket, const InetAddress& atAddress, int64_t now);
|
||||
|
||||
/**
|
||||
* Sends a VERB_PATH_NEGOTIATION_REQUEST to the remote peer.
|
||||
@ -267,7 +265,7 @@ public:
|
||||
* @param tPtr Thread pointer to be handed through to any callbacks called as a result of this call
|
||||
* @param path Path over which packet should be sent
|
||||
*/
|
||||
void sendPATH_NEGOTIATION_REQUEST(void *tPtr, const SharedPtr<Path> &path);
|
||||
void sendPATH_NEGOTIATION_REQUEST(void* tPtr, const SharedPtr<Path>& path);
|
||||
|
||||
/**
|
||||
*
|
||||
@ -281,7 +279,7 @@ public:
|
||||
* @param tPtr Thread pointer to be handed through to any callbacks called as a result of this call
|
||||
* @param now Current time
|
||||
*/
|
||||
void processActiveBackupTasks(void *tPtr, int64_t now);
|
||||
void processActiveBackupTasks(void* tPtr, int64_t now);
|
||||
|
||||
/**
|
||||
* Switches the active link in an active-backup scenario to the next best during
|
||||
@ -311,64 +309,82 @@ public:
|
||||
/**
|
||||
* @param latencyInMilliseconds Maximum acceptable latency.
|
||||
*/
|
||||
void setMaxAcceptableLatency(int16_t latencyInMilliseconds) {
|
||||
void setMaxAcceptableLatency(int16_t latencyInMilliseconds)
|
||||
{
|
||||
_maxAcceptableLatency = latencyInMilliseconds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param latencyInMilliseconds Maximum acceptable (mean) latency.
|
||||
*/
|
||||
void setMaxAcceptableMeanLatency(int16_t latencyInMilliseconds) {
|
||||
void setMaxAcceptableMeanLatency(int16_t latencyInMilliseconds)
|
||||
{
|
||||
_maxAcceptableMeanLatency = latencyInMilliseconds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param latencyVarianceInMilliseconds Maximum acceptable packet delay variance (jitter).
|
||||
*/
|
||||
void setMaxAcceptablePacketDelayVariance(int16_t latencyVarianceInMilliseconds) {
|
||||
void setMaxAcceptablePacketDelayVariance(int16_t latencyVarianceInMilliseconds)
|
||||
{
|
||||
_maxAcceptablePacketDelayVariance = latencyVarianceInMilliseconds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param lossRatio Maximum acceptable packet loss ratio (PLR).
|
||||
*/
|
||||
void setMaxAcceptablePacketLossRatio(float lossRatio) {
|
||||
void setMaxAcceptablePacketLossRatio(float lossRatio)
|
||||
{
|
||||
_maxAcceptablePacketLossRatio = lossRatio;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param errorRatio Maximum acceptable packet error ratio (PER).
|
||||
*/
|
||||
void setMaxAcceptablePacketErrorRatio(float errorRatio) {
|
||||
void setMaxAcceptablePacketErrorRatio(float errorRatio)
|
||||
{
|
||||
_maxAcceptablePacketErrorRatio = errorRatio;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param errorRatio Maximum acceptable packet error ratio (PER).
|
||||
*/
|
||||
void setMinAcceptableAllocation(float minAlloc) {
|
||||
_minAcceptableAllocation = minAlloc * 255;
|
||||
void setMinAcceptableAllocation(float minAlloc)
|
||||
{
|
||||
_minAcceptableAllocation = (uint8_t)(minAlloc * 255);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Whether the user has defined links for use on this bond
|
||||
*/
|
||||
inline bool userHasSpecifiedLinks() { return _userHasSpecifiedLinks; }
|
||||
inline bool userHasSpecifiedLinks()
|
||||
{
|
||||
return _userHasSpecifiedLinks;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Whether the user has defined a set of failover link(s) for this bond
|
||||
*/
|
||||
inline bool userHasSpecifiedFailoverInstructions() { return _userHasSpecifiedFailoverInstructions; };
|
||||
inline bool userHasSpecifiedFailoverInstructions()
|
||||
{
|
||||
return _userHasSpecifiedFailoverInstructions;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return Whether the user has specified a primary link
|
||||
*/
|
||||
inline bool userHasSpecifiedPrimaryLink() { return _userHasSpecifiedPrimaryLink; }
|
||||
inline bool userHasSpecifiedPrimaryLink()
|
||||
{
|
||||
return _userHasSpecifiedPrimaryLink;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Whether the user has specified link speeds
|
||||
*/
|
||||
inline bool userHasSpecifiedLinkSpeeds() { return _userHasSpecifiedLinkSpeeds; }
|
||||
inline bool userHasSpecifiedLinkSpeeds()
|
||||
{
|
||||
return _userHasSpecifiedLinkSpeeds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Periodically perform maintenance tasks for each active bond.
|
||||
@ -376,7 +392,7 @@ public:
|
||||
* @param tPtr Thread pointer to be handed through to any callbacks called as a result of this call
|
||||
* @param now Current time
|
||||
*/
|
||||
void processBackgroundTasks(void *tPtr, int64_t now);
|
||||
void processBackgroundTasks(void* tPtr, int64_t now);
|
||||
|
||||
/**
|
||||
* Rate limit gate for VERB_ACK
|
||||
@ -387,11 +403,12 @@ public:
|
||||
inline bool rateGateACK(const int64_t now)
|
||||
{
|
||||
_ackCutoffCount++;
|
||||
int numToDrain = _lastAckRateCheck ? (now - _lastAckRateCheck) / ZT_ACK_DRAINAGE_DIVISOR : _ackCutoffCount;
|
||||
int numToDrain = _lastAckRateCheck ? (now - _lastAckRateCheck) / ZT_ACK_DRAINAGE_DIVISOR : _ackCutoffCount;
|
||||
_lastAckRateCheck = now;
|
||||
if (_ackCutoffCount > numToDrain) {
|
||||
_ackCutoffCount-=numToDrain;
|
||||
} else {
|
||||
_ackCutoffCount -= numToDrain;
|
||||
}
|
||||
else {
|
||||
_ackCutoffCount = 0;
|
||||
}
|
||||
return (_ackCutoffCount < ZT_ACK_CUTOFF_LIMIT);
|
||||
@ -409,8 +426,9 @@ public:
|
||||
int numToDrain = (now - _lastQoSRateCheck) / ZT_QOS_DRAINAGE_DIVISOR;
|
||||
_lastQoSRateCheck = now;
|
||||
if (_qosCutoffCount > numToDrain) {
|
||||
_qosCutoffCount-=numToDrain;
|
||||
} else {
|
||||
_qosCutoffCount -= numToDrain;
|
||||
}
|
||||
else {
|
||||
_qosCutoffCount = 0;
|
||||
}
|
||||
return (_qosCutoffCount < ZT_QOS_CUTOFF_LIMIT);
|
||||
@ -426,7 +444,8 @@ public:
|
||||
{
|
||||
if ((now - _lastPathNegotiationReceived) <= ZT_PATH_NEGOTIATION_CUTOFF_TIME)
|
||||
++_pathNegotiationCutoffCount;
|
||||
else _pathNegotiationCutoffCount = 0;
|
||||
else
|
||||
_pathNegotiationCutoffCount = 0;
|
||||
_lastPathNegotiationReceived = now;
|
||||
return (_pathNegotiationCutoffCount < ZT_PATH_NEGOTIATION_CUTOFF_LIMIT);
|
||||
}
|
||||
@ -434,130 +453,206 @@ public:
|
||||
/**
|
||||
* @param interval Maximum amount of time user expects a failover to take on this bond.
|
||||
*/
|
||||
inline void setFailoverInterval(uint32_t interval) { _failoverInterval = interval; }
|
||||
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; }
|
||||
inline uint32_t getFailoverInterval()
|
||||
{
|
||||
return _failoverInterval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param strategy Strategy that the bond uses to re-assign protocol flows.
|
||||
*/
|
||||
inline void setFlowRebalanceStrategy(uint32_t strategy) { _flowRebalanceStrategy = strategy; }
|
||||
inline void setFlowRebalanceStrategy(uint32_t strategy)
|
||||
{
|
||||
_flowRebalanceStrategy = strategy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param strategy Strategy that the bond uses to prob for path aliveness and quality
|
||||
*/
|
||||
inline void setLinkMonitorStrategy(uint8_t strategy) { _linkMonitorStrategy = strategy; }
|
||||
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; }
|
||||
inline void setOverflowMode(bool abOverflowEnabled)
|
||||
{
|
||||
_abOverflowEnabled = abOverflowEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the current up delay parameter
|
||||
*/
|
||||
inline uint16_t getUpDelay() { return _upDelay; }
|
||||
inline uint16_t getUpDelay()
|
||||
{
|
||||
return _upDelay;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param upDelay Length of time before a newly-discovered path is admitted to the bond
|
||||
*/
|
||||
inline void setUpDelay(int upDelay) { if (upDelay >= 0) { _upDelay = upDelay; } }
|
||||
inline void setUpDelay(int upDelay)
|
||||
{
|
||||
if (upDelay >= 0) {
|
||||
_upDelay = upDelay;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Length of time before a newly-failed path is removed from the bond
|
||||
*/
|
||||
inline uint16_t getDownDelay() { return _downDelay; }
|
||||
inline uint16_t getDownDelay()
|
||||
{
|
||||
return _downDelay;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param downDelay Length of time before a newly-failed path is removed from the bond
|
||||
*/
|
||||
inline void setDownDelay(int downDelay) { if (downDelay >= 0) { _downDelay = downDelay; } }
|
||||
inline void setDownDelay(int downDelay)
|
||||
{
|
||||
if (downDelay >= 0) {
|
||||
_downDelay = downDelay;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the current monitoring interval for the bond (can be overridden with intervals specific to certain links.)
|
||||
*/
|
||||
inline uint16_t getBondMonitorInterval() { return _bondMonitorInterval; }
|
||||
inline uint16_t getBondMonitorInterval()
|
||||
{
|
||||
return _bondMonitorInterval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current monitoring interval for the bond (can be overridden with intervals specific to certain links.)
|
||||
*
|
||||
* @param monitorInterval How often gratuitous VERB_HELLO(s) are sent to remote peer.
|
||||
*/
|
||||
inline void setBondMonitorInterval(uint16_t interval) { _bondMonitorInterval = interval; }
|
||||
inline void setBondMonitorInterval(uint16_t interval)
|
||||
{
|
||||
_bondMonitorInterval = interval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param policy Bonding policy for this bond
|
||||
*/
|
||||
inline void setPolicy(uint8_t policy) { _bondingPolicy = policy; }
|
||||
inline void setPolicy(uint8_t policy)
|
||||
{
|
||||
_bondingPolicy = policy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the current bonding policy
|
||||
*/
|
||||
inline uint8_t getPolicy() { return _bondingPolicy; }
|
||||
inline uint8_t getPolicy()
|
||||
{
|
||||
return _bondingPolicy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the health status of the bond
|
||||
*/
|
||||
inline bool isHealthy() { return _isHealthy; }
|
||||
inline bool isHealthy()
|
||||
{
|
||||
return _isHealthy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the number of links comprising this bond which are considered alive
|
||||
*/
|
||||
inline uint8_t getNumAliveLinks() { return _numAliveLinks; };
|
||||
inline uint8_t getNumAliveLinks()
|
||||
{
|
||||
return _numAliveLinks;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return the number of links comprising this bond
|
||||
*/
|
||||
inline uint8_t getNumTotalLinks() { return _numTotalLinks; }
|
||||
inline uint8_t getNumTotalLinks()
|
||||
{
|
||||
return _numTotalLinks;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param allowFlowHashing
|
||||
*/
|
||||
inline void setFlowHashing(bool allowFlowHashing) { _allowFlowHashing = allowFlowHashing; }
|
||||
inline void setFlowHashing(bool allowFlowHashing)
|
||||
{
|
||||
_allowFlowHashing = allowFlowHashing;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Whether flow-hashing is currently enabled for this bond.
|
||||
*/
|
||||
bool flowHashingEnabled() { return _allowFlowHashing; }
|
||||
bool flowHashingEnabled()
|
||||
{
|
||||
return _allowFlowHashing;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param packetsPerLink
|
||||
*/
|
||||
inline void setPacketsPerLink(int packetsPerLink) { _packetsPerLink = packetsPerLink; }
|
||||
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; }
|
||||
inline int getPacketsPerLink()
|
||||
{
|
||||
return _packetsPerLink;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param linkSelectMethod
|
||||
*/
|
||||
inline void setLinkSelectMethod(uint8_t method) { _abLinkSelectMethod = method; }
|
||||
inline void setLinkSelectMethod(uint8_t method)
|
||||
{
|
||||
_abLinkSelectMethod = method;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
inline uint8_t getLinkSelectMethod() { return _abLinkSelectMethod; }
|
||||
inline uint8_t getLinkSelectMethod()
|
||||
{
|
||||
return _abLinkSelectMethod;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param allowPathNegotiation
|
||||
*/
|
||||
inline void setAllowPathNegotiation(bool allowPathNegotiation) { _allowPathNegotiation = allowPathNegotiation; }
|
||||
inline void setAllowPathNegotiation(bool allowPathNegotiation)
|
||||
{
|
||||
_allowPathNegotiation = allowPathNegotiation;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
inline bool allowPathNegotiation() { return _allowPathNegotiation; }
|
||||
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
|
||||
@ -566,11 +661,13 @@ public:
|
||||
*/
|
||||
bool abForciblyRotateLink();
|
||||
|
||||
SharedPtr<Peer> getPeer() { return _peer; }
|
||||
SharedPtr<Peer> getPeer()
|
||||
{
|
||||
return _peer;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
const RuntimeEnvironment *RR;
|
||||
private:
|
||||
const RuntimeEnvironment* RR;
|
||||
AtomicCounter __refCount;
|
||||
|
||||
/**
|
||||
@ -599,23 +696,23 @@ private:
|
||||
/**
|
||||
* Flows hashed according to port and protocol
|
||||
*/
|
||||
std::map<int32_t,SharedPtr<Flow> > _flows;
|
||||
std::map<int32_t, SharedPtr<Flow> > _flows;
|
||||
|
||||
float _qualityWeights[ZT_QOS_WEIGHT_SIZE]; // How much each factor contributes to the "quality" score of a path.
|
||||
float _qualityWeights[ZT_QOS_WEIGHT_SIZE]; // How much each factor contributes to the "quality" score of a path.
|
||||
|
||||
uint8_t _bondingPolicy;
|
||||
uint32_t _upDelay;
|
||||
uint32_t _downDelay;
|
||||
|
||||
// active-backup
|
||||
SharedPtr<Path> _abPath; // current active path
|
||||
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
|
||||
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
|
||||
uint16_t _rrPacketsSentOnCurrLink; // number of packets sent on this link since the most recent path switch.
|
||||
uint8_t _rrIdx; // index to path currently in use during Round Robin operation
|
||||
uint16_t _rrPacketsSentOnCurrLink; // number of packets sent on this link since the most recent path switch.
|
||||
/**
|
||||
* How many packets will be sent on a path before moving to the next path
|
||||
* in the round-robin sequence. A value of zero will cause a random path
|
||||
@ -745,6 +842,6 @@ private:
|
||||
bool _allowFlowHashing;
|
||||
};
|
||||
|
||||
} // namespace ZeroTier
|
||||
} // namespace ZeroTier
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -11,25 +11,25 @@
|
||||
*/
|
||||
/****/
|
||||
|
||||
#include "../osdep/OSUtils.hpp"
|
||||
|
||||
#include "Constants.hpp"
|
||||
#include "BondController.hpp"
|
||||
#include "Peer.hpp"
|
||||
|
||||
#include "../osdep/OSUtils.hpp"
|
||||
#include "Bond.hpp"
|
||||
#include "Node.hpp"
|
||||
#include "RuntimeEnvironment.hpp"
|
||||
|
||||
namespace ZeroTier {
|
||||
|
||||
int BondController::_minReqPathMonitorInterval;
|
||||
uint8_t BondController::_defaultBondingPolicy;
|
||||
|
||||
BondController::BondController(const RuntimeEnvironment *renv) :
|
||||
RR(renv)
|
||||
BondController::BondController(const RuntimeEnvironment* renv) : RR(renv)
|
||||
{
|
||||
bondStartTime = RR->node->now();
|
||||
_defaultBondingPolicy = ZT_BONDING_POLICY_NONE;
|
||||
}
|
||||
|
||||
bool BondController::linkAllowed(std::string &policyAlias, SharedPtr<Link> link)
|
||||
bool BondController::linkAllowed(std::string& policyAlias, SharedPtr<Link> link)
|
||||
{
|
||||
bool foundInDefinitions = false;
|
||||
if (_linkDefinitions.count(policyAlias)) {
|
||||
@ -52,14 +52,14 @@ void BondController::addCustomLink(std::string& policyAlias, SharedPtr<Link> lin
|
||||
auto search = _interfaceToLinkMap[policyAlias].find(link->ifname());
|
||||
if (search == _interfaceToLinkMap[policyAlias].end()) {
|
||||
link->setAsUserSpecified(true);
|
||||
_interfaceToLinkMap[policyAlias].insert(std::pair<std::string, SharedPtr<Link>>(link->ifname(), link));
|
||||
_interfaceToLinkMap[policyAlias].insert(std::pair<std::string, SharedPtr<Link> >(link->ifname(), link));
|
||||
}
|
||||
}
|
||||
|
||||
bool BondController::addCustomPolicy(const SharedPtr<Bond>& newBond)
|
||||
{
|
||||
Mutex::Lock _l(_bonds_m);
|
||||
if (!_bondPolicyTemplates.count(newBond->policyAlias())) {
|
||||
if (! _bondPolicyTemplates.count(newBond->policyAlias())) {
|
||||
_bondPolicyTemplates[newBond->policyAlias()] = newBond;
|
||||
return true;
|
||||
}
|
||||
@ -69,7 +69,7 @@ bool BondController::addCustomPolicy(const SharedPtr<Bond>& newBond)
|
||||
bool BondController::assignBondingPolicyToPeer(int64_t identity, const std::string& policyAlias)
|
||||
{
|
||||
Mutex::Lock _l(_bonds_m);
|
||||
if (!_policyTemplateAssignments.count(identity)) {
|
||||
if (! _policyTemplateAssignments.count(identity)) {
|
||||
_policyTemplateAssignments[identity] = policyAlias;
|
||||
return true;
|
||||
}
|
||||
@ -82,37 +82,40 @@ SharedPtr<Bond> BondController::getBondByPeerId(int64_t identity)
|
||||
return _bonds.count(identity) ? _bonds[identity] : SharedPtr<Bond>();
|
||||
}
|
||||
|
||||
SharedPtr<Bond> BondController::createTransportTriggeredBond(const RuntimeEnvironment *renv, const SharedPtr<Peer>& peer)
|
||||
SharedPtr<Bond> BondController::createTransportTriggeredBond(const RuntimeEnvironment* renv, const SharedPtr<Peer>& peer)
|
||||
{
|
||||
Mutex::Lock _l(_bonds_m);
|
||||
int64_t identity = peer->identity().address().toInt();
|
||||
Bond *bond = nullptr;
|
||||
Bond* bond = nullptr;
|
||||
char traceMsg[128];
|
||||
if (!_bonds.count(identity)) {
|
||||
if (! _bonds.count(identity)) {
|
||||
std::string policyAlias;
|
||||
if (!_policyTemplateAssignments.count(identity)) {
|
||||
if (! _policyTemplateAssignments.count(identity)) {
|
||||
if (_defaultBondingPolicy) {
|
||||
sprintf(traceMsg, "%s (bond) Creating new default %s bond to peer %llx",
|
||||
OSUtils::humanReadableTimestamp().c_str(), getPolicyStrByCode(_defaultBondingPolicy).c_str(), identity); RR->t->bondStateMessage(NULL, traceMsg);
|
||||
sprintf(traceMsg, "%s (bond) Creating new default %s bond to peer %llx", OSUtils::humanReadableTimestamp().c_str(), getPolicyStrByCode(_defaultBondingPolicy).c_str(), (unsigned long long)identity);
|
||||
RR->t->bondStateMessage(NULL, traceMsg);
|
||||
bond = new Bond(renv, _defaultBondingPolicy, peer);
|
||||
}
|
||||
if (!_defaultBondingPolicy && _defaultBondingPolicyStr.length()) {
|
||||
sprintf(traceMsg, "%s (bond) Creating new default custom %s bond to peer %llx",
|
||||
OSUtils::humanReadableTimestamp().c_str(), _defaultBondingPolicyStr.c_str(), identity);
|
||||
if (! _defaultBondingPolicy && _defaultBondingPolicyStr.length()) {
|
||||
sprintf(traceMsg, "%s (bond) Creating new default custom %s bond to peer %llx", OSUtils::humanReadableTimestamp().c_str(), _defaultBondingPolicyStr.c_str(), (unsigned long long)identity);
|
||||
RR->t->bondStateMessage(NULL, traceMsg);
|
||||
bond = new Bond(renv, _bondPolicyTemplates[_defaultBondingPolicyStr].ptr(), peer);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!_bondPolicyTemplates[_policyTemplateAssignments[identity]]) {
|
||||
sprintf(traceMsg, "%s (bond) Creating new bond. Assignment for peer %llx was specified as %s but the bond definition was not found. Using default %s",
|
||||
OSUtils::humanReadableTimestamp().c_str(), identity, _policyTemplateAssignments[identity].c_str(), getPolicyStrByCode(_defaultBondingPolicy).c_str());
|
||||
if (! _bondPolicyTemplates[_policyTemplateAssignments[identity]]) {
|
||||
sprintf(
|
||||
traceMsg,
|
||||
"%s (bond) Creating new bond. Assignment for peer %llx was specified as %s but the bond definition was not found. Using default %s",
|
||||
OSUtils::humanReadableTimestamp().c_str(),
|
||||
(unsigned long long)identity,
|
||||
_policyTemplateAssignments[identity].c_str(),
|
||||
getPolicyStrByCode(_defaultBondingPolicy).c_str());
|
||||
RR->t->bondStateMessage(NULL, traceMsg);
|
||||
bond = new Bond(renv, _defaultBondingPolicy, peer);
|
||||
}
|
||||
else {
|
||||
sprintf(traceMsg, "%s (bond) Creating new default bond %s to peer %llx",
|
||||
OSUtils::humanReadableTimestamp().c_str(), _defaultBondingPolicyStr.c_str(), identity);
|
||||
sprintf(traceMsg, "%s (bond) Creating new default bond %s to peer %llx", OSUtils::humanReadableTimestamp().c_str(), _defaultBondingPolicyStr.c_str(), (unsigned long long)identity);
|
||||
RR->t->bondStateMessage(NULL, traceMsg);
|
||||
bond = new Bond(renv, _bondPolicyTemplates[_policyTemplateAssignments[identity]].ptr(), peer);
|
||||
}
|
||||
@ -150,12 +153,12 @@ SharedPtr<Link> BondController::getLinkBySocket(const std::string& policyAlias,
|
||||
{
|
||||
Mutex::Lock _l(_links_m);
|
||||
char ifname[16];
|
||||
_phy->getIfName((PhySocket *) ((uintptr_t)localSocket), ifname, 16);
|
||||
_phy->getIfName((PhySocket*)((uintptr_t)localSocket), ifname, 16);
|
||||
std::string ifnameStr(ifname);
|
||||
auto search = _interfaceToLinkMap[policyAlias].find(ifnameStr);
|
||||
if (search == _interfaceToLinkMap[policyAlias].end()) {
|
||||
SharedPtr<Link> s = new Link(ifnameStr, 0, 0, 0, 0, 0, true, ZT_MULTIPATH_SLAVE_MODE_SPARE, "", 0.0);
|
||||
_interfaceToLinkMap[policyAlias].insert(std::pair<std::string,SharedPtr<Link> >(ifnameStr, s));
|
||||
_interfaceToLinkMap[policyAlias].insert(std::pair<std::string, SharedPtr<Link> >(ifnameStr, s));
|
||||
return s;
|
||||
}
|
||||
else {
|
||||
@ -199,14 +202,14 @@ bool BondController::allowedToBind(const std::string& ifname)
|
||||
*/
|
||||
}
|
||||
|
||||
void BondController::processBackgroundTasks(void *tPtr, const int64_t now)
|
||||
void BondController::processBackgroundTasks(void* tPtr, const int64_t now)
|
||||
{
|
||||
Mutex::Lock _l(_bonds_m);
|
||||
std::map<int64_t,SharedPtr<Bond> >::iterator bondItr = _bonds.begin();
|
||||
std::map<int64_t, SharedPtr<Bond> >::iterator bondItr = _bonds.begin();
|
||||
while (bondItr != _bonds.end()) {
|
||||
bondItr->second->processBackgroundTasks(tPtr, now);
|
||||
++bondItr;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ZeroTier
|
||||
} // namespace ZeroTier
|
||||
|
@ -14,46 +14,54 @@
|
||||
#ifndef ZT_BONDCONTROLLER_HPP
|
||||
#define ZT_BONDCONTROLLER_HPP
|
||||
|
||||
#include "../osdep/Link.hpp"
|
||||
#include "../osdep/Phy.hpp"
|
||||
#include "SharedPtr.hpp"
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include "SharedPtr.hpp"
|
||||
#include "../osdep/Phy.hpp"
|
||||
#include "../osdep/Link.hpp"
|
||||
|
||||
namespace ZeroTier {
|
||||
|
||||
class RuntimeEnvironment;
|
||||
class Bond;
|
||||
class Peer;
|
||||
class Mutex;
|
||||
|
||||
class BondController
|
||||
{
|
||||
class BondController {
|
||||
friend class Bond;
|
||||
|
||||
public:
|
||||
|
||||
BondController(const RuntimeEnvironment *renv);
|
||||
public:
|
||||
BondController(const RuntimeEnvironment* renv);
|
||||
|
||||
/**
|
||||
* @return Whether this link is permitted to become a member of a bond.
|
||||
*/
|
||||
bool linkAllowed(std::string &policyAlias, SharedPtr<Link> link);
|
||||
bool linkAllowed(std::string& policyAlias, SharedPtr<Link> link);
|
||||
|
||||
/**
|
||||
* @return The minimum interval required to poll the active bonds to fulfill all active monitoring timing requirements.
|
||||
*/
|
||||
int minReqPathMonitorInterval() { return _minReqPathMonitorInterval; }
|
||||
int minReqPathMonitorInterval()
|
||||
{
|
||||
return _minReqPathMonitorInterval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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; }
|
||||
static void setMinReqPathMonitorInterval(int minReqPathMonitorInterval)
|
||||
{
|
||||
_minReqPathMonitorInterval = minReqPathMonitorInterval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Whether the bonding layer is currently set up to be used.
|
||||
*/
|
||||
bool inUse() { return !_bondPolicyTemplates.empty() || _defaultBondingPolicy; }
|
||||
bool inUse()
|
||||
{
|
||||
return ! _bondPolicyTemplates.empty() || _defaultBondingPolicy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param basePolicyName Bonding policy name (See ZeroTierOne.h)
|
||||
@ -61,12 +69,22 @@ public:
|
||||
*/
|
||||
static int getPolicyCodeByStr(const std::string& basePolicyName)
|
||||
{
|
||||
if (basePolicyName == "active-backup") { return 1; }
|
||||
if (basePolicyName == "broadcast") { return 2; }
|
||||
if (basePolicyName == "balance-rr") { return 3; }
|
||||
if (basePolicyName == "balance-xor") { return 4; }
|
||||
if (basePolicyName == "balance-aware") { return 5; }
|
||||
return 0; // "none"
|
||||
if (basePolicyName == "active-backup") {
|
||||
return 1;
|
||||
}
|
||||
if (basePolicyName == "broadcast") {
|
||||
return 2;
|
||||
}
|
||||
if (basePolicyName == "balance-rr") {
|
||||
return 3;
|
||||
}
|
||||
if (basePolicyName == "balance-xor") {
|
||||
return 4;
|
||||
}
|
||||
if (basePolicyName == "balance-aware") {
|
||||
return 5;
|
||||
}
|
||||
return 0; // "none"
|
||||
}
|
||||
|
||||
/**
|
||||
@ -75,11 +93,21 @@ public:
|
||||
*/
|
||||
static std::string getPolicyStrByCode(int policy)
|
||||
{
|
||||
if (policy == 1) { return "active-backup"; }
|
||||
if (policy == 2) { return "broadcast"; }
|
||||
if (policy == 3) { return "balance-rr"; }
|
||||
if (policy == 4) { return "balance-xor"; }
|
||||
if (policy == 5) { return "balance-aware"; }
|
||||
if (policy == 1) {
|
||||
return "active-backup";
|
||||
}
|
||||
if (policy == 2) {
|
||||
return "broadcast";
|
||||
}
|
||||
if (policy == 3) {
|
||||
return "balance-rr";
|
||||
}
|
||||
if (policy == 4) {
|
||||
return "balance-xor";
|
||||
}
|
||||
if (policy == 5) {
|
||||
return "balance-aware";
|
||||
}
|
||||
return "none";
|
||||
}
|
||||
|
||||
@ -88,19 +116,28 @@ public:
|
||||
*
|
||||
* @param bp Bonding policy
|
||||
*/
|
||||
void setBondingLayerDefaultPolicy(uint8_t bp) { _defaultBondingPolicy = bp; }
|
||||
void setBondingLayerDefaultPolicy(uint8_t bp)
|
||||
{
|
||||
_defaultBondingPolicy = bp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the default (custom) bonding policy for new or undefined bonds.
|
||||
*
|
||||
* @param alias Human-readable string alias for bonding policy
|
||||
*/
|
||||
void setBondingLayerDefaultPolicyStr(std::string alias) { _defaultBondingPolicyStr = alias; }
|
||||
void setBondingLayerDefaultPolicyStr(std::string alias)
|
||||
{
|
||||
_defaultBondingPolicyStr = alias;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The default bonding policy
|
||||
*/
|
||||
static int defaultBondingPolicy() { return _defaultBondingPolicy; }
|
||||
static int defaultBondingPolicy()
|
||||
{
|
||||
return _defaultBondingPolicy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a user-defined link to a given bonding policy.
|
||||
@ -142,7 +179,7 @@ public:
|
||||
* @param peer Remote peer that this bond services
|
||||
* @return A pointer to the newly created Bond
|
||||
*/
|
||||
SharedPtr<Bond> createTransportTriggeredBond(const RuntimeEnvironment *renv, const SharedPtr<Peer>& peer);
|
||||
SharedPtr<Bond> createTransportTriggeredBond(const RuntimeEnvironment* renv, const SharedPtr<Peer>& peer);
|
||||
|
||||
/**
|
||||
* Periodically perform maintenance tasks for the bonding layer.
|
||||
@ -150,7 +187,7 @@ public:
|
||||
* @param tPtr Thread pointer to be handed through to any callbacks called as a result of this call
|
||||
* @param now Current time
|
||||
*/
|
||||
void processBackgroundTasks(void *tPtr, int64_t now);
|
||||
void processBackgroundTasks(void* tPtr, int64_t now);
|
||||
|
||||
/**
|
||||
* Gets a reference to a physical link definition given a policy alias and a local socket.
|
||||
@ -175,12 +212,14 @@ public:
|
||||
*/
|
||||
bool allowedToBind(const std::string& ifname);
|
||||
|
||||
uint64_t getBondStartTime() { return bondStartTime; }
|
||||
uint64_t getBondStartTime()
|
||||
{
|
||||
return bondStartTime;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Phy<BondController *> *_phy;
|
||||
const RuntimeEnvironment *RR;
|
||||
private:
|
||||
Phy<BondController*>* _phy;
|
||||
const RuntimeEnvironment* RR;
|
||||
|
||||
Mutex _bonds_m;
|
||||
Mutex _links_m;
|
||||
@ -208,22 +247,22 @@ private:
|
||||
/**
|
||||
* All currently active bonds.
|
||||
*/
|
||||
std::map<int64_t,SharedPtr<Bond> > _bonds;
|
||||
std::map<int64_t, SharedPtr<Bond> > _bonds;
|
||||
|
||||
/**
|
||||
* Map of peers to custom bonding policies
|
||||
*/
|
||||
std::map<int64_t,std::string> _policyTemplateAssignments;
|
||||
std::map<int64_t, std::string> _policyTemplateAssignments;
|
||||
|
||||
/**
|
||||
* User-defined bonding policies (can be assigned to a peer)
|
||||
*/
|
||||
std::map<std::string,SharedPtr<Bond> > _bondPolicyTemplates;
|
||||
std::map<std::string, SharedPtr<Bond> > _bondPolicyTemplates;
|
||||
|
||||
/**
|
||||
* Set of links defined for a given bonding policy
|
||||
*/
|
||||
std::map<std::string,std::vector<SharedPtr<Link> > > _linkDefinitions;
|
||||
std::map<std::string, std::vector<SharedPtr<Link> > > _linkDefinitions;
|
||||
|
||||
/**
|
||||
* Set of link objects mapped to their physical interfaces
|
||||
@ -234,6 +273,6 @@ private:
|
||||
uint64_t bondStartTime;
|
||||
};
|
||||
|
||||
} // namespace ZeroTier
|
||||
} // namespace ZeroTier
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -22,20 +22,14 @@ namespace ZeroTier {
|
||||
/**
|
||||
* A protocol flow that is identified by the origin and destination port.
|
||||
*/
|
||||
struct Flow
|
||||
{
|
||||
struct Flow {
|
||||
/**
|
||||
* @param flowId Given flow ID
|
||||
* @param now Current time
|
||||
*/
|
||||
Flow(int32_t flowId, int64_t now) :
|
||||
_flowId(flowId),
|
||||
_bytesInPerUnitTime(0),
|
||||
_bytesOutPerUnitTime(0),
|
||||
_lastActivity(now),
|
||||
_lastPathReassignment(0),
|
||||
_assignedPath(SharedPtr<Path>())
|
||||
{}
|
||||
Flow(int32_t flowId, int64_t now) : _flowId(flowId), _bytesInPerUnitTime(0), _bytesOutPerUnitTime(0), _lastActivity(now), _lastPathReassignment(0), _assignedPath(SharedPtr<Path>())
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset flow statistics
|
||||
@ -49,36 +43,54 @@ struct Flow
|
||||
/**
|
||||
* @return The Flow's ID
|
||||
*/
|
||||
int32_t id() { return _flowId; }
|
||||
int32_t id()
|
||||
{
|
||||
return _flowId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Number of incoming bytes processed on this flow per unit time
|
||||
*/
|
||||
int64_t bytesInPerUnitTime() { return _bytesInPerUnitTime; }
|
||||
int64_t bytesInPerUnitTime()
|
||||
{
|
||||
return _bytesInPerUnitTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Record number of incoming bytes on this flow
|
||||
*
|
||||
* @param bytes Number of incoming bytes
|
||||
*/
|
||||
void recordIncomingBytes(uint64_t bytes) { _bytesInPerUnitTime += bytes; }
|
||||
void recordIncomingBytes(uint64_t bytes)
|
||||
{
|
||||
_bytesInPerUnitTime += bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Number of outgoing bytes processed on this flow per unit time
|
||||
*/
|
||||
int64_t bytesOutPerUnitTime() { return _bytesOutPerUnitTime; }
|
||||
int64_t bytesOutPerUnitTime()
|
||||
{
|
||||
return _bytesOutPerUnitTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Record number of outgoing bytes on this flow
|
||||
*
|
||||
* @param bytes
|
||||
*/
|
||||
void recordOutgoingBytes(uint64_t bytes) { _bytesOutPerUnitTime += bytes; }
|
||||
void recordOutgoingBytes(uint64_t bytes)
|
||||
{
|
||||
_bytesOutPerUnitTime += bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The total number of bytes processed on this flow
|
||||
*/
|
||||
uint64_t totalBytes() { return _bytesInPerUnitTime + _bytesOutPerUnitTime; }
|
||||
uint64_t totalBytes()
|
||||
{
|
||||
return _bytesInPerUnitTime + _bytesOutPerUnitTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* How long since a packet was sent or received in this flow
|
||||
@ -86,24 +98,34 @@ struct Flow
|
||||
* @param now Current time
|
||||
* @return The age of the flow in terms of last recorded activity
|
||||
*/
|
||||
int64_t age(int64_t now) { return now - _lastActivity; }
|
||||
int64_t age(int64_t now)
|
||||
{
|
||||
return now - _lastActivity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Record that traffic was processed on this flow at the given time.
|
||||
*
|
||||
* @param now Current time
|
||||
*/
|
||||
void updateActivity(int64_t now) { _lastActivity = now; }
|
||||
void updateActivity(int64_t now)
|
||||
{
|
||||
_lastActivity = now;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Path assigned to this flow
|
||||
*/
|
||||
SharedPtr<Path> assignedPath() { return _assignedPath; }
|
||||
SharedPtr<Path> assignedPath()
|
||||
{
|
||||
return _assignedPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param path Assigned path over which this flow should be handled
|
||||
*/
|
||||
void assignPath(const SharedPtr<Path> &path, int64_t now) {
|
||||
void assignPath(const SharedPtr<Path>& path, int64_t now)
|
||||
{
|
||||
_assignedPath = path;
|
||||
_lastPathReassignment = now;
|
||||
}
|
||||
@ -119,6 +141,6 @@ struct Flow
|
||||
SharedPtr<Path> _previouslyAssignedPath;
|
||||
};
|
||||
|
||||
} // namespace ZeroTier
|
||||
} // namespace ZeroTier
|
||||
|
||||
#endif
|
@ -1047,7 +1047,6 @@ void Switch::_sendViaSpecificPath(void *tPtr,SharedPtr<Peer> peer,SharedPtr<Path
|
||||
if (trustedPathId) {
|
||||
packet.setTrusted(trustedPathId);
|
||||
} else {
|
||||
Packet::Verb v = packet.verb();
|
||||
packet.armor(peer->key(),encrypt,peer->aesKeysIfSupported());
|
||||
RR->node->expectReplyTo(packet.packetId());
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ void Trace::peerConfirmingUnknownPath(void *const tPtr,const uint64_t networkId,
|
||||
char tmp[128];
|
||||
if (!path) return; // sanity check
|
||||
|
||||
ZT_LOCAL_TRACE(tPtr,RR,"trying unknown path %s to %.10llx (packet %.16llx verb %d local socket %lld network %.16llx)",path->address().toString(tmp),peer.address().toInt(),packetId,(double)verb,path->localSocket(),networkId);
|
||||
ZT_LOCAL_TRACE(tPtr,RR,"trying unknown path %s to %.10llx (packet %.16llx verb %d local socket %lld network %.16llx)",path->address().toString(tmp),peer.address().toInt(),packetId,verb,path->localSocket(),networkId);
|
||||
|
||||
std::pair<Address,Trace::Level> byn;
|
||||
if (networkId) { Mutex::Lock l(_byNet_m); _byNet.get(networkId,byn); }
|
||||
|
@ -28,10 +28,12 @@
|
||||
#include <sys/stat.h>
|
||||
#include <sys/uio.h>
|
||||
#include <dirent.h>
|
||||
#ifdef ZT_ARCH_ARM_HAS_NEON
|
||||
#ifdef __LINUX__
|
||||
#include <sys/auxv.h>
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
#include <wincrypt.h>
|
||||
|
42
one.cpp
42
one.cpp
@ -494,12 +494,11 @@ static int cli(int argc,char **argv)
|
||||
} else if (command == "bond") {
|
||||
/* zerotier-cli bond */
|
||||
if (arg1.empty()) {
|
||||
printf("(bond) command is missing required arugments" ZT_EOL_S);
|
||||
printf("(bond) command is missing required arguments" ZT_EOL_S);
|
||||
return 2;
|
||||
}
|
||||
/* zerotier-cli bond list */
|
||||
if (arg1 == "list") {
|
||||
fprintf(stderr, "zerotier-cli bond list\n");
|
||||
const unsigned int scode = Http::GET(1024 * 1024 * 16,60000,(const struct sockaddr *)&addr,"/bonds",requestHeaders,responseHeaders,responseBody);
|
||||
if (scode == 0) {
|
||||
printf("Error connecting to the ZeroTier service: %s\n\nPlease check that the service is running and that TCP port 9993 can be contacted via 127.0.0.1." ZT_EOL_S, responseBody.c_str());
|
||||
@ -525,11 +524,11 @@ static int cli(int argc,char **argv)
|
||||
for(unsigned long k=0;k<j.size();++k) {
|
||||
nlohmann::json &p = j[k];
|
||||
bool isBonded = p["isBonded"];
|
||||
int8_t bondingPolicy = p["bondingPolicy"];
|
||||
bool isHealthy = p["isHealthy"];
|
||||
int8_t numAliveLinks = p["numAliveLinks"];
|
||||
int8_t numTotalLinks = p["numTotalLinks"];
|
||||
if (isBonded) {
|
||||
int8_t bondingPolicy = p["bondingPolicy"];
|
||||
bool isHealthy = p["isHealthy"];
|
||||
int8_t numAliveLinks = p["numAliveLinks"];
|
||||
int8_t numTotalLinks = p["numTotalLinks"];
|
||||
bFoundBond = true;
|
||||
std::string healthStr;
|
||||
if (isHealthy) {
|
||||
@ -618,7 +617,6 @@ static int cli(int argc,char **argv)
|
||||
if (json) {
|
||||
printf("%s" ZT_EOL_S,OSUtils::jsonDump(j).c_str());
|
||||
} else {
|
||||
bool bFoundBond = false;
|
||||
std::string healthStr;
|
||||
if (OSUtils::jsonInt(j["isHealthy"],0)) {
|
||||
healthStr = "Healthy";
|
||||
@ -630,14 +628,14 @@ static int cli(int argc,char **argv)
|
||||
printf("Peer : %s\n", arg1.c_str());
|
||||
printf("Bond : %s\n", OSUtils::jsonString(j["bondingPolicy"],"-").c_str());
|
||||
//if (bondingPolicy == ZT_BONDING_POLICY_ACTIVE_BACKUP) {
|
||||
printf("Link Select Method : %d\n", OSUtils::jsonInt(j["linkSelectMethod"],0));
|
||||
printf("Link Select Method : %d\n", (int)OSUtils::jsonInt(j["linkSelectMethod"],0));
|
||||
//}
|
||||
printf("Status : %s\n", healthStr.c_str());
|
||||
printf("Links : %d/%d\n", numAliveLinks, numTotalLinks);
|
||||
printf("Failover Interval : %d (ms)\n", OSUtils::jsonInt(j["failoverInterval"],0));
|
||||
printf("Up Delay : %d (ms)\n", OSUtils::jsonInt(j["upDelay"],0));
|
||||
printf("Down Delay : %d (ms)\n", OSUtils::jsonInt(j["downDelay"],0));
|
||||
printf("Packets Per Link : %d (ms)\n", OSUtils::jsonInt(j["packetsPerLink"],0));
|
||||
printf("Failover Interval : %d (ms)\n", (int)OSUtils::jsonInt(j["failoverInterval"],0));
|
||||
printf("Up Delay : %d (ms)\n", (int)OSUtils::jsonInt(j["upDelay"],0));
|
||||
printf("Down Delay : %d (ms)\n", (int)OSUtils::jsonInt(j["downDelay"],0));
|
||||
printf("Packets Per Link : %d (ms)\n", (int)OSUtils::jsonInt(j["packetsPerLink"],0));
|
||||
nlohmann::json &p = j["links"];
|
||||
if (p.is_array()) {
|
||||
printf("\n Interface Name\t\t\t\t\t Path\t Alive\n");
|
||||
@ -649,7 +647,7 @@ static int cli(int argc,char **argv)
|
||||
i,
|
||||
OSUtils::jsonString(p[i]["ifname"],"-").c_str(),
|
||||
OSUtils::jsonString(p[i]["path"],"-").c_str(),
|
||||
OSUtils::jsonInt(p[i]["alive"],0));
|
||||
(int)OSUtils::jsonInt(p[i]["alive"],0));
|
||||
}
|
||||
printf("\n Latency Jitter Loss Error Speed Alloc\n");
|
||||
for(int i=0; i<80; i++) { printf("-"); }
|
||||
@ -662,8 +660,8 @@ static int cli(int argc,char **argv)
|
||||
OSUtils::jsonDouble(p[i]["latencyVariance"], 0),
|
||||
OSUtils::jsonDouble(p[i]["packetLossRatio"], 0),
|
||||
OSUtils::jsonDouble(p[i]["packetErrorRatio"], 0),
|
||||
OSUtils::jsonInt(p[i]["givenLinkSpeed"], 0),
|
||||
OSUtils::jsonInt(p[i]["allocation"], 0));
|
||||
(int)OSUtils::jsonInt(p[i]["givenLinkSpeed"], 0),
|
||||
(int)OSUtils::jsonInt(p[i]["allocation"], 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -676,7 +674,7 @@ static int cli(int argc,char **argv)
|
||||
}
|
||||
}
|
||||
/* zerotier-cli bond command was malformed in some way */
|
||||
printf("(bond) command is missing required arugments" ZT_EOL_S);
|
||||
printf("(bond) command is missing required arguments" ZT_EOL_S);
|
||||
return 2;
|
||||
const unsigned int scode = Http::GET(1024 * 1024 * 16,60000,(const struct sockaddr *)&addr,"/bonds",requestHeaders,responseHeaders,responseBody);
|
||||
if (scode == 0) {
|
||||
@ -711,14 +709,13 @@ static int cli(int argc,char **argv)
|
||||
if (j.is_array()) {
|
||||
for(unsigned long k=0;k<j.size();++k) {
|
||||
nlohmann::json &p = j[k];
|
||||
|
||||
bool isBonded = p["isBonded"];
|
||||
int8_t bondingPolicy = p["bondingPolicy"];
|
||||
bool isHealthy = p["isHealthy"];
|
||||
int8_t numAliveLinks = p["numAliveLinks"];
|
||||
int8_t numTotalLinks = p["numTotalLinks"];
|
||||
|
||||
if (isBonded) {
|
||||
int8_t bondingPolicy = p["bondingPolicy"];
|
||||
bool isHealthy = p["isHealthy"];
|
||||
int8_t numAliveLinks = p["numAliveLinks"];
|
||||
int8_t numTotalLinks = p["numTotalLinks"];
|
||||
|
||||
bFoundBond = true;
|
||||
std::string healthStr;
|
||||
if (isHealthy) {
|
||||
@ -1310,7 +1307,6 @@ static int cli(int argc,char **argv)
|
||||
struct ifconf ifc;
|
||||
char buf[1024];
|
||||
char stringBuffer[128];
|
||||
int success = 0;
|
||||
|
||||
int sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
|
||||
|
||||
|
151
osdep/Link.hpp
151
osdep/Link.hpp
@ -14,20 +14,17 @@
|
||||
#ifndef ZT_LINK_HPP
|
||||
#define ZT_LINK_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "../node/AtomicCounter.hpp"
|
||||
#include "../node/SharedPtr.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace ZeroTier {
|
||||
|
||||
class Link
|
||||
{
|
||||
class Link {
|
||||
friend class SharedPtr<Link>;
|
||||
|
||||
public:
|
||||
|
||||
Link() {}
|
||||
|
||||
public:
|
||||
/**
|
||||
*
|
||||
* @param ifnameStr
|
||||
@ -38,123 +35,165 @@ public:
|
||||
* @param failoverToLinkStr
|
||||
* @param userSpecifiedAlloc
|
||||
*/
|
||||
Link(std::string& ifnameStr,
|
||||
uint8_t ipvPref,
|
||||
uint32_t speed,
|
||||
uint32_t linkMonitorInterval,
|
||||
uint32_t upDelay,
|
||||
uint32_t downDelay,
|
||||
bool enabled,
|
||||
uint8_t mode,
|
||||
std::string failoverToLinkStr,
|
||||
float userSpecifiedAlloc) :
|
||||
_ifnameStr(ifnameStr),
|
||||
_ipvPref(ipvPref),
|
||||
_speed(speed),
|
||||
_relativeSpeed(0),
|
||||
_linkMonitorInterval(linkMonitorInterval),
|
||||
_upDelay(upDelay),
|
||||
_downDelay(downDelay),
|
||||
_enabled(enabled),
|
||||
_mode(mode),
|
||||
_failoverToLinkStr(failoverToLinkStr),
|
||||
_userSpecifiedAlloc(userSpecifiedAlloc),
|
||||
_isUserSpecified(false)
|
||||
{}
|
||||
Link(std::string& ifnameStr, uint8_t ipvPref, uint32_t speed, uint32_t linkMonitorInterval, uint32_t upDelay, uint32_t downDelay, bool enabled, uint8_t mode, std::string failoverToLinkStr, float userSpecifiedAlloc)
|
||||
: _ifnameStr(ifnameStr)
|
||||
, _ipvPref(ipvPref)
|
||||
, _speed(speed)
|
||||
, _relativeSpeed(0)
|
||||
, _linkMonitorInterval(linkMonitorInterval)
|
||||
, _upDelay(upDelay)
|
||||
, _downDelay(downDelay)
|
||||
, _enabled(enabled)
|
||||
, _mode(mode)
|
||||
, _failoverToLinkStr(failoverToLinkStr)
|
||||
, _userSpecifiedAlloc(userSpecifiedAlloc)
|
||||
, _isUserSpecified(false)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The string representation of this link's underlying interface's system name.
|
||||
*/
|
||||
inline std::string ifname() { return _ifnameStr; }
|
||||
inline std::string ifname()
|
||||
{
|
||||
return _ifnameStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Whether this link is designated as a primary.
|
||||
*/
|
||||
inline bool primary() { return _mode == ZT_MULTIPATH_SLAVE_MODE_PRIMARY; }
|
||||
inline bool primary()
|
||||
{
|
||||
return _mode == ZT_MULTIPATH_SLAVE_MODE_PRIMARY;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Whether this link is designated as a spare.
|
||||
*/
|
||||
inline bool spare() { return _mode == ZT_MULTIPATH_SLAVE_MODE_SPARE; }
|
||||
inline bool spare()
|
||||
{
|
||||
return _mode == ZT_MULTIPATH_SLAVE_MODE_SPARE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The name of the link interface that should be used in the event of a failure.
|
||||
*/
|
||||
inline std::string failoverToLink() { return _failoverToLinkStr; }
|
||||
inline std::string failoverToLink()
|
||||
{
|
||||
return _failoverToLinkStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Whether this link interface was specified by the user or auto-detected.
|
||||
*/
|
||||
inline bool isUserSpecified() { return _isUserSpecified; }
|
||||
inline bool isUserSpecified()
|
||||
{
|
||||
return _isUserSpecified;
|
||||
}
|
||||
|
||||
/**
|
||||
* Signify that this link was specified by the user and not the result of auto-detection.
|
||||
*
|
||||
* @param isUserSpecified
|
||||
*/
|
||||
inline void setAsUserSpecified(bool isUserSpecified) { _isUserSpecified = isUserSpecified; }
|
||||
inline void setAsUserSpecified(bool isUserSpecified)
|
||||
{
|
||||
_isUserSpecified = isUserSpecified;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Whether or not the user has specified failover instructions.
|
||||
*/
|
||||
inline bool userHasSpecifiedFailoverInstructions() { return _failoverToLinkStr.length(); }
|
||||
inline bool userHasSpecifiedFailoverInstructions()
|
||||
{
|
||||
return _failoverToLinkStr.length();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The speed of the link relative to others in the bond.
|
||||
*/
|
||||
inline uint8_t relativeSpeed() { return _relativeSpeed; }
|
||||
inline uint8_t relativeSpeed()
|
||||
{
|
||||
return _relativeSpeed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the speed of the link relative to others in the bond.
|
||||
*
|
||||
* @param relativeSpeed The speed relative to the rest of the link.
|
||||
*/
|
||||
inline void setRelativeSpeed(uint8_t relativeSpeed) { _relativeSpeed = relativeSpeed; }
|
||||
inline void setRelativeSpeed(uint8_t relativeSpeed)
|
||||
{
|
||||
_relativeSpeed = relativeSpeed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the speed of the link relative to others in the bond.
|
||||
*
|
||||
* @param relativeSpeed
|
||||
*/
|
||||
inline void setMonitorInterval(uint32_t interval) { _linkMonitorInterval = interval; }
|
||||
inline void setMonitorInterval(uint32_t interval)
|
||||
{
|
||||
_linkMonitorInterval = interval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The absolute speed of the link (as specified by the user.)
|
||||
*/
|
||||
inline uint32_t monitorInterval() { return _linkMonitorInterval; }
|
||||
inline uint32_t monitorInterval()
|
||||
{
|
||||
return _linkMonitorInterval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The absolute speed of the link (as specified by the user.)
|
||||
*/
|
||||
inline uint32_t speed() { return _speed; }
|
||||
inline uint32_t speed()
|
||||
{
|
||||
return _speed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The address preference for this link (as specified by the user.)
|
||||
*/
|
||||
inline uint8_t ipvPref() { return _ipvPref; }
|
||||
inline uint8_t ipvPref()
|
||||
{
|
||||
return _ipvPref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The mode (e.g. primary/spare) for this link (as specified by the user.)
|
||||
*/
|
||||
inline uint8_t mode() { return _mode; }
|
||||
inline uint8_t mode()
|
||||
{
|
||||
return _mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The upDelay parameter for all paths on this link.
|
||||
*/
|
||||
inline uint32_t upDelay() { return _upDelay; }
|
||||
inline uint32_t upDelay()
|
||||
{
|
||||
return _upDelay;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The downDelay parameter for all paths on this link.
|
||||
*/
|
||||
inline uint32_t downDelay() { return _downDelay; }
|
||||
inline uint32_t downDelay()
|
||||
{
|
||||
return _downDelay;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Whether this link is enabled or disabled
|
||||
*/
|
||||
inline uint8_t enabled() { return _enabled; }
|
||||
|
||||
private:
|
||||
inline uint8_t enabled()
|
||||
{
|
||||
return _enabled;
|
||||
}
|
||||
|
||||
private:
|
||||
/**
|
||||
* String representation of underlying interface's system name
|
||||
*/
|
||||
@ -223,15 +262,15 @@ private:
|
||||
float _userSpecifiedAlloc;
|
||||
|
||||
/**
|
||||
* Whether or not this link was created as a result of manual user specification. This is
|
||||
* important to know because certain policy decisions are dependent on whether the user
|
||||
* intents to use a specific set of interfaces.
|
||||
*/
|
||||
* Whether or not this link was created as a result of manual user specification. This is
|
||||
* important to know because certain policy decisions are dependent on whether the user
|
||||
* intents to use a specific set of interfaces.
|
||||
*/
|
||||
bool _isUserSpecified;
|
||||
|
||||
AtomicCounter __refCount;
|
||||
};
|
||||
|
||||
} // namespace ZeroTier
|
||||
} // namespace ZeroTier
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -302,7 +302,6 @@ static void _peerToJson(nlohmann::json &pj,const ZT_Peer *peer)
|
||||
|
||||
static void _bondToJson(nlohmann::json &pj, SharedPtr<Bond> &bond)
|
||||
{
|
||||
char tmp[256];
|
||||
uint64_t now = OSUtils::now();
|
||||
|
||||
int bondingPolicy = bond->getPolicy();
|
||||
@ -1261,7 +1260,7 @@ public:
|
||||
_bondToJson(res,bond);
|
||||
scode = 200;
|
||||
} else {
|
||||
fprintf(stderr, "unable to find bond to peer %llx\n", id);
|
||||
fprintf(stderr, "unable to find bond to peer %llx\n", (unsigned long long)id);
|
||||
scode = 400;
|
||||
}
|
||||
}
|
||||
@ -1468,7 +1467,7 @@ public:
|
||||
if (bond) {
|
||||
scode = bond->abForciblyRotateLink() ? 200 : 400;
|
||||
} else {
|
||||
fprintf(stderr, "unable to find bond to peer %llx\n", id);
|
||||
fprintf(stderr, "unable to find bond to peer %llx\n", (unsigned long long)id);
|
||||
scode = 400;
|
||||
}
|
||||
}
|
||||
@ -2393,7 +2392,7 @@ public:
|
||||
Dictionary<4096> nc;
|
||||
nc.load(nlcbuf.c_str());
|
||||
Buffer<1024> allowManaged;
|
||||
if (nc.get("allowManaged", allowManaged) && !allowManaged.size() == 0) {
|
||||
if (nc.get("allowManaged", allowManaged) && allowManaged.size() > 0) {
|
||||
std::string addresses (allowManaged.begin(), allowManaged.size());
|
||||
if (allowManaged.size() <= 5) { // untidy parsing for backward compatibility
|
||||
if (allowManaged[0] == '1' || allowManaged[0] == 't' || allowManaged[0] == 'T') {
|
||||
|
Loading…
x
Reference in New Issue
Block a user