Skip to content

Commit

Permalink
Add mtu network setting
Browse files Browse the repository at this point in the history
  • Loading branch information
jcronenberg committed Jun 11, 2024
1 parent e7e11e7 commit 83cf368
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions rust/agama-lib/share/profile.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@
"description": "Custom mac-address (can also be 'preserve', 'permanent', 'random' or 'stable')",
"type": "string"
},
"mtu": {
"description": "Connection MTU",
"type": "integer",
"minimum": 0
},
"method4": {
"description": "IPv4 configuration method (e.g., 'auto')",
"type": "string",
Expand Down
4 changes: 4 additions & 0 deletions rust/agama-lib/src/network/proxies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ trait Connection {
fn mac_address(&self) -> zbus::Result<String>;
#[dbus_proxy(property)]
fn set_mac_address(&self, mac_address: &str) -> zbus::Result<()>;
#[dbus_proxy(property)]
fn mtu(&self) -> zbus::Result<u32>;
#[dbus_proxy(property)]
fn set_mtu(&self, mtu: u32) -> zbus::Result<()>;
}

#[dbus_proxy(
Expand Down
6 changes: 6 additions & 0 deletions rust/agama-lib/src/network/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ pub struct NetworkConnection {
pub mac_address: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub status: Option<Status>,
#[serde(skip_serializing_if = "is_zero", default)]
pub mtu: u32,
}

fn is_zero(u: &u32) -> bool {
*u == 0
}

impl NetworkConnection {
Expand Down
3 changes: 3 additions & 0 deletions rust/agama-server/src/network/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,7 @@ impl TryFrom<NetworkConnection> for Connection {
connection.ip_config.gateway4 = conn.gateway4;
connection.ip_config.gateway6 = conn.gateway6;
connection.interface = conn.interface;
connection.mtu = conn.mtu;

Ok(connection)
}
Expand All @@ -620,6 +621,7 @@ impl TryFrom<Connection> for NetworkConnection {
let gateway6 = conn.ip_config.gateway6;
let interface = conn.interface;
let status = Some(conn.status);
let mtu = conn.mtu;

let mut connection = NetworkConnection {
id,
Expand All @@ -632,6 +634,7 @@ impl TryFrom<Connection> for NetworkConnection {
mac_address,
interface,
addresses,
mtu,
..Default::default()
};

Expand Down

0 comments on commit 83cf368

Please sign in to comment.