@@ -858,11 +858,11 @@ public boolean shutdownVpc(long vpcId) throws ConcurrentOperationException, Reso
858858 @ Override
859859 @ DB
860860 public void validateGuestNtkwForVpc (NetworkOffering guestNtwkOff , String cidr , String networkDomain ,
861- Account networkOwner , Vpc vpc , Long networkId ) {
862-
861+ Account networkOwner , Vpc vpc , Long networkId , String gateway ) {
862+
863863 if (networkId == null ) {
864864 //1) Validate attributes that has to be passed in when create new guest network
865- validateNewVpcGuestNetwork (cidr , networkOwner , vpc , networkDomain );
865+ validateNewVpcGuestNetwork (cidr , gateway , networkOwner , vpc , networkDomain );
866866 }
867867
868868 //2) Only Isolated networks with Source nat service enabled can be added to vpc
@@ -914,7 +914,7 @@ public void validateGuestNtkwForVpc(NetworkOffering guestNtwkOff, String cidr, S
914914
915915 }
916916
917- protected void validateNewVpcGuestNetwork (String cidr , Account networkOwner , Vpc vpc , String networkDomain ) {
917+ protected void validateNewVpcGuestNetwork (String cidr , String gateway , Account networkOwner , Vpc vpc , String networkDomain ) {
918918 Vpc locked = _vpcDao .acquireInLockTable (vpc .getId ());
919919 if (locked == null ) {
920920 throw new CloudRuntimeException ("Unable to acquire lock on " + vpc );
@@ -954,6 +954,12 @@ protected void validateNewVpcGuestNetwork(String cidr, Account networkOwner, Vpc
954954 throw new InvalidParameterValueException ("Network domain of the new network should match network" +
955955 " domain of vpc " + vpc );
956956 }
957+
958+ //6) gateway should never be equal to the cidr subnet
959+ if (NetUtils .getCidrSubNet (cidr ).equalsIgnoreCase (gateway )) {
960+ throw new InvalidParameterValueException ("Invalid gateway specified. It should never be equal to the cidr subnet value" );
961+ }
962+
957963 } finally {
958964 s_logger .debug ("Releasing lock for " + locked );
959965 _vpcDao .releaseFromLockTable (locked .getId ());
0 commit comments