When creating a network, so far no size constraints were checked.
We no limit the size of a network to a /30 or bigger, although
tecnically, the ipaddr library supports even /32 networks.

Signed-off-by: Helga Velroyen <hel...@google.com>
---
 lib/network.py |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/lib/network.py b/lib/network.py
index cc3bfd6..be26ef0 100644
--- a/lib/network.py
+++ b/lib/network.py
@@ -55,6 +55,10 @@ class AddressPool(object):
     self.net = network
 
     self.network = ipaddr.IPNetwork(self.net.network)
+    if self.network.numhosts < 4:
+      raise errors.AddressPoolError(
+        "A network of size %s is too small. Please specify at least a "
+        "/30 network." % str(self.network.numhosts))
     if self.net.gateway:
       self.gateway = ipaddr.IPAddress(self.net.gateway)
 
-- 
1.7.7.3

Reply via email to