]> git.proxmox.com Git - pve-common.git/blobdiff - src/PVE/INotify.pm
INotify: allow vlan tagged bridge interface on non-vlanaware bridge
[pve-common.git] / src / PVE / INotify.pm
index b3e5ab05fd22763f63c6dd51798fa2273b7a9dde..1a528fa356bc0f7207dfeb4f816487ca596b7d4e 100644 (file)
@@ -312,7 +312,7 @@ sub parse_ccache_options {
            # noclone flag for large read-only data chunks like aplinfo
            $ccinfo->{$opt} = $v;
        } elsif ($opt eq 'always_call_parser') {
-           # when set, we call parser even when the file does not exists.
+           # when set, we call parser even when the file does not exist.
            # this allows the parser to return some default
            $ccinfo->{$opt} = $v;
        } else {
@@ -901,9 +901,10 @@ sub __read_etc_network_interfaces {
     SECTION: while (defined ($line = <$fh>)) {
        chomp ($line);
        next if $line =~ m/^\s*#/;
+       next if $line =~ m/^\s*(allow-hotplug)\s+(.*)$/;
 
-       if ($line =~ m/^\s*auto\s+(.*)$/) {
-           my @aa = split (/\s+/, $1);
+       if ($line =~ m/^\s*(auto|allow-ovs)\s+(.*)$/) {
+           my @aa = split (/\s+/, $2);
 
            foreach my $a (@aa) {
                $ifaces->{$a}->{autostart} = 1;
@@ -1294,10 +1295,9 @@ sub __interface_to_string {
        $raw .= "\tovs_type $d->{type}\n";
        $done->{ovs_type} = 1;
 
-       if ($d->{ovs_bridge}) {
-
-           $raw = "allow-$d->{ovs_bridge} $iface\n$raw";
-           $raw .= "\tovs_bridge $d->{ovs_bridge}\n";
+       if (my $bridge = $d->{ovs_bridge}) {
+           $raw = "allow-$bridge $iface\n$raw";
+           $raw .= "\tovs_bridge $bridge\n";
            $done->{ovs_bridge} = 1;
        }
     }
@@ -1474,9 +1474,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";
            }
@@ -1512,6 +1510,10 @@ sub __write_etc_network_interfaces {
                my $n = $ifaces->{$p};
                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;
            }
@@ -1600,10 +1602,13 @@ NETWORKDOC
        }
 
        $printed->{$iface} = 1;
-        if ($d->{type} eq 'OVSBridge') {
-           $raw .= "allow-ovs $iface\n";
-       } elsif ($d->{autostart}) {
-           $raw .= "auto $iface\n" if $d->{autostart};
+       if ($d->{autostart}) {
+           if ($d->{type} eq 'OVSBridge') {
+               # cannot use 'auto' for OVS, would add race with systemd ifup@.service
+               $raw .= "allow-ovs $iface\n";
+           } else {
+               $raw .= "auto $iface\n";
+           }
        }
 
        my $i = 0; # some options should be printed only once