mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 12:33:44 +02:00
Prevent arithmetic error on interface change.
This commit is contained in:
parent
fa58909d44
commit
aeec7dae36
1 changed files with 4 additions and 4 deletions
|
@ -488,6 +488,10 @@ int32_t Bond::generateQoSPacket(int pathIdx, int64_t now, char* qosBuffer)
|
||||||
|
|
||||||
bool Bond::assignFlowToBondedPath(SharedPtr<Flow>& flow, int64_t now)
|
bool Bond::assignFlowToBondedPath(SharedPtr<Flow>& flow, int64_t now)
|
||||||
{
|
{
|
||||||
|
if (! _numBondedPaths) {
|
||||||
|
log("unable to assign flow %x (bond has no links)\n", flow->id);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
unsigned int idx = ZT_MAX_PEER_NETWORK_PATHS;
|
unsigned int idx = ZT_MAX_PEER_NETWORK_PATHS;
|
||||||
if (_policy == ZT_BOND_POLICY_BALANCE_XOR) {
|
if (_policy == ZT_BOND_POLICY_BALANCE_XOR) {
|
||||||
idx = abs((int)(flow->id % (_numBondedPaths)));
|
idx = abs((int)(flow->id % (_numBondedPaths)));
|
||||||
|
@ -500,10 +504,6 @@ bool Bond::assignFlowToBondedPath(SharedPtr<Flow>& flow, int64_t now)
|
||||||
if (_totalBondUnderload) {
|
if (_totalBondUnderload) {
|
||||||
entropy %= _totalBondUnderload;
|
entropy %= _totalBondUnderload;
|
||||||
}
|
}
|
||||||
if (! _numBondedPaths) {
|
|
||||||
log("unable to assign flow %x (bond has no links)\n", flow->id);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
/* Since there may be scenarios where a path is removed before we can re-estimate
|
/* Since there may be scenarios where a path is removed before we can re-estimate
|
||||||
relative qualities (and thus allocations) we need to down-modulate the entropy
|
relative qualities (and thus allocations) we need to down-modulate the entropy
|
||||||
value that we use to randomly assign among the surviving paths, otherwise we risk
|
value that we use to randomly assign among the surviving paths, otherwise we risk
|
||||||
|
|
Loading…
Add table
Reference in a new issue