Skip to content

Commit 3e2ef5e

Browse files
committed
common/pick_address: check if address in subnet all public address
When mon trying to check if osd joining within subnet address, it will check only the first subnet and not the rest of the subnets. this fix will loop over all the other subnet for checks. Fixes: https://tracker.ceph.com/issues/65186 Signed-off-by: Nitzan Mordechai <[email protected]>
1 parent 107e162 commit 3e2ef5e

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/common/pick_address.cc

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -644,15 +644,24 @@ bool is_addr_in_subnet(
644644
{
645645
const auto nets = get_str_list(networks);
646646
ceph_assert(!nets.empty());
647-
const auto &net = nets.front();
648-
struct ifaddrs ifa;
647+
649648
unsigned ipv = CEPH_PICK_ADDRESS_IPV4;
650649
struct sockaddr_in public_addr;
651-
652-
ifa.ifa_next = nullptr;
653-
ifa.ifa_addr = (struct sockaddr*)&public_addr;
654650
public_addr.sin_family = AF_INET;
655-
inet_pton(AF_INET, addr.c_str(), &public_addr.sin_addr);
656651

657-
return matches_with_net(cct, ifa, net, ipv);
652+
if(inet_pton(AF_INET, addr.c_str(), &public_addr.sin_addr) != 1) {
653+
lderr(cct) << "unable to convert chosen address to string: " << addr << dendl;
654+
return false;
655+
}
656+
657+
for (const auto &net : nets) {
658+
struct ifaddrs ifa;
659+
memset(&ifa, 0, sizeof(ifa));
660+
ifa.ifa_next = nullptr;
661+
ifa.ifa_addr = (struct sockaddr*)&public_addr;
662+
if(matches_with_net(cct, ifa, net, ipv)) {
663+
return true;
664+
}
665+
}
666+
return false;
658667
}

0 commit comments

Comments
 (0)