mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 11:52:28 +01:00
S2S VPN: CS-15810: Add check for customer gateway subnets / VPC CIDR overlap
This commit is contained in:
parent
6ad7f2f80b
commit
96ac18d8ed
@ -209,6 +209,18 @@ public class Site2SiteVpnManagerImpl implements Site2SiteVpnManager, Manager {
|
|||||||
throw new InvalidParameterValueException("The vpn connection with specified customer gateway id " + customerGatewayId +
|
throw new InvalidParameterValueException("The vpn connection with specified customer gateway id " + customerGatewayId +
|
||||||
" already exists!");
|
" 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);
|
Site2SiteVpnConnectionVO conn = new Site2SiteVpnConnectionVO(owner.getAccountId(), owner.getDomainId(), vpnGatewayId, customerGatewayId);
|
||||||
conn.setState(State.Pending);
|
conn.setState(State.Pending);
|
||||||
_vpnConnectionDao.persist(conn);
|
_vpnConnectionDao.persist(conn);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user