From: Redouane Kachach Date: Thu, 5 May 2022 13:53:49 +0000 (+0200) Subject: mgr/cephadm: fixing ipv6 handling during bootstrap X-Git-Tag: v16.2.11~86^2~8^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=f6dc000b66536fcb2c1a970635a31d934d0db9d5;p=ceph.git mgr/cephadm: fixing ipv6 handling during bootstrap Fixes: https://tracker.ceph.com/issues/55556 Signed-off-by: Redouane Kachach (cherry picked from commit ae0cbacd1d8d78f41a06fd3b5cd3c0fd693e4c0f) --- diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index 02893efc5b68b..b5d342c596ebf 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -3916,7 +3916,8 @@ def ip_in_subnets(ip_addr: str, subnets: str) -> bool: """Determine if the ip_addr belongs to any of the subnets list.""" subnet_list = [x.strip() for x in subnets.split(',')] for subnet in subnet_list: - if ipaddress.ip_address(ip_addr) in ipaddress.ip_network(subnet): + ip_address = unwrap_ipv6(ip_addr) if is_ipv6(ip_addr) else ip_addr + if ipaddress.ip_address(ip_address) in ipaddress.ip_network(subnet): return True return False diff --git a/src/cephadm/tests/test_cephadm.py b/src/cephadm/tests/test_cephadm.py index 4ff942ba35740..d50cce850305e 100644 --- a/src/cephadm/tests/test_cephadm.py +++ b/src/cephadm/tests/test_cephadm.py @@ -2282,6 +2282,10 @@ class TestNetworkValidation: rc = cd.ip_in_subnets('fe80::5054:ff:fef4:873a', 'fe80::/64') assert rc is True + # valid wrapped ip and valid IPV6 network + rc = cd.ip_in_subnets('[fe80::5054:ff:fef4:873a]', 'fe80::/64') + assert rc is True + # valid ip and that doesn't belong to IPV6 network rc = cd.ip_in_subnets('fe80::5054:ff:fef4:873a', '2001:db8:85a3::/64') assert rc is False