network: cleanup "check bond" code

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2020-10-23 21:08:38 +02:00
parent 000a5a6bcb
commit 329dfb6488

View File

@ -1500,22 +1500,22 @@ sub __write_etc_network_interfaces {
# check bond # check bond
foreach my $iface (keys %$ifaces) { foreach my $iface (keys %$ifaces) {
my $d = $ifaces->{$iface}; my $d = $ifaces->{$iface};
if ($d->{type} eq 'bond' && $d->{slaves}) { next if !($d->{type} eq 'bond' && $d->{slaves});
my $bond_primary_is_slave = undef; my $bond_primary_is_slave = undef;
foreach my $p (split (/\s+/, $d->{slaves})) { foreach my $p (split (/\s+/, $d->{slaves})) {
my $n = $ifaces->{$p}; my $n = $ifaces->{$p};
$n->{autostart} = 1; $n->{autostart} = 1;
die "bond '$iface' - unable to find slave '$p'\n" die "bond '$iface' - unable to find slave '$p'\n" if !$n;
if !$n; die "bond '$iface' - wrong interface type on slave '$p' ('$n->{type}' != 'eth or bond')\n"
die "bond '$iface' - wrong interface type on slave '$p' " . if ($n->{type} ne 'eth' && $n->{type} ne 'bond');
"('$n->{type}' != 'eth or bond')\n" if ($n->{type} ne 'eth' && $n->{type} ne 'bond');
&$check_mtu($ifaces, $iface, $p); $check_mtu->($ifaces, $iface, $p);
$bond_primary_is_slave = 1 if $d->{'bond-primary'} && $d->{'bond-primary'} eq $p; $bond_primary_is_slave = 1 if $d->{'bond-primary'} && $d->{'bond-primary'} eq $p;
} }
die "bond '$iface' - bond-primary interface is not a slave" if $d->{'bond-primary'} && !$bond_primary_is_slave; die "bond '$iface' - bond-primary interface is not a slave" if $d->{'bond-primary'} && !$bond_primary_is_slave;
} }
}
# check vxlan # check vxlan
my $vxlans = {}; my $vxlans = {};