Browse Source

Merge branch 'candidate-4.2.6' into candidate-5.0.0

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 11 years ago
parent
commit
79bc0c79c1
1 changed files with 8 additions and 1 deletions
  1. 8 1
      system/jlib/jsocket.cpp

+ 8 - 1
system/jlib/jsocket.cpp

@@ -2580,7 +2580,14 @@ bool getInterfaceIp(IpAddress &ip,const char *ifname)
                 if (!WildMatch(item->ifr_name,ifname))
                     continue;
             IpAddress iptest((inet_ntoa(((struct sockaddr_in *)&item->ifr_addr)->sin_addr)));
-            if (iptest.isLoopBack() == useLoopback)
+            if (ioctl(fd, SIOCGIFFLAGS, item) < 0)
+            {
+                DBGLOG("Error retrieving interface flags for interface %s", item->ifr_name);
+                continue;
+            }
+            bool isLoopback = iptest.isLoopBack() || ((item->ifr_flags & IFF_LOOPBACK) != 0);
+            bool isUp = (item->ifr_flags & IFF_UP) != 0;
+            if ((isLoopback==useLoopback) && isUp)
             {
                 if (ip.isNull())
                     ip.ipset(iptest);