Skip to content

Commit

Permalink
Merge pull request #667 from imobachgs/do-not-write-lo
Browse files Browse the repository at this point in the history
Update the changes file
  • Loading branch information
imobachgs authored Jul 17, 2023
2 parents c49c48d + b3cd527 commit bd024b8
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
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 <igonzalezsosa@suse.com>

- 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 <jreidinger@suse.com>

Expand Down

0 comments on commit bd024b8

Please sign in to comment.