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

@ -65,6 +65,12 @@ var _ = Describe("host-local ip allocator", func() {
expectResult: "10.0.0.2",
lastIP: "",
},
{
subnet: "10.0.0.0/30",
ipmap: map[string]string{},
expectResult: "10.0.0.2",
lastIP: "",
},
{
subnet: "10.0.0.0/29",
ipmap: map[string]string{
@ -107,6 +113,18 @@ var _ = Describe("host-local ip allocator", func() {
expectResult: "10.0.0.3",
lastIP: "10.0.0.128",
},
// wrap around and reserve lastIP
{
subnet: "10.0.0.0/29",
ipmap: map[string]string{
"10.0.0.2": "id",
"10.0.0.4": "id",
"10.0.0.5": "id",
"10.0.0.6": "id",
},
expectResult: "10.0.0.3",
lastIP: "10.0.0.3",
},
}
for _, tc := range testCases {