You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2014/09/01 16:15:35 UTC

[1/2] git commit: updated refs/heads/4.3 to 514c2ef

Repository: cloudstack
Updated Branches:
  refs/heads/4.3 f5483eeea -> 514c2ef0f


CLOUDSTACK-4770: In MacAddress skip macAddress when parsed value is 0x00

In MacAddress class, we start by settig macAddress String as null and go through
the output of ifconfig -a and pick the one string that is a valid mac address
but is not 0x00 and 0xff. With each loop we set the macAddress to null so that
it does not pick the last one if everything fails.

Tested on Ubuntu where I had an interface called cloud0 whose mac id was 0x00
and it was skipped to get the next one:

$ java -classpath <path-to-cloud-utils.jar> com.cloud.utils.net.MacAddress
addr in integer is 5071953436
addr in bytes is  0 1 2e 4f de 1c
addr in char is 00:01:2e:4f:de:1c

Signed-off-by: Rohit Yadav <ro...@shapeblue.com>
(cherry picked from commit 3b5aa42c6d87fb7e2573146efb8c7d2d0a4692b3)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/4.3
Commit: 435fa225c6f9dd5a666cf58699bc078865ff2419
Parents: f5483ee
Author: Rohit Yadav <ro...@shapeblue.com>
Authored: Wed Aug 13 14:54:26 2014 +0200
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Mon Sep 1 16:06:48 2014 +0200

----------------------------------------------------------------------
 utils/src/com/cloud/utils/net/MacAddress.java | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435fa225/utils/src/com/cloud/utils/net/MacAddress.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/net/MacAddress.java b/utils/src/com/cloud/utils/net/MacAddress.java
index 15350c8..70a45ea 100755
--- a/utils/src/com/cloud/utils/net/MacAddress.java
+++ b/utils/src/com/cloud/utils/net/MacAddress.java
@@ -16,6 +16,8 @@
 // under the License.
 package com.cloud.utils.net;
 
+import com.cloud.utils.NumbersUtil;
+
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.IOException;
@@ -24,8 +26,6 @@ import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.util.Formatter;
 
-import com.cloud.utils.NumbersUtil;
-
 /**
  * copied from the public domain utility from John Burkard.
  * @author <a href="mailto:jb@eaio.com">Johann Burkard</a>
@@ -117,8 +117,12 @@ public class MacAddress {
                 String l = null;
                 while ((l = in.readLine()) != null) {
                     macAddress = MacAddress.parse(l);
-                    if (macAddress != null && MacAddress.parseShort(macAddress) != 0xff)
-                        break;
+                    if (macAddress != null) {
+                        short parsedShortMacAddress = MacAddress.parseShort(macAddress);
+                        if (parsedShortMacAddress != 0xff && parsedShortMacAddress != 0x00)
+                            break;
+                    }
+                    macAddress = null;
                 }
             }
 


[2/2] git commit: updated refs/heads/4.3 to 514c2ef

Posted by bh...@apache.org.
NetUtils: Check for NPE in getDefaultHostIp method when processing nic/mac

On hosts or containers where they don't have valid mac address on nic resulting
in null, NetUtils.getNetworkParam can throw NPE.

This was a case found on TravisCI where OpenVZ containers are used. This method
(getDefaultHostIp) is used at several other places within the ACS codebase to
get the host IP and if null is caught we fallback to localhost or 127.0.0.1, so
we therefore set info to null before trying to process network param and if we
fail we return null and expect other layers to use localhost.

Signed-off-by: Rohit Yadav <ro...@shapeblue.com>
(cherry picked from commit 7ada4ad50b683268f4031ff05e9d19d15d2c35f1)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>

Conflicts:
	utils/src/com/cloud/utils/net/NetUtils.java


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

Branch: refs/heads/4.3
Commit: 514c2ef0fbeebb039bf294f793fdd8268791d910
Parents: 435fa22
Author: Rohit Yadav <ro...@shapeblue.com>
Authored: Thu Aug 21 11:35:38 2014 +0200
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Mon Sep 1 16:09:36 2014 +0200

----------------------------------------------------------------------
 utils/src/com/cloud/utils/net/NetUtils.java | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/514c2ef0/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 1c94b71..f7446b7 100755
--- a/utils/src/com/cloud/utils/net/NetUtils.java
+++ b/utils/src/com/cloud/utils/net/NetUtils.java
@@ -195,8 +195,16 @@ public class NetUtils {
                 return null;
             }
 
-            String[] info = NetUtils.getNetworkParams(nic);
-            return info[0];
+            String[] info = null;
+            try {
+                info = NetUtils.getNetworkParams(nic);
+            } catch (NullPointerException ignored) {
+                s_logger.debug("Caught NullPointerException when trying to getDefaultHostIp");
+            }
+            if (info != null) {
+                return info[0];
+            }
+            return null;
         }
     }