Skip to content

Commit aaa99cd

Browse files
committed
CLOUDSTACK-4596: CloudStack is currently allowing same ip range to be
defined in different VLANs across public and portable ranges added checks to restric same ip range to be configure as both public ip range and portable ip range
1 parent 325c94e commit aaa99cd

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

‎server/src/com/cloud/configuration/ConfigurationManagerImpl.java‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2922,6 +2922,12 @@ public Vlan createVlanAndPublicIpRange(long zoneId, long networkId, long physica
29222922
// Check if there are any errors with the IP range
29232923
checkPublicIpRangeErrors(zoneId, vlanId, vlanGateway, vlanNetmask, startIP, endIP);
29242924

2925+
// check and throw exception if there is portable IP range that overlaps with ip range being configure
2926+
if (checkOverlapPortableIpRange(_regionDao.getRegionId(), startIP, endIP)) {
2927+
throw new InvalidParameterValueException("Ip range: " + startIP + "-" + endIP +
2928+
" overlaps with a portable" + " IP range already configured in the region " + _regionDao.getRegionId());
2929+
}
2930+
29252931
// Throw an exception if this subnet overlaps with subnet on other VLAN,
29262932
// if this is ip range extension, gateway, network mask should be same and ip range should not overlap
29272933

@@ -4809,13 +4815,15 @@ public PortableIpRange createPortableIpRange(CreatePortableIpRangeCmd cmd) throw
48094815
throw new InvalidParameterValueException("Invalid vlan id " + vlanId);
48104816
}
48114817

4812-
// check if there is zone vlan with same id
48134818
List<DataCenterVO> zones= _zoneDao.listAllZones();
48144819
if (zones != null && !zones.isEmpty()) {
48154820
for (DataCenterVO zone: zones) {
4821+
// check if there is zone vlan with same id
48164822
if (_vlanDao.findByZoneAndVlanId(zone.getId(), vlanId) != null)
48174823
throw new InvalidParameterValueException("Found a VLAN id " + vlanId + " already existing in"
48184824
+ " zone " + zone.getUuid() + " that conflicts with VLAN id of the portable ip range being configured");
4825+
//check if there is a public ip range that overlaps with portable ip range being created
4826+
checkOverlapPublicIpRange(zone.getId(), startIP, endIP);
48194827
}
48204828
}
48214829

@@ -4921,6 +4929,11 @@ private boolean checkOverlapPortableIpRange(int regionId, String newStartIpStr,
49214929
long newEndIp = NetUtils.ip2Long(newEndIpStr);
49224930

49234931
List<PortableIpRangeVO> existingPortableIPRanges = _portableIpRangeDao.listByRegionId(regionId);
4932+
4933+
if (existingPortableIPRanges == null || existingPortableIPRanges.isEmpty()) {
4934+
return false;
4935+
}
4936+
49244937
for (PortableIpRangeVO portableIpRange : existingPortableIPRanges) {
49254938
String ipRangeStr = portableIpRange.getIpRange();
49264939
String[] range = ipRangeStr.split("-");

0 commit comments

Comments
 (0)