mirror of
https://github.com/clearlinux/libnetwork.git
synced 2026-06-16 02:25:48 +00:00
Merge pull request #593 from mavenugo/ipam-fix
ipam must honor preferedIP ahead of random allocation from subPool
This commit is contained in:
+4
-4
@@ -425,16 +425,16 @@ func (a *Allocator) getAddress(nw *net.IPNet, bitmask *bitseq.Handle, prefAddres
|
||||
}
|
||||
if ipr == nil && prefAddress == nil {
|
||||
ordinal, err = bitmask.SetAny()
|
||||
} else if ipr != nil {
|
||||
base.IP = ipr.Sub.IP
|
||||
ordinal, err = bitmask.SetAnyInRange(ipr.Start, ipr.End)
|
||||
} else {
|
||||
} else if prefAddress != nil {
|
||||
hostPart, e := types.GetHostPartIP(prefAddress, base.Mask)
|
||||
if e != nil {
|
||||
return nil, fmt.Errorf("failed to allocate preferred address %s: %v", prefAddress.String(), e)
|
||||
}
|
||||
ordinal = ipToUint32(types.GetMinimalIP(hostPart))
|
||||
err = bitmask.Set(ordinal)
|
||||
} else {
|
||||
base.IP = ipr.Sub.IP
|
||||
ordinal, err = bitmask.SetAnyInRange(ipr.Start, ipr.End)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, ipamapi.ErrNoAvailableIPs
|
||||
|
||||
Reference in New Issue
Block a user