src/config/network.rs: use a single mtu setting (instead of mtu_v4 and mtu_v6)
This commit is contained in:
@ -90,10 +90,8 @@ pub enum DeletableProperty {
|
||||
method_v4,
|
||||
/// Delete the whole IPv6 configuration entry.
|
||||
method_v6,
|
||||
/// Delete mtu for IPv4.
|
||||
mtu_v4,
|
||||
/// Delete mtu IPv6.
|
||||
mtu_v6,
|
||||
/// Delete mtu.
|
||||
mtu,
|
||||
/// Delete auto flag
|
||||
auto,
|
||||
}
|
||||
@ -126,17 +124,12 @@ pub enum DeletableProperty {
|
||||
schema: IP_SCHEMA,
|
||||
optional: true,
|
||||
},
|
||||
mtu_v4: {
|
||||
description: "Maximum Transmission Unit for IPv4.",
|
||||
optional: true,
|
||||
minimum: 46,
|
||||
maximum: 65535,
|
||||
},
|
||||
mtu_v6: {
|
||||
description: "Maximum Transmission Unit for IPv6.",
|
||||
mtu: {
|
||||
description: "Maximum Transmission Unit.",
|
||||
optional: true,
|
||||
minimum: 46,
|
||||
maximum: 65535,
|
||||
default: 1500,
|
||||
},
|
||||
delete: {
|
||||
description: "List of properties to delete.",
|
||||
@ -164,8 +157,7 @@ pub fn update_interface(
|
||||
method_v6: Option<NetworkConfigMethod>,
|
||||
address: Option<String>,
|
||||
gateway: Option<String>,
|
||||
mtu_v4: Option<u64>,
|
||||
mtu_v6: Option<u64>,
|
||||
mtu: Option<u64>,
|
||||
delete: Option<Vec<DeletableProperty>>,
|
||||
digest: Option<String>,
|
||||
) -> Result<(), Error> {
|
||||
@ -190,8 +182,7 @@ pub fn update_interface(
|
||||
DeletableProperty::gateway_v6 => { interface.gateway_v6 = None; },
|
||||
DeletableProperty::method_v4 => { interface.method_v4 = None; },
|
||||
DeletableProperty::method_v6 => { interface.method_v6 = None; },
|
||||
DeletableProperty::mtu_v4 => { interface.mtu_v4 = None; },
|
||||
DeletableProperty::mtu_v6 => { interface.mtu_v6 = None; },
|
||||
DeletableProperty::mtu => { interface.mtu = None; },
|
||||
DeletableProperty::auto => { interface.auto = false; },
|
||||
}
|
||||
}
|
||||
@ -200,8 +191,7 @@ pub fn update_interface(
|
||||
if let Some(auto) = auto { interface.auto = auto; }
|
||||
if method_v4.is_some() { interface.method_v4 = method_v4; }
|
||||
if method_v6.is_some() { interface.method_v6 = method_v6; }
|
||||
if mtu_v4.is_some() { interface.mtu_v4 = mtu_v4; }
|
||||
if mtu_v6.is_some() { interface.mtu_v6 = mtu_v6; }
|
||||
if mtu.is_some() { interface.mtu = mtu; }
|
||||
|
||||
if let Some(address) = address {
|
||||
let (_, _, is_v6) = network::parse_cidr(&address)?;
|
||||
|
@ -586,17 +586,14 @@ pub struct Interface {
|
||||
/// IPv6 gateway
|
||||
pub gateway_v6: Option<String>,
|
||||
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
/// Maximum Transmission Unit for IPv4
|
||||
pub mtu_v4: Option<u64>,
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
/// Maximum Transmission Unit for IPv6
|
||||
pub mtu_v6: Option<u64>,
|
||||
|
||||
#[serde(skip_serializing_if="Vec::is_empty")]
|
||||
pub options_v4: Vec<String>,
|
||||
#[serde(skip_serializing_if="Vec::is_empty")]
|
||||
pub options_v6: Vec<String>,
|
||||
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
/// Maximum Transmission Unit
|
||||
pub mtu: Option<u64>,
|
||||
}
|
||||
|
||||
// Regression tests
|
||||
|
Reference in New Issue
Block a user