From b3cd5279b88943da307be411c824b68ce11f472f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Imobach=20Gonz=C3=A1lez=20Sosa?= Date: Mon, 17 Jul 2023 14:39:48 +0100 Subject: [PATCH] Update the changes file --- rust/agama-dbus-server/src/network/model.rs | 24 ++++++++++++++++++- .../src/network/nm/adapter.rs | 6 ++--- rust/package/agama-cli.changes | 7 ++++++ 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/rust/agama-dbus-server/src/network/model.rs b/rust/agama-dbus-server/src/network/model.rs index c892e4a515..34937d20b3 100644 --- a/rust/agama-dbus-server/src/network/model.rs +++ b/rust/agama-dbus-server/src/network/model.rs @@ -95,7 +95,7 @@ impl NetworkState { mod tests { use uuid::Uuid; - use super::{BaseConnection, Connection, EthernetConnection, NetworkState}; + use super::*; use crate::network::error::NetworkStateError; #[test] @@ -186,6 +186,23 @@ mod tests { let error = state.remove_connection("eth0").unwrap_err(); assert!(matches!(error, NetworkStateError::UnknownConnection(_))); } + + #[test] + fn test_is_loopback() { + let base = BaseConnection { + id: "eth0".to_string(), + ..Default::default() + }; + let conn = Connection::Ethernet(EthernetConnection { base }); + assert!(!conn.is_loopback()); + + let base = BaseConnection { + id: "lo".to_string(), + ..Default::default() + }; + let conn = Connection::Loopback(LoopbackConnection { base }); + assert!(conn.is_loopback()); + } } /// Network device @@ -264,6 +281,11 @@ impl Connection { pub fn is_removed(&self) -> bool { self.base().status == Status::Removed } + + /// Determines whether it is a loopback interface. + pub fn is_loopback(&self) -> bool { + matches!(self, Connection::Loopback(_)) + } } #[derive(Debug, Default, Clone)] diff --git a/rust/agama-dbus-server/src/network/nm/adapter.rs b/rust/agama-dbus-server/src/network/nm/adapter.rs index 23dda0a03a..4ef6ec9a76 100644 --- a/rust/agama-dbus-server/src/network/nm/adapter.rs +++ b/rust/agama-dbus-server/src/network/nm/adapter.rs @@ -22,7 +22,7 @@ impl<'a> NetworkManagerAdapter<'a> { /// /// * `conn`: connection fn is_writable(conn: &Connection) -> bool { - matches!(conn, Connection::Loopback(_)) + !conn.is_loopback() } } @@ -46,10 +46,10 @@ impl<'a> Adapter for NetworkManagerAdapter<'a> { } if conn.is_removed() { if let Err(e) = self.client.remove_connection(conn.uuid()).await { - log::error!("Could not remove the connection {}: {}", conn.uuid(), e); + log::error!("Could not remove the connection {}: {}", conn.id(), e); } } else if let Err(e) = self.client.add_or_update_connection(conn).await { - log::error!("Could not add/update the connection {}: {}", conn.uuid(), e); + log::error!("Could not add/update the connection {}: {}", conn.id(), e); } } }); diff --git a/rust/package/agama-cli.changes b/rust/package/agama-cli.changes index 1d5445bb30..77619c52e6 100644 --- a/rust/package/agama-cli.changes +++ b/rust/package/agama-cli.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Mon Jul 17 13:36:56 UTC 2023 - Imobach Gonzalez Sosa + +- Fix the logic to decide which network connections to write + due to a bug introduced in gh#openSUSE/agama#662 + (gh#openSUSE/agama#667). + ------------------------------------------------------------------- Mon Jul 17 09:16:38 UTC 2023 - Josef Reidinger