]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: fixing ipv6 handling during bootstrap 46163/head
authorRedouane Kachach <rkachach@redhat.com>
Thu, 5 May 2022 13:53:49 +0000 (15:53 +0200)
committerRedouane Kachach <rkachach@redhat.com>
Thu, 5 May 2022 13:58:27 +0000 (15:58 +0200)
Fixes: https://tracker.ceph.com/issues/55556
Signed-off-by: Redouane Kachach <rkachach@redhat.com>
src/cephadm/cephadm
src/cephadm/tests/test_cephadm.py

index 0de6dc4e523b3c4d0214da98280f7c55e8d52f10..14751939c0ee2710ca7bf937235adaa215fc6fe6 100755 (executable)
@@ -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
 
index cd946cff14efb9eadc67c1a48cd11c1eec613c09..ea683fb377e7a6493251c74b2567f8f25630c618 100644 (file)
@@ -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