Check interface is up before connecting a NIO (Linux only). Fixes #277.

This commit is contained in:
grossmj committed 2015-06-07 13:51:33 -06:00
1 parent 81d417a2b3
commit 042472f02c
3 files changed
+39 -2

No files matched your search

+7 -1
View File
@@ -28,6 +28,7 @@ import logging
log = logging.getLogger(__name__)
from uuid import UUID, uuid4
from gns3server.utils.interfaces import is_interface_up
from ..config import Config
from ..utils.asyncio import wait_run_in_executor
from .project_manager import ProjectManager
@@ -369,12 +370,17 @@ class BaseManager:
nio = NIOUDP(lport, rhost, rport)
elif nio_settings["type"] == "nio_tap":
tap_device = nio_settings["tap_device"]
if not is_interface_up(tap_device):
raise aiohttp.web.HTTPConflict(text="TAP interface {} is down".format(tap_device))
# FIXME: check for permissions on tap device
# if not self._has_privileged_access(executable):
# raise aiohttp.web.HTTPForbidden(text="{} has no privileged access to {}.".format(executable, tap_device))
nio = NIOTAP(tap_device)
elif nio_settings["type"] == "nio_generic_ethernet":
nio = NIOGenericEthernet(nio_settings["ethernet_device"])
ethernet_device = nio_settings["ethernet_device"]
if not is_interface_up(ethernet_device):
raise aiohttp.web.HTTPConflict(text="Ethernet interface {} is down".format(ethernet_device))
nio = NIOGenericEthernet(ethernet_device)
elif nio_settings["type"] == "nio_nat":
nio = NIONAT()
assert nio is not None
+5 -1
View File
@@ -32,7 +32,7 @@ import logging
log = logging.getLogger(__name__)
from gns3server.utils.interfaces import get_windows_interfaces
from gns3server.utils.interfaces import get_windows_interfaces, is_interface_up
from gns3server.utils.asyncio import wait_run_in_executor
from pkg_resources import parse_version
from uuid import UUID, uuid4
@@ -404,6 +404,8 @@ class Dynamips(BaseManager):
raise DynamipsError("Could not find interface {} on this host".format(ethernet_device))
else:
ethernet_device = npf_interface
if not is_interface_up(ethernet_device):
raise aiohttp.web.HTTPConflict(text="Ethernet interface {} is down".format(ethernet_device))
nio = NIOGenericEthernet(node.hypervisor, ethernet_device)
elif nio_settings["type"] == "nio_linux_ethernet":
if sys.platform.startswith("win"):
@@ -412,6 +414,8 @@ class Dynamips(BaseManager):
nio = NIOLinuxEthernet(node.hypervisor, ethernet_device)
elif nio_settings["type"] == "nio_tap":
tap_device = nio_settings["tap_device"]
if not is_interface_up(tap_device):
raise aiohttp.web.HTTPConflict(text="TAP interface {} is down".format(tap_device))
nio = NIOTAP(node.hypervisor, tap_device)
elif nio_settings["type"] == "nio_unix":
local_file = nio_settings["local_file"]