]> git.proxmox.com Git - pve-common.git/blobdiff - src/PVE/INotify.pm
fix #2374: bridge-ports is assumed to be defined
[pve-common.git] / src / PVE / INotify.pm
index ae9e5e2777040f60aaf4bcc072c021a60efb5004..f524672e6cfd6827ceea891bffa44bd0f2996344 100644 (file)
@@ -923,7 +923,8 @@ sub __read_etc_network_interfaces {
            push @{$d->{families}}, $family;
 
            while (defined ($line = <$fh>)) {
-               chomp $line;
+               $line =~ s/\s+$//; # drop trailing whitespaces
+
                if ($line =~ m/^\s*#(.*?)\s*$/) {
                    $f->{comments} = '' if !$f->{comments};
                    my $comment = decode('UTF-8', $1);
@@ -1235,8 +1236,8 @@ sub __interface_to_string {
        # not printing out options
     } elsif ($d->{type} eq 'bridge') {
 
-       $d->{bridge_ports} =~ s/[;,\s]+/ /g;
        my $ports = $d->{bridge_ports} || 'none';
+       $ports =~ s/[;,\s]+/ /g;
        $raw .= "\tbridge-ports $ports\n";
        $done->{bridge_ports} = 1;
 
@@ -1413,8 +1414,9 @@ sub __write_etc_network_interfaces {
     foreach my $iface (keys %$ifaces) {
        my $d = $ifaces->{$iface};
 
-       delete $d->{cidr};
-       delete $d->{cidr6};
+       my ($cidr, $cidr6) = (delete $d->{cidr}, delete $d->{cidr6});
+       $d->{address} //= $cidr;
+       $d->{address6} //= $cidr6;
 
        my $ports = '';
        foreach my $k (qw(bridge_ports ovs_ports slaves ovs_bonds)) {
@@ -1485,6 +1487,7 @@ sub __write_etc_network_interfaces {
        if ($d->{type} eq 'OVSBond' && $d->{ovs_bonds}) {
            foreach my $p (split (/\s+/, $d->{ovs_bonds})) {
                my $n = $ifaces->{$p};
+               $n->{autostart} = 1;
                die "OVS bond '$iface' - unable to find slave '$p'\n"
                    if !$n;
                die "OVS bond '$iface' - wrong interface type on slave '$p' " .
@@ -1501,6 +1504,7 @@ sub __write_etc_network_interfaces {
            my $bond_primary_is_slave = undef;
            foreach my $p (split (/\s+/, $d->{slaves})) {
                my $n = $ifaces->{$p};
+               $n->{autostart} = 1;
 
                die "bond '$iface' - unable to find slave '$p'\n"
                    if !$n;
@@ -1601,7 +1605,7 @@ sub __write_etc_network_interfaces {
     foreach my $iface (keys %$ifaces_copy) {
        my $d = $ifaces_copy->{$iface};
        if ($d->{type} eq 'bridge') {
-           foreach my $p (split (/\s+/, $d->{bridge_ports})) {
+           foreach my $p (split (/\s+/, $d->{bridge_ports} // '')) {
                if($p =~ m/(\S+)\.(\d+)$/) {
                    my $vlanparent = $1;
                    if (!defined($ifaces_copy->{$p})) {