cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mc...@apache.org
Subject [06/25] git commit: refs/heads/api_entity - CLOUDSTACK-1668: Fix IP conflict in VPC tier
Date Thu, 21 Mar 2013 01:04:20 GMT
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).

The corresponding patch for 4.0.1 has been posted on
https://reviews.apache.org/r/9923/

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/86a2a750
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/86a2a750
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/86a2a750

Branch: refs/heads/api_entity
Commit: 86a2a7504693e2672552fa98b90a60f9fea30196
Parents: 2bebb12
Author: Wei Zhou <w.zhou@leaseweb.com>
Authored: Wed Mar 20 00:26:37 2013 +0000
Committer: Chip Childers <chip.childers@gmail.com>
Committed: Wed Mar 20 00:31:52 2013 +0000

----------------------------------------------------------------------
 server/src/com/cloud/network/NetworkModelImpl.java |    5 +++++
 .../src/com/cloud/network/NetworkServiceImpl.java  |    5 +++++
 utils/src/com/cloud/utils/net/NetUtils.java        |    2 +-
 3 files changed, 11 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/86a2a750/server/src/com/cloud/network/NetworkModelImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkModelImpl.java b/server/src/com/cloud/network/NetworkModelImpl.java
index 779b9f2..40a18c7 100644
--- a/server/src/com/cloud/network/NetworkModelImpl.java
+++ b/server/src/com/cloud/network/NetworkModelImpl.java
@@ -1644,6 +1644,11 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel
{
         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;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/86a2a750/server/src/com/cloud/network/NetworkServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkServiceImpl.java b/server/src/com/cloud/network/NetworkServiceImpl.java
index 52e81e5..8303b0b 100755
--- a/server/src/com/cloud/network/NetworkServiceImpl.java
+++ b/server/src/com/cloud/network/NetworkServiceImpl.java
@@ -2046,6 +2046,11 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService
{
         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;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/86a2a750/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 dd40a33..5988dd5 100755
--- a/utils/src/com/cloud/utils/net/NetUtils.java
+++ b/utils/src/com/cloud/utils/net/NetUtils.java
@@ -632,7 +632,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