[pve-devel] [PATCH pve-common 3/3] INotify : check_bridge : fix bridge-ports with vlan tagged interface

Alexandre Derumier aderumier at odiso.com
Fri Feb 7 12:40:28 CET 2020


Currently with strip vlan tag, that's wrong because
mtu && others check are done the main interface.
---
 src/PVE/INotify.pm                            | 21 ++++++++++++------
 .../t.create_network.pl                       | 22 +++++++++++++++++--
 2 files changed, 34 insertions(+), 9 deletions(-)

diff --git a/src/PVE/INotify.pm b/src/PVE/INotify.pm
index 7becbde..ba952e3 100644
--- a/src/PVE/INotify.pm
+++ b/src/PVE/INotify.pm
@@ -1,7 +1,6 @@
 package PVE::INotify;
 
 # todo: maybe we do not need update_file() ?
-
 use strict;
 use warnings;
 
@@ -1554,18 +1553,26 @@ sub __write_etc_network_interfaces {
     # 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})) {
-		$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 '::');
-
-		&$check_mtu($ifaces, $p, $iface);
+		&$check_mtu($ifaces_copy, $p, $iface);
 		$bridgeports->{$p} = $iface;
 	    }
 	    $bridges->{$iface} = $d;
diff --git a/test/etc_network_interfaces/t.create_network.pl b/test/etc_network_interfaces/t.create_network.pl
index d6418f4..700eeef 100644
--- a/test/etc_network_interfaces/t.create_network.pl
+++ b/test/etc_network_interfaces/t.create_network.pl
@@ -205,7 +205,7 @@ $config->{ifaces}->{vmbr3} = {
     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
@@ -229,7 +229,7 @@ iface vmbr2 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
@@ -336,6 +336,17 @@ $config->{ifaces}->{'vmbr4'} = {
     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
 
@@ -373,6 +384,13 @@ iface vmbr4 inet manual
 	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
-- 
2.20.1




More information about the pve-devel mailing list