Hi! On Mon, Jan 21, 2013 at 1:45 PM, Iustin Pop <[email protected]> wrote:
> On Mon, Jan 21, 2013 at 01:40:46PM +0100, Helga Velroyen wrote: > > Adding a network failed in the corner case of adding > > a network with just one IP address, because it would try > > to reserve the same IP twice. Fixing the way we iterate > > over all IPs does the trick. > > > > Signed-off-by: Helga Velroyen <[email protected]> > > --- > > lib/network.py | 2 +- > > 1 files changed, 1 insertions(+), 1 deletions(-) > > > > diff --git a/lib/network.py b/lib/network.py > > index cc3bfd6..4656a88 100644 > > --- a/lib/network.py > > +++ b/lib/network.py > > @@ -224,7 +224,7 @@ class AddressPool(object): > > """ > > obj = cls(net) > > obj.Update() > > - for ip in [obj.network[0], obj.network[-1]]: > > + for ip in obj.network: > > This seems very wrong. The original code was intended to reserve the > network ([0]) and broadcast ([-1]) addresses for the network, which are > not valid host addresses. Your change will reserve all addresses in the > network, leaving none available for hosts. > > So I rather think that /31 networks should not be allowed, since they > are not valid anyway. The smallest IPv4 valid network is a /30, which > has just two host (1 gw + 1 other) valid addresses. > Hm, makes sense. So far, the user is not kept from creating such a small net. Will send a patch for that. Cheers, Helga
