From: Sun Yuechi Date: Tue, 30 Jun 2026 06:58:24 +0000 (+0800) Subject: common/pick_address: match against the current iface in pick_iface X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=29017afa1a79e577b8527188f0d915d6e1de44a9;p=ceph.git common/pick_address: match against the current iface in pick_iface The loop iterated over addr but always passed the list head *ifa to matches_with_net, so it only ever tested the first interface while returning the iterated interface's name. Match against *addr. Fixes: https://tracker.ceph.com/issues/77847 Signed-off-by: Sun Yuechi --- diff --git a/src/common/pick_address.cc b/src/common/pick_address.cc index a69c2e9a4ea1..47823f86b212 100644 --- a/src/common/pick_address.cc +++ b/src/common/pick_address.cc @@ -531,7 +531,7 @@ std::string pick_iface(CephContext *cct, const struct sockaddr_storage &network) auto free_ifa = make_scope_guard([ifa] { freeifaddrs(ifa); }); const unsigned int prefix_len = std::max(sizeof(in_addr::s_addr), sizeof(in6_addr::s6_addr)) * CHAR_BIT; for (auto addr = ifa; addr != nullptr; addr = addr->ifa_next) { - if (matches_with_net(*ifa, (const struct sockaddr *) &network, prefix_len, + if (matches_with_net(*addr, (const struct sockaddr *) &network, prefix_len, CEPH_PICK_ADDRESS_IPV4 | CEPH_PICK_ADDRESS_IPV6)) { return addr->ifa_name; }