You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by da...@apache.org on 2015/12/06 20:11:38 UTC

[10/11] git commit: updated refs/heads/master to afe1130

move back to original contract of isNetworksOverlap()

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

Branch: refs/heads/master
Commit: 4b7f87b9c80b792080640a1d7a7a251e254fdc92
Parents: b4c5cd4
Author: Daan Hoogland <da...@onecht.net>
Authored: Sat Nov 21 18:58:54 2015 +0100
Committer: Daan Hoogland <da...@onecht.net>
Committed: Sat Nov 21 18:58:54 2015 +0100

----------------------------------------------------------------------
 .../src/main/java/com/cloud/utils/net/NetUtils.java  | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4b7f87b9/utils/src/main/java/com/cloud/utils/net/NetUtils.java
----------------------------------------------------------------------
diff --git a/utils/src/main/java/com/cloud/utils/net/NetUtils.java b/utils/src/main/java/com/cloud/utils/net/NetUtils.java
index db724f6..90a43fa 100644
--- a/utils/src/main/java/com/cloud/utils/net/NetUtils.java
+++ b/utils/src/main/java/com/cloud/utils/net/NetUtils.java
@@ -1170,14 +1170,15 @@ public class NetUtils {
     }
 
     public static boolean isNetworksOverlap(final String cidrA, final String cidrB) {
-        if (!areCidrsNotEmpty(cidrA, cidrB)) {
-            return false;
+        try {
+            Long[] cidrALong = cidrToLong(cidrA);
+            Long[] cidrBLong = cidrToLong(cidrB);
+            final long shift = MAX_CIDR - (cidrALong[1] > cidrBLong[1] ? cidrBLong[1] : cidrALong[1]);
+            return cidrALong[0] >> shift == cidrBLong[0] >> shift;
+        } catch (CloudRuntimeException e) {
+            s_logger.error(e.getLocalizedMessage(),e);
         }
-        Long[] cidrALong = cidrToLong(cidrA);
-        Long[] cidrBLong = cidrToLong(cidrB);
-
-        final long shift = MAX_CIDR - (cidrALong[1] > cidrBLong[1] ? cidrBLong[1] : cidrALong[1]);
-        return cidrALong[0] >> shift == cidrBLong[0] >> shift;
+        return false;
     }
 
     public static boolean isValidS2SVpnPolicy(final String policys) {