mirror of
https://github.com/ceph/ceph
synced 2025-03-20 09:16:59 +00:00
Merge pull request #57590 from NitzanMordhai/wip-66141-reef
reef: common/pick_address: check if address in subnet all public address Reviewed-by: Laura Flores <lflores@redhat.com>
This commit is contained in:
commit
1f7fb81be4
@ -638,15 +638,24 @@ bool is_addr_in_subnet(
|
||||
{
|
||||
const auto nets = get_str_list(networks);
|
||||
ceph_assert(!nets.empty());
|
||||
const auto &net = nets.front();
|
||||
struct ifaddrs ifa;
|
||||
|
||||
unsigned ipv = CEPH_PICK_ADDRESS_IPV4;
|
||||
struct sockaddr_in public_addr;
|
||||
|
||||
ifa.ifa_next = nullptr;
|
||||
ifa.ifa_addr = (struct sockaddr*)&public_addr;
|
||||
public_addr.sin_family = AF_INET;
|
||||
inet_pton(AF_INET, addr.c_str(), &public_addr.sin_addr);
|
||||
|
||||
return matches_with_net(cct, ifa, net, ipv);
|
||||
if(inet_pton(AF_INET, addr.c_str(), &public_addr.sin_addr) != 1) {
|
||||
lderr(cct) << "unable to convert chosen address to string: " << addr << dendl;
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const auto &net : nets) {
|
||||
struct ifaddrs ifa;
|
||||
memset(&ifa, 0, sizeof(ifa));
|
||||
ifa.ifa_next = nullptr;
|
||||
ifa.ifa_addr = (struct sockaddr*)&public_addr;
|
||||
if(matches_with_net(cct, ifa, net, ipv)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user