Extract allocation logic from ipallocator and portallocator

IP and ports allocation shared a same strategy for automatically assigning slots inside a given range: this strategy is extracted and refactored (this idea was raised while reviewing #8699). The `ipallocator` and `portallocator` logics remain unchanged (it's just adaptations). Benchmarks results with this patch are very similar.
We need to both have "automatic allocation inside a given range", and custom allocation (e.g: you can want to allocate port 80 to expose a container while keeping the automatic ones in the 49153.. range).