From 11a8e61c10548bdccf9968d11b0ff9b2a2a5e148 Mon Sep 17 00:00:00 2001 From: Dmitri Dolguikh Date: Tue, 31 Oct 2017 15:11:33 -0700 Subject: [PATCH] For compatibility with 1.7 replaced rand.Uint64() call with calls to rand.Uint32() --- dhcp6/random_address_pool.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dhcp6/random_address_pool.go b/dhcp6/random_address_pool.go index a8e1168..eaeb91e 100644 --- a/dhcp6/random_address_pool.go +++ b/dhcp6/random_address_pool.go @@ -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()) +}