Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the changes file #667

Merged
merged 1 commit into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion rust/agama-dbus-server/src/network/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)]
Expand Down
6 changes: 3 additions & 3 deletions rust/agama-dbus-server/src/network/nm/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl<'a> NetworkManagerAdapter<'a> {
///
/// * `conn`: connection
fn is_writable(conn: &Connection) -> bool {
matches!(conn, Connection::Loopback(_))
!conn.is_loopback()
}
}

Expand All @@ -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);
}
}
});
Expand Down
7 changes: 7 additions & 0 deletions rust/package/agama-cli.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Mon Jul 17 13:36:56 UTC 2023 - Imobach Gonzalez Sosa <[email protected]>

- 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 <[email protected]>

Expand Down
Loading