]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
pick_address: don't bother checking struct ifaddrs which have a null ifa_addr
authorGreg Farnum <gregory.farnum@dreamhost.com>
Thu, 26 Apr 2012 01:17:53 +0000 (18:17 -0700)
committerSage Weil <sage@newdream.net>
Tue, 1 May 2012 00:24:03 +0000 (17:24 -0700)
I assume that's the localhost interface or similar.

Signed-off-by: Greg Farnum <gregory.farnum@dreamhost.com>
src/common/pick_address.cc

index 20f300ae78a9d1433a48532d5e83eb3e7a361363..a9788331761dcc1bb1baea58c9e8729e21dc6eb5 100644 (file)
@@ -96,13 +96,15 @@ bool have_local_addr(CephContext *cct, const list<entity_addr_t>& ls, entity_add
 
   bool found = false;
   for (struct ifaddrs *addrs = ifa; addrs != NULL; addrs = addrs->ifa_next) {
-    entity_addr_t a;
-    a.set_sockaddr(addrs->ifa_addr);
-    for (list<entity_addr_t>::const_iterator p = ls.begin(); p != ls.end(); ++p) {
-      if (a.is_same_host(*p)) {
-       *match = *p;
-       found = true;
-       goto out;
+    if (addrs->ifa_addr) {
+      entity_addr_t a;
+      a.set_sockaddr(addrs->ifa_addr);
+      for (list<entity_addr_t>::const_iterator p = ls.begin(); p != ls.end(); ++p) {
+        if (a.is_same_host(*p)) {
+          *match = *p;
+          found = true;
+          goto out;
+        }
       }
     }
   }