Skip to content

Commit ae0cbac

Browse files
committed
mgr/cephadm: fixing ipv6 handling during bootstrap
Fixes: https://tracker.ceph.com/issues/55556 Signed-off-by: Redouane Kachach <[email protected]>
1 parent 42b969b commit ae0cbac

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/cephadm/cephadm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4638,7 +4638,8 @@ def ip_in_subnets(ip_addr: str, subnets: str) -> bool:
46384638
"""Determine if the ip_addr belongs to any of the subnets list."""
46394639
subnet_list = [x.strip() for x in subnets.split(',')]
46404640
for subnet in subnet_list:
4641-
if ipaddress.ip_address(ip_addr) in ipaddress.ip_network(subnet):
4641+
ip_address = unwrap_ipv6(ip_addr) if is_ipv6(ip_addr) else ip_addr
4642+
if ipaddress.ip_address(ip_address) in ipaddress.ip_network(subnet):
46424643
return True
46434644
return False
46444645

src/cephadm/tests/test_cephadm.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2270,6 +2270,10 @@ def test_ip_in_subnet(self):
22702270
rc = cd.ip_in_subnets('fe80::5054:ff:fef4:873a', 'fe80::/64')
22712271
assert rc is True
22722272

2273+
# valid wrapped ip and valid IPV6 network
2274+
rc = cd.ip_in_subnets('[fe80::5054:ff:fef4:873a]', 'fe80::/64')
2275+
assert rc is True
2276+
22732277
# valid ip and that doesn't belong to IPV6 network
22742278
rc = cd.ip_in_subnets('fe80::5054:ff:fef4:873a', '2001:db8:85a3::/64')
22752279
assert rc is False

0 commit comments

Comments
 (0)