diff --git a/rust/agama-server/src/network/nm/dbus.rs b/rust/agama-server/src/network/nm/dbus.rs index 0254932f50..00db6bb7b1 100644 --- a/rust/agama-server/src/network/nm/dbus.rs +++ b/rust/agama-server/src/network/nm/dbus.rs @@ -66,32 +66,10 @@ pub fn connection_to_dbus<'a>( result.insert("ipv6", ip_config_to_ipv6_dbus(&conn.ip_config)); result.insert("match", match_config_to_dbus(&conn.match_config)); - if conn.is_ethernet() { - let ethernet_config = HashMap::from([ - ( - "assigned-mac-address", - Value::new(conn.mac_address.to_string()), - ), - ("mtu", Value::new(conn.mtu)), - ]); - result.insert(ETHERNET_KEY, ethernet_config); - } - match &conn.config { ConnectionConfig::Wireless(wireless) => { connection_dbus.insert("type", WIRELESS_KEY.into()); - let mut wireless_dbus = wireless_config_to_dbus(wireless); - wireless_dbus - .get_mut(WIRELESS_KEY) - .unwrap() - .extend(HashMap::from([ - ("mtu", Value::new(conn.mtu)), - ( - "assigned-mac-address", - Value::new(conn.mac_address.to_string()), - ), - ])); - + let wireless_dbus = wireless_config_to_dbus(wireless); result.extend(wireless_dbus); } ConnectionConfig::Bond(bond) => { @@ -119,6 +97,22 @@ pub fn connection_to_dbus<'a>( _ => {} } + let general_conn_config = HashMap::from([ + ( + "assigned-mac-address", + Value::new(conn.mac_address.to_string()), + ), + ("mtu", Value::new(conn.mtu)), + ]); + if conn.is_ethernet() { + result.insert(ETHERNET_KEY, general_conn_config); + } else if let ConnectionConfig::Wireless(_) = conn.config { + result + .get_mut(WIRELESS_KEY) + .unwrap() + .extend(general_conn_config); + } + match &conn.port_config { PortConfig::Bridge(bridge_port) => { result.insert(BRIDGE_PORT_KEY, bridge_port_config_to_dbus(bridge_port));