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.1 - CLOUDSTACK-1668: Fix IP conflict in VPC tier
Date Wed, 20 Mar 2013 00:31:15 GMT
Updated Branches:
  refs/heads/4.1 7802a62d5 -> 0ce1d4fde


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

Branch: refs/heads/4.1
Commit: 0ce1d4fde1fb9e68ed83a9e094133701abbee291
Parents: 7802a62
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:26:37 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/0ce1d4fd/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 6fa8bde..3c7329f 100644
--- a/server/src/com/cloud/network/NetworkModelImpl.java
+++ b/server/src/com/cloud/network/NetworkModelImpl.java
@@ -1639,6 +1639,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/0ce1d4fd/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 5e33d75..0cd3ebe 100755
--- a/server/src/com/cloud/network/NetworkServiceImpl.java
+++ b/server/src/com/cloud/network/NetworkServiceImpl.java
@@ -1751,6 +1751,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/0ce1d4fd/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