cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject git commit: updated refs/heads/master to 3b5aa42
Date Wed, 13 Aug 2014 13:05:51 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master f6bde7b46 -> 3b5aa42c6


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 <rohit.yadav@shapeblue.com>


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

Branch: refs/heads/master
Commit: 3b5aa42c6d87fb7e2573146efb8c7d2d0a4692b3
Parents: f6bde7b
Author: Rohit Yadav <rohit.yadav@shapeblue.com>
Authored: Wed Aug 13 14:54:26 2014 +0200
Committer: Rohit Yadav <rohit.yadav@shapeblue.com>
Committed: Wed Aug 13 15:04:04 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/3b5aa42c/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 214ce68..dc53e4a 100755
--- a/utils/src/com/cloud/utils/net/MacAddress.java
+++ b/utils/src/com/cloud/utils/net/MacAddress.java
@@ -19,6 +19,8 @@
 
 package com.cloud.utils.net;
 
+import com.cloud.utils.NumbersUtil;
+
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.IOException;
@@ -27,8 +29,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>
@@ -114,8 +114,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;
                 }
             }
 


Mime
View raw message