S2S VPN: CS-15810: Add check for customer gateway subnets / VPC CIDR overlap

This commit is contained in:
Sheng Yang 2012-08-01 15:18:19 -07:00
parent 751ebce589
commit 4ddc002764
1 changed files with 12 additions and 0 deletions

View File

@ -217,6 +217,18 @@ public class Site2SiteVpnManagerImpl implements Site2SiteVpnManager, Manager {
throw new InvalidParameterValueException("The vpn connection with specified customer gateway id " +
" already exists!", idList);
}
String[] cidrList = customerGateway.getGuestCidrList().split(",");
String vpcCidr = _vpcDao.findById(vpnGateway.getVpcId()).getCidr();
for (String cidr : cidrList) {
if (NetUtils.isNetworksOverlap(vpcCidr, cidr)) {
List<IdentityProxy> idList = new ArrayList<IdentityProxy>();
idList.add(new IdentityProxy(customerGateway, customerGatewayId, "customerGatewayId"));
throw new InvalidParameterValueException("The subnet of customer gateway " + cidr + " is overlapped with VPC cidr " +
vpcCidr + "!", idList);
}
}
Site2SiteVpnConnectionVO conn = new Site2SiteVpnConnectionVO(owner.getAccountId(), owner.getDomainId(), vpnGatewayId, customerGatewayId);
conn.setState(State.Pending);
_vpnConnectionDao.persist(conn);