From: Redouane Kachach Date: Thu, 5 May 2022 13:53:49 +0000 (+0200) Subject: mgr/cephadm: fixing ipv6 handling during bootstrap X-Git-Tag: v18.0.0~871^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ae0cbacd1d8d78f41a06fd3b5cd3c0fd693e4c0f;p=ceph.git mgr/cephadm: fixing ipv6 handling during bootstrap Fixes: https://tracker.ceph.com/issues/55556 Signed-off-by: Redouane Kachach --- diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index 0de6dc4e523b..14751939c0ee 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -4638,7 +4638,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 cd946cff14ef..ea683fb377e7 100644 --- a/src/cephadm/tests/test_cephadm.py +++ b/src/cephadm/tests/test_cephadm.py @@ -2270,6 +2270,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