]> 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 6a7f11042552ddf380f170f203263fd6a538d41a..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;
@@ -1142,7 +1143,9 @@ sub __read_etc_network_interfaces {
     # from the {options} hash for them to be removed correctly.
     @$options = grep {defined($_)} map {
        my ($pri, $line) = @$_;
-       if ($line =~ /^allow-(\S+)\s+(.*)$/) {
+       if ($line =~ /^allow-ovs\s+(.*)$/) {
+           undef;
+       } elsif ($line =~ /^allow-(\S+)\s+(.*)$/) {
            my $bridge = $1;
            my @ports = split(/\s+/, $2);
            if (defined(my $br = $ifaces->{$bridge})) {
@@ -1254,6 +1257,7 @@ sub __interface_to_string {
        $done->{ovs_type} = 1;
 
        $raw .= "\tovs_ports $d->{ovs_ports}\n" if $d->{ovs_ports};
+
        $done->{ovs_ports} = 1;
     } elsif ($d->{type} eq 'OVSPort' || $d->{type} eq 'OVSIntPort' ||
             $d->{type} eq 'OVSBond') {
@@ -1291,15 +1295,9 @@ sub __interface_to_string {
        $raw .= "\tovs_type $d->{type}\n";
        $done->{ovs_type} = 1;
 
-       if ($d->{ovs_bridge}) {
-
-           if ($ifupdown2) {
-               $raw = "auto $iface\n$raw";
-           } else {
-               $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;
        }
     }
@@ -1476,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";
            }
@@ -1514,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;
            }
@@ -1592,7 +1592,6 @@ NETWORKDOC
        return $a cmp $b;
     } keys %$ifaces) {
        next if $printed->{$iface};
-
        my $d = $ifaces->{$iface};
        my $pri = $d->{priority} // 0;
        if (@options && $options[0]->[0] < $pri) {
@@ -1603,7 +1602,15 @@ NETWORKDOC
        }
 
        $printed->{$iface} = 1;
-       $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
        $raw .= __interface_to_string($iface, $d, $_, !$i++, $ifupdown2) foreach @{$d->{families}};
     }