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 6ad7f2f80b
commit 96ac18d8ed

View File

@ -209,6 +209,18 @@ public class Site2SiteVpnManagerImpl implements Site2SiteVpnManager, Manager {
throw new InvalidParameterValueException("The vpn connection with specified customer gateway id " + customerGatewayId +
" already exists!");
}
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);