]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common/pick_address: match against the current iface in pick_iface 69822/head
authorSun Yuechi <sunyuechi@iscas.ac.cn>
Tue, 30 Jun 2026 06:58:24 +0000 (14:58 +0800)
committerKefu Chai <k.chai@proxmox.com>
Wed, 1 Jul 2026 02:06:29 +0000 (10:06 +0800)
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 <sunyuechi@iscas.ac.cn>
src/common/pick_address.cc

index a69c2e9a4ea1092d785ab4c6c5b4cca55d37b442..47823f86b212ccf8c30ae39dd16eca67097347a9 100644 (file)
@@ -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;
     }