From 9f1ab992654a261f8be05cda19b7d527bac8c2eb Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Tue, 9 Aug 2022 08:07:52 +0000 Subject: [PATCH 1/4] Support basic IPv6 --- supervisor/const.py | 1 + supervisor/docker/network.py | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/supervisor/const.py b/supervisor/const.py index f504a702b44..c618ce69e94 100644 --- a/supervisor/const.py +++ b/supervisor/const.py @@ -38,6 +38,7 @@ DOCKER_NETWORK = "hassio" DOCKER_NETWORK_MASK = ip_network("172.30.32.0/23") DOCKER_NETWORK_RANGE = ip_network("172.30.33.0/24") +DOCKER_NETWORK_LINK_LOCAL = ip_network("fd00:172:30:32::/64") # This needs to match the dockerd --cpu-rt-runtime= argument. DOCKER_CPU_RUNTIME_TOTAL = 950_000 diff --git a/supervisor/docker/network.py b/supervisor/docker/network.py index 7b6179bbdc5..39367dd9549 100644 --- a/supervisor/docker/network.py +++ b/supervisor/docker/network.py @@ -7,7 +7,12 @@ import docker import requests -from ..const import DOCKER_NETWORK, DOCKER_NETWORK_MASK, DOCKER_NETWORK_RANGE +from ..const import ( + DOCKER_NETWORK, + DOCKER_NETWORK_LINK_LOCAL, + DOCKER_NETWORK_MASK, + DOCKER_NETWORK_RANGE, +) from ..exceptions import DockerError _LOGGER: logging.Logger = logging.getLogger(__name__) @@ -80,19 +85,26 @@ def _get_network(self) -> docker.models.networks.Network: except docker.errors.NotFound: _LOGGER.info("Can't find Supervisor network, creating a new network") - ipam_pool = docker.types.IPAMPool( + # IP configuration + ipam_pool_v4 = docker.types.IPAMPool( subnet=str(DOCKER_NETWORK_MASK), gateway=str(self.gateway), iprange=str(DOCKER_NETWORK_RANGE), ) + ipam_pool_v6 = docker.types.IPAMPool( + subnet=str(DOCKER_NETWORK_LINK_LOCAL), + gateway=str(self.gateway), + iprange=str(DOCKER_NETWORK_LINK_LOCAL), + ) - ipam_config = docker.types.IPAMConfig(pool_configs=[ipam_pool]) + ipam_config = docker.types.IPAMConfig(pool_configs=[ipam_pool_v4, ipam_pool_v6]) + # Create Network return self.docker.networks.create( DOCKER_NETWORK, driver="bridge", ipam=ipam_config, - enable_ipv6=False, + enable_ipv6=True, options={"com.docker.network.bridge.name": DOCKER_NETWORK}, ) From 006db94cc07237697c8d861bcbfd80aef38644f5 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Tue, 9 Aug 2022 08:32:16 +0000 Subject: [PATCH 2/4] fix gateway --- supervisor/docker/network.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/supervisor/docker/network.py b/supervisor/docker/network.py index 39367dd9549..8c62573e85f 100644 --- a/supervisor/docker/network.py +++ b/supervisor/docker/network.py @@ -93,7 +93,7 @@ def _get_network(self) -> docker.models.networks.Network: ) ipam_pool_v6 = docker.types.IPAMPool( subnet=str(DOCKER_NETWORK_LINK_LOCAL), - gateway=str(self.gateway), + gateway=str(DOCKER_NETWORK_LINK_LOCAL[1]), iprange=str(DOCKER_NETWORK_LINK_LOCAL), ) From 5c0172440afd214de4892728824bfb0a1b39db94 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Tue, 9 Aug 2022 11:18:33 +0000 Subject: [PATCH 3/4] change name --- supervisor/const.py | 2 +- supervisor/docker/network.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/supervisor/const.py b/supervisor/const.py index c618ce69e94..b38dad7b9ac 100644 --- a/supervisor/const.py +++ b/supervisor/const.py @@ -38,7 +38,7 @@ DOCKER_NETWORK = "hassio" DOCKER_NETWORK_MASK = ip_network("172.30.32.0/23") DOCKER_NETWORK_RANGE = ip_network("172.30.33.0/24") -DOCKER_NETWORK_LINK_LOCAL = ip_network("fd00:172:30:32::/64") +DOCKER_NETWORK_ULA = ip_network("fd00:172:30:32::/64") # This needs to match the dockerd --cpu-rt-runtime= argument. DOCKER_CPU_RUNTIME_TOTAL = 950_000 diff --git a/supervisor/docker/network.py b/supervisor/docker/network.py index 8c62573e85f..fd6c11f3118 100644 --- a/supervisor/docker/network.py +++ b/supervisor/docker/network.py @@ -9,9 +9,9 @@ from ..const import ( DOCKER_NETWORK, - DOCKER_NETWORK_LINK_LOCAL, DOCKER_NETWORK_MASK, DOCKER_NETWORK_RANGE, + DOCKER_NETWORK_ULA, ) from ..exceptions import DockerError @@ -92,9 +92,9 @@ def _get_network(self) -> docker.models.networks.Network: iprange=str(DOCKER_NETWORK_RANGE), ) ipam_pool_v6 = docker.types.IPAMPool( - subnet=str(DOCKER_NETWORK_LINK_LOCAL), - gateway=str(DOCKER_NETWORK_LINK_LOCAL[1]), - iprange=str(DOCKER_NETWORK_LINK_LOCAL), + subnet=str(DOCKER_NETWORK_ULA), + gateway=str(DOCKER_NETWORK_ULA[1]), + iprange=str(DOCKER_NETWORK_ULA), ) ipam_config = docker.types.IPAMConfig(pool_configs=[ipam_pool_v4, ipam_pool_v6]) From 2470d16d85fe2643a050927aec2a125ad6e5ef50 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Tue, 9 Aug 2022 14:36:56 +0000 Subject: [PATCH 4/4] Cleanup --- supervisor/docker/network.py | 1 - 1 file changed, 1 deletion(-) diff --git a/supervisor/docker/network.py b/supervisor/docker/network.py index fd6c11f3118..4f55842245c 100644 --- a/supervisor/docker/network.py +++ b/supervisor/docker/network.py @@ -94,7 +94,6 @@ def _get_network(self) -> docker.models.networks.Network: ipam_pool_v6 = docker.types.IPAMPool( subnet=str(DOCKER_NETWORK_ULA), gateway=str(DOCKER_NETWORK_ULA[1]), - iprange=str(DOCKER_NETWORK_ULA), ) ipam_config = docker.types.IPAMConfig(pool_configs=[ipam_pool_v4, ipam_pool_v6])