You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@omid.apache.org by oh...@apache.org on 2018/06/10 09:09:22 UTC

incubator-omid git commit: [OMID-97] New MacBooks include a TouchBar that has a usb link called iBridge. When choosing a network interface, Omid accidentally chooses this iBridge instead of choosing the right network interface.

Repository: incubator-omid
Updated Branches:
  refs/heads/master 36f7634cf -> 10d95cd14


[OMID-97] New MacBooks include a TouchBar that has a usb link called iBridge. When choosing a network interface, Omid accidentally chooses this iBridge instead of choosing the right network interface.


Project: http://git-wip-us.apache.org/repos/asf/incubator-omid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-omid/commit/10d95cd1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-omid/tree/10d95cd1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-omid/diff/10d95cd1

Branch: refs/heads/master
Commit: 10d95cd1409e9f61bfa107587a858bb85c448d0a
Parents: 36f7634
Author: Ohad Shacham <oh...@yahoo-inc.com>
Authored: Sun Apr 29 12:47:25 2018 +0300
Committer: Ohad Shacham <oh...@yahoo-inc.com>
Committed: Sun Jun 10 12:09:16 2018 +0300

----------------------------------------------------------------------
 common/src/main/java/org/apache/omid/NetworkUtils.java | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/10d95cd1/common/src/main/java/org/apache/omid/NetworkUtils.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/omid/NetworkUtils.java b/common/src/main/java/org/apache/omid/NetworkUtils.java
index 09bd626..751a733 100644
--- a/common/src/main/java/org/apache/omid/NetworkUtils.java
+++ b/common/src/main/java/org/apache/omid/NetworkUtils.java
@@ -22,6 +22,7 @@ import org.slf4j.LoggerFactory;
 
 import java.net.NetworkInterface;
 import java.net.SocketException;
+import java.util.Collections;
 import java.util.Enumeration;
 
 public class NetworkUtils {
@@ -36,11 +37,14 @@ public class NetworkUtils {
         try {
             Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
             while (networkInterfaces.hasMoreElements()) {
-                String name = networkInterfaces.nextElement().getDisplayName();
+                NetworkInterface nextElement = networkInterfaces.nextElement();
+                String name = nextElement.getDisplayName();
                 LOG.info("Iterating over network interfaces, found '{}'", name);
-                if (name.startsWith(MAC_TSO_NET_IFACE_PREFIX) || name.startsWith(LINUX_TSO_NET_IFACE_PREFIX)) {
-                    return name;
-                }
+                boolean hasInet = Collections.list(nextElement.getInetAddresses()).size() > 1; // Checking that inet exists, to avoid taking iBridge
+                if ((name.startsWith(MAC_TSO_NET_IFACE_PREFIX) && hasInet ) ||
+                        name.startsWith(LINUX_TSO_NET_IFACE_PREFIX)) {
+                  return name;
+              }
             }
         } catch (SocketException ignored) {
             throw new RuntimeException("Failed to find any network interfaces", ignored);