From: Ricardo Dias Date: Thu, 28 Feb 2019 11:02:04 +0000 (+0000) Subject: pick_address: error out in dual stack mode if both addr types cannot be provided X-Git-Tag: v14.1.1~82^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=89a6c39e94166131f14198ee7830555661173495;p=ceph.git pick_address: error out in dual stack mode if both addr types cannot be provided 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 --- diff --git a/src/common/pick_address.cc b/src/common/pick_address.cc index a009a5b18647..7b284925d51f 100644 --- a/src/common/pick_address.cc +++ b/src/common/pick_address.cc @@ -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 }