host-local: don't allocate past RangeEnd
authorDan Williams <dcbw@redhat.com>
Fri, 2 Sep 2016 20:55:53 +0000 (15:55 -0500)
committerDan Williams <dcbw@redhat.com>
Fri, 2 Sep 2016 21:37:34 +0000 (16:37 -0500)
commitdfc4f7cd2af04016fc7deedc2cc23925533bbf0a
tree16260a1968e0a3f43fd50e30a760f30c6c36b335
parentc5e39a87f702f757a1e98f701d873992bd4d37b1
host-local: don't allocate past RangeEnd

When RangeEnd is given, a.end = RangeEnd+1.

If when getSearchRange() is called and lastReservedIP equals
RangeEnd, a.nextIP() only compares lastReservedIP (which in this
example is RangeEnd) against a.end (which in this example is
RangeEnd+1) and they clearly don't match, so a.nextIP() returns
start=RangeEnd+1 and end=RangeEnd.

Get() happily allocates RangeEnd+1 because it only compares 'cur'
to the end returned by getSearchRange(), not to a.end, and thus
allocates past RangeEnd.

Since a.end is inclusive (eg, host-local will allocate a.end) the
fix is to simply set a.end equal to RangeEnd.
plugins/ipam/host-local/allocator.go
plugins/ipam/host-local/allocator_test.go