From: Redouane Kachach Date: Thu, 5 May 2022 13:53:49 +0000 (+0200) Subject: mgr/cephadm: fixing ipv6 handling during bootstrap X-Git-Tag: v17.2.1~48^2~36 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fa27a1cef2f684b926c612692c47ca5043900875;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 1480b2c069f9..27f1db137794 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -4633,7 +4633,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 2995665a4114..1e71caed84f0 100644 --- a/src/cephadm/tests/test_cephadm.py +++ b/src/cephadm/tests/test_cephadm.py @@ -2301,6 +2301,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