]> git.proxmox.com Git - pve-common.git/blobdiff - src/PVE/INotify.pm
followup code cleanup
[pve-common.git] / src / PVE / INotify.pm
index 867da306197014d57fa3c8886db3833732de3cd4..2aa70707cbdaaa0ff5a2d7f90856623024146399 100644 (file)
@@ -872,6 +872,7 @@ sub __read_etc_network_interfaces {
     my $options = $config->{options} = [];
 
     my $options_alternatives = {
+       'ovs_mtu'     => 'mtu',
        'bond-slaves' => 'slaves',
        'bond_slaves' => 'slaves',
        'bond-xmit-hash-policy' => 'bond_xmit_hash_policy',
@@ -956,6 +957,7 @@ sub __read_etc_network_interfaces {
                        'bridge-multicast-flood' => 1,
                        'bond_miimon' => 1,
                        'bond_xmit_hash_policy' => 1,
+                       'bond-primary' => 1,
                        'uplink-id' => 1,
                        'vlan-protocol' => 1,
                        'vxlan-id' => 1,
@@ -1214,6 +1216,9 @@ sub __interface_to_string {
        $done->{bridge_vlan_aware} = 1;
        $done->{bridge_vids} = 1;
 
+       $raw .= "\tmtu $d->{mtu}\n" if $d->{mtu};
+       $done->{mtu} = 1;
+
     } elsif ($d->{type} eq 'bond') {
 
        $d->{slaves} =~ s/[;,\s]+/ /g;
@@ -1234,6 +1239,15 @@ sub __interface_to_string {
            $raw .= "\tbond-xmit-hash-policy $d->{'bond_xmit_hash_policy'}\n";
        }
        $done->{'bond_xmit_hash_policy'} = 1;
+
+       if ($d->{'bond_mode'} && $d->{'bond_mode'} eq 'active-backup' && $d->{'bond-primary'}) {
+           $raw .= "\tbond-primary $d->{'bond-primary'}\n";
+       }
+       $done->{'bond-primary'} = 1;
+
+       $raw .= "\tmtu $d->{mtu}\n" if $d->{mtu};
+       $done->{mtu} = 1;
+
     } elsif ($d->{type} eq 'vlan') {
        die "$iface: wrong vlan-protocol $d->{'vlan-protocol'}\n"
            if $d->{'vlan-protocol'} && $d->{'vlan-protocol'} ne '802.1ad' && $d->{'vlan-protocol'} ne '802.1q';
@@ -1251,14 +1265,21 @@ sub __interface_to_string {
            }
            $done->{'vxlan-remoteip'} = 1;
        }
+
+       $raw .= "\tmtu $d->{mtu}\n" if $d->{mtu};
+       $done->{mtu} = 1;
+
     } elsif ($d->{type} eq 'OVSBridge') {
 
        $raw .= "\tovs_type $d->{type}\n";
        $done->{ovs_type} = 1;
 
        $raw .= "\tovs_ports $d->{ovs_ports}\n" if $d->{ovs_ports};
-
        $done->{ovs_ports} = 1;
+
+       $raw .= "\tovs_mtu $d->{mtu}\n" if $d->{mtu};
+       $done->{mtu} = 1;
+
     } elsif ($d->{type} eq 'OVSPort' || $d->{type} eq 'OVSIntPort' ||
             $d->{type} eq 'OVSBond') {
 
@@ -1300,6 +1321,9 @@ sub __interface_to_string {
            $raw .= "\tovs_bridge $bridge\n";
            $done->{ovs_bridge} = 1;
        }
+
+       $raw .= "\tovs_mtu $d->{mtu}\n" if $d->{mtu};
+       $done->{mtu} = 1;
     }
 
     if ($first_block) {
@@ -1427,6 +1451,7 @@ sub __write_etc_network_interfaces {
     foreach my $iface (keys %$ifaces) {
        my $d = $ifaces->{$iface};
        if ($d->{type} eq 'bond' && $d->{slaves}) {
+           my $bond_primary_is_slave = undef;
            foreach my $p (split (/\s+/, $d->{slaves})) {
                my $n = $ifaces->{$p};
 
@@ -1435,7 +1460,9 @@ sub __write_etc_network_interfaces {
                die "bond '$iface' - wrong interface type on slave '$p' " .
                    "('$n->{type}' != 'eth')\n" if $n->{type} ne 'eth';
                &$check_mtu($ifaces, $iface, $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;
        }
     }
 
@@ -1474,9 +1501,7 @@ sub __write_etc_network_interfaces {
            die "vlan '$iface' - unable to find parent '$p'\n"
                if !$n;
 
-           if ($n->{type} eq 'bridge' && !$n->{bridge_vlan_aware}) {
-               die "vlan '$iface' - bridge vlan aware is not enabled on parent '$p'\n";
-           } elsif ($n->{type} ne 'eth' && $n->{type} ne 'bridge' && $n->{type} ne 'bond' && $n->{type} ne 'vlan') {
+           if ($n->{type} ne 'eth' && $n->{type} ne 'bridge' && $n->{type} ne 'bond' && $n->{type} ne 'vlan') {
                die "vlan '$iface' - wrong interface type on parent '$p' " .
                    "('$n->{type}' != 'eth|bond|bridge|vlan' )\n";
            }
@@ -1510,8 +1535,11 @@ sub __write_etc_network_interfaces {
            foreach my $p (split (/\s+/, $d->{bridge_ports})) {
                $p =~ s/\.\d+$//;
                my $n = $ifaces->{$p};
-               die "bridge '$iface' - unable to find bridge port '$p'\n"
-                   if !$n;
+               die "bridge '$iface' - unable to find bridge port '$p'\n" if !$n;
+               die "iface $p - ip address can't be set on interface if bridged in $iface\n"
+                   if ($n->{method} eq 'static' && $n->{address} ne '0.0.0.0') ||
+                      ($n->{method6} eq 'static' && $n->{address} ne '::');
+
                &$check_mtu($ifaces, $iface, $p);
                $bridgeports->{$p} = $iface;
            }