diff --git a/supervisor/dbus/network/configuration.py b/supervisor/dbus/network/configuration.py index a203a5378..887e3caf3 100644 --- a/supervisor/dbus/network/configuration.py +++ b/supervisor/dbus/network/configuration.py @@ -32,6 +32,7 @@ class ConnectionProperties: id: Optional[str] = attr.ib() uuid: Optional[str] = attr.ib() type: Optional[str] = attr.ib() + interface_name: Optional[str] = attr.ib() @attr.s(slots=True) diff --git a/supervisor/dbus/network/setting.py b/supervisor/dbus/network/setting.py index a1e190c4c..83d1ff3df 100644 --- a/supervisor/dbus/network/setting.py +++ b/supervisor/dbus/network/setting.py @@ -31,6 +31,7 @@ ATTR_ASSIGNED_MAC = "assigned-mac-address" ATTR_POWERSAVE = "powersave" ATTR_AUTH_ALGO = "auth-algo" ATTR_KEY_MGMT = "key-mgmt" +ATTR_INTERFACE_NAME = "interface-name" class NetworkSetting(DBusInterfaceProxy): @@ -109,6 +110,7 @@ class NetworkSetting(DBusInterfaceProxy): data[CONF_ATTR_CONNECTION].get(ATTR_ID), data[CONF_ATTR_CONNECTION].get(ATTR_UUID), data[CONF_ATTR_CONNECTION].get(ATTR_TYPE), + data[CONF_ATTR_CONNECTION].get(ATTR_INTERFACE_NAME), ) if CONF_ATTR_802_ETHERNET in data: diff --git a/supervisor/dbus/payloads/interface_update.tmpl b/supervisor/dbus/payloads/interface_update.tmpl index 8b65e0faa..a2af64ede 100644 --- a/supervisor/dbus/payloads/interface_update.tmpl +++ b/supervisor/dbus/payloads/interface_update.tmpl @@ -61,7 +61,7 @@ , '802-3-ethernet': { - 'assigned-mac-address': <'stable'> + 'assigned-mac-address': <'preserve'> } {% endif %} @@ -78,7 +78,7 @@ , '802-11-wireless': { - 'assigned-mac-address': <'stable'>, + 'assigned-mac-address': <'preserve'>, 'ssid': <[byte {{ interface.wifi.ssid }}]>, 'mode': <'{{ interface.wifi.mode.value }}'>, 'powersave': diff --git a/supervisor/host/network.py b/supervisor/host/network.py index 952e34e46..e55607384 100644 --- a/supervisor/host/network.py +++ b/supervisor/host/network.py @@ -111,7 +111,12 @@ class NetworkManager(CoreSysAttributes): inet = self.sys_dbus.network.interfaces.get(interface.name) # Update exist configuration - if inet and inet.settings and interface.enabled: + if ( + inet + and inet.settings + and inet.settings.connection.interface_name == interface.name + and interface.enabled + ): settings = interface_update_payload( interface, name=inet.settings.connection.id, @@ -279,7 +284,7 @@ class Interface: inet.connection.ipv4.nameservers, ) if inet.connection and inet.connection.ipv4 - else None, + else IpConfig(InterfaceMethod.DISABLED, [], None, []), IpConfig( Interface._map_nm_method(inet.settings.ipv6.method), inet.connection.ipv6.address, @@ -287,7 +292,7 @@ class Interface: inet.connection.ipv6.nameservers, ) if inet.connection and inet.connection.ipv6 - else None, + else IpConfig(InterfaceMethod.DISABLED, [], None, []), Interface._map_nm_wifi(inet), Interface._map_nm_vlan(inet), ) diff --git a/tests/api/test_network.py b/tests/api/test_network.py index f4f2739ae..fc5c1aaa2 100644 --- a/tests/api/test_network.py +++ b/tests/api/test_network.py @@ -26,8 +26,18 @@ async def test_api_network_info(api_client, coresys): assert interface["ipv4"]["gateway"] == "192.168.2.1" if interface["interface"] == TEST_INTERFACE_WLAN: assert not interface["primary"] - assert interface["ipv4"] is None - assert interface["ipv6"] is None + assert interface["ipv4"] == { + "address": [], + "gateway": None, + "method": "disabled", + "nameservers": [], + } + assert interface["ipv6"] == { + "address": [], + "gateway": None, + "method": "disabled", + "nameservers": [], + } assert result["data"]["docker"]["interface"] == DOCKER_NETWORK assert result["data"]["docker"]["address"] == str(DOCKER_NETWORK_MASK) diff --git a/tests/dbus/payloads/test_interface_update_payload.py b/tests/dbus/payloads/test_interface_update_payload.py index 7b7ade14d..9540d4237 100644 --- a/tests/dbus/payloads/test_interface_update_payload.py +++ b/tests/dbus/payloads/test_interface_update_payload.py @@ -21,7 +21,8 @@ async def test_interface_update_payload_ethernet(coresys): assert DBus.parse_gvariant(data)["ipv6"]["method"] == "auto" assert ( - DBus.parse_gvariant(data)["802-3-ethernet"]["assigned-mac-address"] == "stable" + DBus.parse_gvariant(data)["802-3-ethernet"]["assigned-mac-address"] + == "preserve" ) assert DBus.parse_gvariant(data)["connection"]["mdns"] == 2 @@ -243,7 +244,8 @@ async def test_interface_update_payload_wireless_open(coresys): assert DBus.parse_gvariant(data)["802-11-wireless"]["ssid"] == [84, 101, 115, 116] assert DBus.parse_gvariant(data)["802-11-wireless"]["mode"] == "infrastructure" assert ( - DBus.parse_gvariant(data)["802-11-wireless"]["assigned-mac-address"] == "stable" + DBus.parse_gvariant(data)["802-11-wireless"]["assigned-mac-address"] + == "preserve" ) assert "802-11-wireless-security" not in DBus.parse_gvariant(data)