mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-01 23:10:52 +00:00
Fix custom policy parsing bug mentioned in issue #1507
This commit is contained in:
parent
f0e824416b
commit
1c6fd4125d
@ -95,7 +95,6 @@ SharedPtr<Bond> Bond::createTransportTriggeredBond(const RuntimeEnvironment* ren
|
|||||||
int64_t identity = peer->identity().address().toInt();
|
int64_t identity = peer->identity().address().toInt();
|
||||||
Bond* bond = nullptr;
|
Bond* bond = nullptr;
|
||||||
if (! _bonds.count(identity)) {
|
if (! _bonds.count(identity)) {
|
||||||
std::string policyAlias;
|
|
||||||
if (! _policyTemplateAssignments.count(identity)) {
|
if (! _policyTemplateAssignments.count(identity)) {
|
||||||
if (_defaultPolicy) {
|
if (_defaultPolicy) {
|
||||||
bond = new Bond(renv, _defaultPolicy, peer);
|
bond = new Bond(renv, _defaultPolicy, peer);
|
||||||
@ -1717,6 +1716,7 @@ void Bond::setBondParameters(int policy, SharedPtr<Bond> templateBond, bool useT
|
|||||||
/* If a user has specified custom parameters for this bonding policy, overlay them onto the defaults */
|
/* If a user has specified custom parameters for this bonding policy, overlay them onto the defaults */
|
||||||
if (useTemplate) {
|
if (useTemplate) {
|
||||||
_policyAlias = templateBond->_policyAlias;
|
_policyAlias = templateBond->_policyAlias;
|
||||||
|
_policy = templateBond->policy();
|
||||||
_failoverInterval = templateBond->_failoverInterval >= ZT_BOND_FAILOVER_MIN_INTERVAL ? templateBond->_failoverInterval : ZT_BOND_FAILOVER_MIN_INTERVAL;
|
_failoverInterval = templateBond->_failoverInterval >= ZT_BOND_FAILOVER_MIN_INTERVAL ? templateBond->_failoverInterval : ZT_BOND_FAILOVER_MIN_INTERVAL;
|
||||||
_downDelay = templateBond->_downDelay;
|
_downDelay = templateBond->_downDelay;
|
||||||
_upDelay = templateBond->_upDelay;
|
_upDelay = templateBond->_upDelay;
|
||||||
|
@ -1000,12 +1000,12 @@ class Bond {
|
|||||||
/**
|
/**
|
||||||
* @param policy Bonding policy for this bond
|
* @param policy Bonding policy for this bond
|
||||||
*/
|
*/
|
||||||
/*
|
|
||||||
inline void setPolicy(uint8_t policy)
|
inline void setPolicy(uint8_t policy)
|
||||||
{
|
{
|
||||||
_policy = policy;
|
_policy = policy;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
/**
|
/**
|
||||||
* @return the current bonding policy
|
* @return the current bonding policy
|
||||||
*/
|
*/
|
||||||
|
@ -1769,7 +1769,8 @@ public:
|
|||||||
if (basePolicyStr.empty()) {
|
if (basePolicyStr.empty()) {
|
||||||
fprintf(stderr, "error: no base policy was specified for custom policy (%s)\n", customPolicyStr.c_str());
|
fprintf(stderr, "error: no base policy was specified for custom policy (%s)\n", customPolicyStr.c_str());
|
||||||
}
|
}
|
||||||
if (_node->bondController()->getPolicyCodeByStr(basePolicyStr) == ZT_BOND_POLICY_NONE) {
|
int basePolicyCode = _node->bondController()->getPolicyCodeByStr(basePolicyStr);
|
||||||
|
if (basePolicyCode == ZT_BOND_POLICY_NONE) {
|
||||||
fprintf(stderr, "error: custom policy (%s) is invalid, unknown base policy (%s).\n",
|
fprintf(stderr, "error: custom policy (%s) is invalid, unknown base policy (%s).\n",
|
||||||
customPolicyStr.c_str(), basePolicyStr.c_str());
|
customPolicyStr.c_str(), basePolicyStr.c_str());
|
||||||
continue;
|
continue;
|
||||||
@ -1781,6 +1782,7 @@ public:
|
|||||||
// New bond, used as a copy template for new instances
|
// New bond, used as a copy template for new instances
|
||||||
SharedPtr<Bond> newTemplateBond = new Bond(NULL, basePolicyStr, customPolicyStr, SharedPtr<Peer>());
|
SharedPtr<Bond> newTemplateBond = new Bond(NULL, basePolicyStr, customPolicyStr, SharedPtr<Peer>());
|
||||||
// Acceptable ranges
|
// Acceptable ranges
|
||||||
|
newTemplateBond->setPolicy(basePolicyCode);
|
||||||
newTemplateBond->setMaxAcceptableLatency(OSUtils::jsonInt(customPolicy["maxAcceptableLatency"],-1));
|
newTemplateBond->setMaxAcceptableLatency(OSUtils::jsonInt(customPolicy["maxAcceptableLatency"],-1));
|
||||||
newTemplateBond->setMaxAcceptableMeanLatency(OSUtils::jsonInt(customPolicy["maxAcceptableMeanLatency"],-1));
|
newTemplateBond->setMaxAcceptableMeanLatency(OSUtils::jsonInt(customPolicy["maxAcceptableMeanLatency"],-1));
|
||||||
newTemplateBond->setMaxAcceptablePacketDelayVariance(OSUtils::jsonInt(customPolicy["maxAcceptablePacketDelayVariance"],-1));
|
newTemplateBond->setMaxAcceptablePacketDelayVariance(OSUtils::jsonInt(customPolicy["maxAcceptablePacketDelayVariance"],-1));
|
||||||
@ -1805,7 +1807,7 @@ public:
|
|||||||
newTemplateBond->setUpDelay(OSUtils::jsonInt(customPolicy["upDelay"],-1));
|
newTemplateBond->setUpDelay(OSUtils::jsonInt(customPolicy["upDelay"],-1));
|
||||||
newTemplateBond->setDownDelay(OSUtils::jsonInt(customPolicy["downDelay"],-1));
|
newTemplateBond->setDownDelay(OSUtils::jsonInt(customPolicy["downDelay"],-1));
|
||||||
newTemplateBond->setFlowRebalanceStrategy(OSUtils::jsonInt(customPolicy["flowRebalanceStrategy"],(uint64_t)0));
|
newTemplateBond->setFlowRebalanceStrategy(OSUtils::jsonInt(customPolicy["flowRebalanceStrategy"],(uint64_t)0));
|
||||||
newTemplateBond->setFailoverInterval(OSUtils::jsonInt(customPolicy["failoverInterval"],(uint64_t)0));
|
newTemplateBond->setFailoverInterval(OSUtils::jsonInt(customPolicy["failoverInterval"],ZT_BOND_FAILOVER_DEFAULT_INTERVAL));
|
||||||
newTemplateBond->setPacketsPerLink(OSUtils::jsonInt(customPolicy["packetsPerLink"],-1));
|
newTemplateBond->setPacketsPerLink(OSUtils::jsonInt(customPolicy["packetsPerLink"],-1));
|
||||||
|
|
||||||
// Policy-Specific link set
|
// Policy-Specific link set
|
||||||
|
Loading…
x
Reference in New Issue
Block a user