cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chipchild...@apache.org
Subject git commit: refs/heads/4.0 - CLOUDSTACK-1668: Fix IP conflict in VPC tier
Date Wed, 20 Mar 2013 00:35:04 GMT
Updated Branches:
  refs/heads/4.0 5c8f3a4c5 -> af0723e9c


CLOUDSTACK-1668: Fix IP conflict in VPC tier

Currently, allPossibleIps return the Ip lists which include the gateway,
so we need to remove gateway ip from this list.

Now, for non-VPC network it works, because NetUtils.getAllIpsFromCidr
return the Ip lists which do not include the first IP of the network
(like 192.168.0.1).
We need too add the first IP into the returned Ip list, because it can
be used for VM if it is not the gateway IP (for example, VPC networks).

Signed-off-by: Chip Childers <chip.childers@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/af0723e9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/af0723e9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/af0723e9

Branch: refs/heads/4.0
Commit: af0723e9c9259619c2cb5d77396e2297f1273a5e
Parents: 5c8f3a4
Author: Wei Zhou <w.zhou@leaseweb.com>
Authored: Wed Mar 20 00:34:17 2013 +0000
Committer: Chip Childers <chip.childers@gmail.com>
Committed: Wed Mar 20 00:34:17 2013 +0000

----------------------------------------------------------------------
 .../src/com/cloud/network/NetworkManagerImpl.java  |    6 +++++-
 utils/src/com/cloud/utils/net/NetUtils.java        |    2 +-
 2 files changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af0723e9/server/src/com/cloud/network/NetworkManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java
index b33c52b..a98bdd4 100755
--- a/server/src/com/cloud/network/NetworkManagerImpl.java
+++ b/server/src/com/cloud/network/NetworkManagerImpl.java
@@ -4846,9 +4846,13 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService,
Manag
         if (usedIps.size() != 0) {
             allPossibleIps.removeAll(usedIps);
         }
+
+        String gateway = network.getGateway();
+        if ((gateway != null) && (allPossibleIps.contains(NetUtils.ip2Long(gateway))))
+            allPossibleIps.remove(NetUtils.ip2Long(gateway));
+
         return allPossibleIps;
     }
-    
 
     private String getZoneNetworkDomain(long zoneId) {
         return _dcDao.findById(zoneId).getDomain();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af0723e9/utils/src/com/cloud/utils/net/NetUtils.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/net/NetUtils.java b/utils/src/com/cloud/utils/net/NetUtils.java
index 1341338..24d8a9e 100755
--- a/utils/src/com/cloud/utils/net/NetUtils.java
+++ b/utils/src/com/cloud/utils/net/NetUtils.java
@@ -628,7 +628,7 @@ public class NetUtils {
         Set<Long> result = new TreeSet<Long>();
         long ip = ip2Long(cidr);
         long startNetMask = ip2Long(getCidrNetmask(size));
-        long start = (ip & startNetMask) + 2;
+        long start = (ip & startNetMask) + 1;
         long end = start;
 
         end = end >> (32 - size);


Mime
View raw message