For compatibility with 1.7 replaced rand.Uint64() call with calls to rand.Uint32()

This commit is contained in:
Dmitri Dolguikh 2017-10-31 15:11:33 -07:00 committed by Dave Anderson
parent 43551d9de3
commit 11a8e61c10

View File

@ -96,7 +96,7 @@ func (p *RandomAddressPool) ReserveAddresses(clientId []byte, interfaceIds [][]b
for {
// we assume that ip addresses adhere to high 64 bits for net and subnet ids, low 64 bits are for host id rule
hostOffset := rng.Uint64() % p.poolSize
hostOffset := randomUint64(rng) % p.poolSize
newIp := big.NewInt(0).Add(p.poolStartAddress, big.NewInt(0).SetUint64(hostOffset))
_, exists := p.usedIps[newIp.Uint64()];
if !exists {
@ -155,3 +155,7 @@ func (p *RandomAddressPool) calculateIaIdHash(clientId, interfaceId []byte) uint
h.Write(interfaceId)
return h.Sum64()
}
func randomUint64(rng *rand.Rand) uint64 {
return uint64(rng.Uint32())<<32 + uint64(rand.Uint32())
}