]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: fixing ipv6 handling during bootstrap
authorRedouane Kachach <rkachach@redhat.com>
Thu, 5 May 2022 13:53:49 +0000 (15:53 +0200)
committerAdam King <adking@redhat.com>
Tue, 17 May 2022 22:25:14 +0000 (18:25 -0400)
Fixes: https://tracker.ceph.com/issues/55556
Signed-off-by: Redouane Kachach <rkachach@redhat.com>
(cherry picked from commit ae0cbacd1d8d78f41a06fd3b5cd3c0fd693e4c0f)

src/cephadm/cephadm
src/cephadm/tests/test_cephadm.py

index 02893efc5b68b65e5f04f1ff940c782cc9e8e932..b5d342c596ebfb63ee3b5d95135c2ed0060efaa2 100755 (executable)
@@ -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
 
index 4ff942ba357403857d57a0ce8d0b7f9ddb6ea67d..d50cce850305e932e42d108d1011b57a75f4a20a 100644 (file)
@@ -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