src/config/network.rs: always write bridge_ports and bond_slaves

So that we can reliable detect the interface type.
This commit is contained in:
Dietmar Maurer 2020-05-08 09:58:03 +02:00
parent 86a5d56c4e
commit db5672e83e
1 changed files with 12 additions and 12 deletions

View File

@ -142,31 +142,31 @@ impl Interface {
/// Write attributes not dependening on address family
fn write_iface_attributes(&self, w: &mut dyn Write) -> Result<(), Error> {
static EMPTY_LIST: Vec<String> = Vec::new();
match self.interface_type {
NetworkInterfaceType::Bridge => {
if let Some(true) = self.bridge_vlan_aware {
writeln!(w, "\tbridge-vlan-aware yes")?;
}
if let Some(ref ports) = self.bridge_ports {
let ports = self.bridge_ports.as_ref().unwrap_or(&EMPTY_LIST);
if ports.is_empty() {
writeln!(w, "\tbridge-ports none")?;
} else {
writeln!(w, "\tbridge-ports {}", ports.join(" "))?;
}
}
}
NetworkInterfaceType::Bond => {
let mode = self.bond_mode.unwrap_or(LinuxBondMode::balance_rr);
writeln!(w, "\tbond-mode {}", bond_mode_to_str(mode))?;
if let Some(ref slaves) = self.slaves {
let slaves = self.slaves.as_ref().unwrap_or(&EMPTY_LIST);
if slaves.is_empty() {
writeln!(w, "\tbond-slaves none")?;
} else {
writeln!(w, "\tbond-slaves {}", slaves.join(" "))?;
}
}
}
_ => {}
}