Use link-local instead disabled for ipv6 (#3829)

* Use link-local instead disabled for ipv6

* Add a test

Co-authored-by: Mike Degatano <michael.degatano@gmail.com>
This commit is contained in:
Pascal Vizeli 2022-08-29 22:56:59 +02:00 committed by GitHub
parent bae7fe4184
commit 3dc36c3402
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 1 deletions

View File

@ -140,6 +140,7 @@ class InterfaceMethod(str, Enum):
AUTO = "auto"
MANUAL = "manual"
DISABLED = "disabled"
LINK_LOCAL = "link-local"
class ConnectionType(str, Enum):

View File

@ -93,7 +93,7 @@ def get_connection_from_interface(
if not interface.ipv6 or interface.ipv6.method == InterfaceMethod.AUTO:
ipv6["method"] = Variant("s", "auto")
elif interface.ipv6.method == InterfaceMethod.DISABLED:
ipv6["method"] = Variant("s", "disabled")
ipv6["method"] = Variant("s", "link-local")
else:
ipv6["method"] = Variant("s", "manual")
ipv6["dns"] = Variant(

View File

@ -402,6 +402,7 @@ class Interface:
NMInterfaceMethod.AUTO: InterfaceMethod.AUTO,
NMInterfaceMethod.DISABLED: InterfaceMethod.DISABLED,
NMInterfaceMethod.MANUAL: InterfaceMethod.STATIC,
NMInterfaceMethod.LINK_LOCAL: InterfaceMethod.DISABLED,
}
return mapping.get(method, InterfaceMethod.DISABLED)

View File

@ -6,6 +6,7 @@ from dbus_next.signature import Variant
from supervisor.coresys import CoreSys
from supervisor.dbus.network.setting.generate import get_connection_from_interface
from supervisor.host.const import InterfaceMethod
from supervisor.host.network import Interface
from tests.const import TEST_INTERFACE
@ -149,3 +150,21 @@ async def test_update(coresys: CoreSys):
new=mock_call_dbus_get_settings_signature,
):
await coresys.dbus.network.interfaces[TEST_INTERFACE].settings.update(conn)
async def test_ipv6_disabled_is_link_local(coresys: CoreSys):
"""Test disabled equals link local for ipv6."""
await coresys.dbus.network.interfaces[TEST_INTERFACE].connect()
interface = Interface.from_dbus_interface(
coresys.dbus.network.interfaces[TEST_INTERFACE]
)
interface.ipv4.method = InterfaceMethod.DISABLED
interface.ipv6.method = InterfaceMethod.DISABLED
conn = get_connection_from_interface(
interface,
name=coresys.dbus.network.interfaces[TEST_INTERFACE].settings.connection.id,
uuid=coresys.dbus.network.interfaces[TEST_INTERFACE].settings.connection.uuid,
)
assert conn["ipv4"]["method"] == Variant("s", "disabled")
assert conn["ipv6"]["method"] == Variant("s", "link-local")