]> git.proxmox.com Git - pve-common.git/commitdiff
INotify : check_bridge : fix bridge-ports with vlan tagged interface
authorAlexandre Derumier <aderumier@odiso.com>
Fri, 7 Feb 2020 11:40:28 +0000 (12:40 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 7 Feb 2020 11:56:24 +0000 (12:56 +0100)
Currently with strip vlan tag, that's wrong because
mtu && others check are done the main interface.

src/PVE/INotify.pm
test/etc_network_interfaces/t.create_network.pl

index 7becbde4dd12163c03ba22401130399607a7ee66..ba952e3b731e95a9087f8dc4387c914c309ca142 100644 (file)
@@ -1,7 +1,6 @@
 package PVE::INotify;
 
 # todo: maybe we do not need update_file() ?
 package PVE::INotify;
 
 # todo: maybe we do not need update_file() ?
-
 use strict;
 use warnings;
 
 use strict;
 use warnings;
 
@@ -1554,18 +1553,26 @@ sub __write_etc_network_interfaces {
     # check bridgeport option
     my $bridgeports = {};
     my $bridges = {};
     # check bridgeport option
     my $bridgeports = {};
     my $bridges = {};
-    foreach my $iface (keys %$ifaces) {
-       my $d = $ifaces->{$iface};
+    my $ifaces_copy = { %$ifaces };
+    foreach my $iface (keys %$ifaces_copy) {
+       my $d = $ifaces_copy->{$iface};
        if ($d->{type} eq 'bridge') {
            foreach my $p (split (/\s+/, $d->{bridge_ports})) {
        if ($d->{type} eq 'bridge') {
            foreach my $p (split (/\s+/, $d->{bridge_ports})) {
-               $p =~ s/\.\d+$//;
-               my $n = $ifaces->{$p};
+               if($p =~ m/(\S+)\.(\d+)$/) {
+                   my $vlanparent = $1;
+                   if (!defined($ifaces_copy->{$p})) {
+                       $ifaces_copy->{$p}->{type} = 'vlan';
+                       $ifaces_copy->{$p}->{method} = 'manual';
+                       $ifaces_copy->{$p}->{method6} = 'manual';
+                       $ifaces_copy->{$p}->{mtu} = $ifaces_copy->{$vlanparent}->{mtu} if defined($ifaces_copy->{$1}->{mtu});
+                   }
+               }
+               my $n = $ifaces_copy->{$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} && $n->{method} eq 'static' && $n->{address} ne '0.0.0.0') ||
                       ($n->{method6} && $n->{method6} eq 'static' && $n->{address} ne '::');
                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} && $n->{method} eq 'static' && $n->{address} ne '0.0.0.0') ||
                       ($n->{method6} && $n->{method6} eq 'static' && $n->{address} ne '::');
-
-               &$check_mtu($ifaces, $p, $iface);
+               &$check_mtu($ifaces_copy, $p, $iface);
                $bridgeports->{$p} = $iface;
            }
            $bridges->{$iface} = $d;
                $bridgeports->{$p} = $iface;
            }
            $bridges->{$iface} = $d;
index d6418f42aacb43d3ae14c91f61ce5ade085c4259..700eeef6bed1a4da3b27ecfd28bba766162723a6 100644 (file)
@@ -205,7 +205,7 @@ $config->{ifaces}->{vmbr3} = {
     families => ['inet'],
     bridge_stp => 'off',
     bridge_fd => 0,
     families => ['inet'],
     bridge_stp => 'off',
     bridge_fd => 0,
-    bridge_ports => 'vxlan3.50',
+    bridge_ports => 'vxlan3',
     bridge_vlan_aware => 'yes',
     bridge_vids => '2-10',
     autostart => 1
     bridge_vlan_aware => 'yes',
     bridge_vids => '2-10',
     autostart => 1
@@ -229,7 +229,7 @@ iface vmbr2 inet manual
 
 auto vmbr3
 iface vmbr3 inet manual
 
 auto vmbr3
 iface vmbr3 inet manual
-       bridge-ports vxlan3.50
+       bridge-ports vxlan3
        bridge-stp off
        bridge-fd 0
        bridge-vlan-aware yes
        bridge-stp off
        bridge-fd 0
        bridge-vlan-aware yes
@@ -336,6 +336,17 @@ $config->{ifaces}->{'vmbr4'} = {
     autostart => 1
 };
 
     autostart => 1
 };
 
+$config->{ifaces}->{'vmbr5'} = {
+    mtu => 1100,
+    type => 'bridge',
+    method => 'manual',
+    families => ['inet'],
+    bridge_stp => 'off',
+    bridge_fd => 0,
+    bridge_ports => 'vmbr4.99',
+    autostart => 1
+};
+
 expect load('loopback') . <<"CHECK";
 source-directory interfaces.d
 
 expect load('loopback') . <<"CHECK";
 source-directory interfaces.d
 
@@ -373,6 +384,13 @@ iface vmbr4 inet manual
        bridge-fd 0
        mtu 1200
 
        bridge-fd 0
        mtu 1200
 
+auto vmbr5
+iface vmbr5 inet manual
+       bridge-ports vmbr4.99
+       bridge-stp off
+       bridge-fd 0
+       mtu 1100
+
 auto vmbr1.100
 iface vmbr1.100 inet manual
        mtu 1300
 auto vmbr1.100
 iface vmbr1.100 inet manual
        mtu 1300