]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
pick_address: error out in dual stack mode if both addr types cannot be provided
authorRicardo Dias <rdias@suse.com>
Thu, 28 Feb 2019 11:02:04 +0000 (11:02 +0000)
committerRicardo Dias <rdias@suse.com>
Thu, 28 Feb 2019 16:21:13 +0000 (16:21 +0000)
When ms_bind_ipv4 and ms_bind_ipv6 options are enabled, if the
public_network or cluster_network settings only contain networks of a
single type (either IPv4 or IPv6) then pick_addresses function must
fail.

Fixes: http://tracker.ceph.com/issues/38307
Signed-off-by: Ricardo Dias <rdias@suse.com>
src/common/pick_address.cc

index a009a5b18647b2f809fc80d8fa6dbe611be4a997..7b284925d51fc31d995d771076f5c5475bf9e565 100644 (file)
@@ -339,31 +339,33 @@ int pick_addresses(
   }
   if (addr.is_blank_ip() &&
       !networks.empty()) {
+    int ipv4_r = !(ipv & CEPH_PICK_ADDRESS_IPV4) ? 0 : -1;
+    int ipv6_r = !(ipv & CEPH_PICK_ADDRESS_IPV6) ? 0 : -1;
     // first try on preferred numa node (if >= 0), then anywhere.
     while (true) {
       // note: pass in ipv to filter the matching addresses
-      int r = 0;
       if ((ipv & CEPH_PICK_ADDRESS_IPV4) &&
          (flags & CEPH_PICK_ADDRESS_PREFER_IPV4)) {
-       r = fill_in_one_address(cct, ifa, CEPH_PICK_ADDRESS_IPV4, networks,
-                               interfaces, addrs, preferred_numa_node);
+       ipv4_r = fill_in_one_address(cct, ifa, CEPH_PICK_ADDRESS_IPV4,
+                                     networks, interfaces, addrs,
+                                     preferred_numa_node);
       }
-      if (r >= 0 &&
-         (ipv & CEPH_PICK_ADDRESS_IPV6)) {
-       r = fill_in_one_address(cct, ifa, CEPH_PICK_ADDRESS_IPV6, networks,
-                               interfaces, addrs, preferred_numa_node);
+      if (ipv & CEPH_PICK_ADDRESS_IPV6) {
+       ipv6_r = fill_in_one_address(cct, ifa, CEPH_PICK_ADDRESS_IPV6,
+                                     networks, interfaces, addrs,
+                                     preferred_numa_node);
       }
-      if (r >= 0 &&
-         (ipv & CEPH_PICK_ADDRESS_IPV4) &&
+      if ((ipv & CEPH_PICK_ADDRESS_IPV4) &&
          !(flags & CEPH_PICK_ADDRESS_PREFER_IPV4)) {
-       r = fill_in_one_address(cct, ifa, CEPH_PICK_ADDRESS_IPV4, networks,
-                               interfaces, addrs, preferred_numa_node);
+       ipv4_r = fill_in_one_address(cct, ifa, CEPH_PICK_ADDRESS_IPV4,
+                                     networks, interfaces, addrs,
+                                     preferred_numa_node);
       }
-      if (r >= 0) {
+      if (ipv4_r >= 0 && ipv6_r >= 0) {
        break;
       }
       if (preferred_numa_node < 0) {
-       return r;
+       return ipv4_r >= 0 && ipv6_r >= 0 ? 0 : -1;
       }
       preferred_numa_node = -1;      // try any numa node
     }