mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-12-21 13:47:50 +00:00
Don't release NIO UDP ports when updating docker container.
When a docker container was updated, the NIO UDP ports were being released from port_manager, but they were still stored in self._ethernet_adapters. When the container was restarted, the same NIO ports would be used. However, if a new connection was then added, it could assign a port that was already in use. The end result was that traffic would be bridged across the wrong interface connection.
This commit is contained in:
parent
45edc40948
commit
b2e0a1b291
@ -386,7 +386,8 @@ class DockerVM(BaseNode):
|
|||||||
aux = self.aux
|
aux = self.aux
|
||||||
state = yield from self._get_container_state()
|
state = yield from self._get_container_state()
|
||||||
|
|
||||||
yield from self.reset()
|
# reset the docker container, but don't release the NIO UDP ports
|
||||||
|
yield from self.reset(False)
|
||||||
yield from self.create()
|
yield from self.create()
|
||||||
self.console = console
|
self.console = console
|
||||||
self.aux = aux
|
self.aux = aux
|
||||||
@ -680,7 +681,8 @@ class DockerVM(BaseNode):
|
|||||||
yield from self.reset()
|
yield from self.reset()
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def reset(self):
|
def reset(self, release_nio_udp_ports=True):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
state = yield from self._get_container_state()
|
state = yield from self._get_container_state()
|
||||||
if state == "paused" or state == "running":
|
if state == "paused" or state == "running":
|
||||||
@ -706,11 +708,12 @@ class DockerVM(BaseNode):
|
|||||||
log.info("Docker container '{name}' [{image}] removed".format(
|
log.info("Docker container '{name}' [{image}] removed".format(
|
||||||
name=self._name, image=self._image))
|
name=self._name, image=self._image))
|
||||||
|
|
||||||
for adapter in self._ethernet_adapters:
|
if release_nio_udp_ports:
|
||||||
if adapter is not None:
|
for adapter in self._ethernet_adapters:
|
||||||
for nio in adapter.ports.values():
|
if adapter is not None:
|
||||||
if nio and isinstance(nio, NIOUDP):
|
for nio in adapter.ports.values():
|
||||||
self.manager.port_manager.release_udp_port(nio.lport, self._project)
|
if nio and isinstance(nio, NIOUDP):
|
||||||
|
self.manager.port_manager.release_udp_port(nio.lport, self._project)
|
||||||
# Ignore runtime error because when closing the server
|
# Ignore runtime error because when closing the server
|
||||||
except (DockerHttp404Error, RuntimeError) as e:
|
except (DockerHttp404Error, RuntimeError) as e:
|
||||||
log.debug("Docker error when closing: {}".format(str(e)))
|
log.debug("Docker error when closing: {}".format(str(e)))
|
||||||
|
Loading…
Reference in New Issue
Block a user