host-local: fix allocation of last address in a /30

This commit is contained in:
Minhan Xia
2016-09-16 10:38:44 -07:00
parent 56032390fe
commit 52e4358cbd
2 changed files with 23 additions and 1 deletions

View File

@ -173,7 +173,7 @@ func (a *IPAllocator) Get(id string) (*types.IPConfig, error) {
}
startIP, endIP := a.getSearchRange()
for cur := startIP; !cur.Equal(endIP); cur = a.nextIP(cur) {
for cur := startIP; ; cur = a.nextIP(cur) {
// don't allocate gateway IP
if gw != nil && cur.Equal(gw) {
continue
@ -190,6 +190,10 @@ func (a *IPAllocator) Get(id string) (*types.IPConfig, error) {
Routes: a.conf.Routes,
}, nil
}
// break here to complete the loop
if cur.Equal(endIP) {
break
}
}
return nil, fmt.Errorf("no IP addresses available in network: %s", a.conf.Name)
}