Explorar el Código

Add check for overlapping subnets

Signed-off-by: Abhinandan Prativadi <abhi@docker.com>
Abhinandan Prativadi hace 7 años
padre
commit
9fe5cc10b2
Se han modificado 1 ficheros con 4 adiciones y 3 borrados
  1. 4 3
      libnetwork/ipam/structures.go

+ 4 - 3
libnetwork/ipam/structures.go

@@ -262,12 +262,13 @@ func (aSpace *addrSpace) updatePoolDBOnAdd(k SubnetKey, nw *net.IPNet, ipr *Addr
 	defer aSpace.Unlock()
 	defer aSpace.Unlock()
 
 
 	// Check if already allocated
 	// Check if already allocated
-	if p, ok := aSpace.subnets[k]; ok {
+	if _, ok := aSpace.subnets[k]; ok {
 		if pdf {
 		if pdf {
 			return nil, types.InternalMaskableErrorf("predefined pool %s is already reserved", nw)
 			return nil, types.InternalMaskableErrorf("predefined pool %s is already reserved", nw)
 		}
 		}
-		aSpace.incRefCount(p, 1)
-		return func() error { return nil }, nil
+		// This means the same pool is already allocated. updatePoolDBOnAdd is called when there
+		// is request for a pool/subpool. It should ensure there is no overlap with existing pools
+		return nil, ipamapi.ErrPoolOverlap
 	}
 	}
 
 
 	// If master pool, check for overlap
 	// If master pool, check for overlap