code: func (aSpace *addrSpace) updatePoolDBOnAdd(k SubnetKey, nw *net.IPNet, ipr *AddressRange, pdf bool) (func() error, error) {
  	aSpace.Lock()
  	defer aSpace.Unlock()
  
  	// Check if already allocated
  	if _, ok := aSpace.subnets[k]; ok {
  		if pdf {
  			return nil, types.InternalMaskableErrorf("predefined pool %s is already reserved", nw)
  		}
  		// 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 ipr == nil {
  		if aSpace.contains(k.AddressSpace, nw) {
  			return nil, ipamapi.ErrPoolOverlap
  		}
  		// This is a new master pool, add it along with corresponding bitmask
  		aSpace.subnets[k] = &PoolData{Pool: nw, RefCount: 1}
  		return func() error { return aSpace.alloc.insertBitMask(k, nw) }, nil
  	}
  
  	// This is a new non-master pool (subPool)
  	p := &PoolData{
  		ParentKey: SubnetKey{AddressSpace: k.AddressSpace, Subnet: k.Subnet},
  		Pool:      nw,
  		Range:     ipr,
  		RefCount:  1,
  	}
  	aSpace.subnets[k] = p
  
  	// Look for parent pool
  	pp, ok := aSpace.subnets[p.ParentKey]
  	if ok {
  		aSpace.incRefCount(pp, 1)
  		return func() error { return nil }, nil
  	}
  
  	// Parent pool does not exist, add it along with corresponding bitmask
  	aSpace.subnets[p.ParentKey] = &PoolData{Pool: nw, RefCount: 1}
  	return func() error { return aSpace.alloc.insertBitMask(p.ParentKey, nw) }, nil
  }
docs: // updatePoolDBOnAdd returns a closure which will add the subnet k to the address space when executed.