[pve-devel] [PATCH pve-common 1/2] Inotify: add support for 802.1ad stacked vlans

Alexandre Derumier aderumier at odiso.com
Mon Sep 24 09:52:46 CEST 2018


---
 src/PVE/INotify.pm                              | 26 ++++++++++++++++++++++++-
 test/etc_network_interfaces/t.create_network.pl | 14 +++++++++++++
 2 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/src/PVE/INotify.pm b/src/PVE/INotify.pm
index f837596..de61d79 100644
--- a/src/PVE/INotify.pm
+++ b/src/PVE/INotify.pm
@@ -954,6 +954,7 @@ sub __read_etc_network_interfaces {
 			'bridge-multicast-flood' => 1,
 			'bond_miimon' => 1,
 			'bond_xmit_hash_policy' => 1,
+			'vlan-protocol' => 1,
 			'vxlan-id' => 1,
 			'vxlan-svcnodeip' => 1,
 			'vxlan-physdev' => 1,
@@ -1432,7 +1433,25 @@ sub __write_etc_network_interfaces {
     # check vlan
     foreach my $iface (keys %$ifaces) {
 	my $d = $ifaces->{$iface};
-	if ($d->{type} eq 'vlan' && $iface =~ m/^(\S+)\.\d+$/) {
+	if ($d->{type} eq 'vlan' && $iface =~ m/^(\S+\.\d+)\.\d+$/) {
+	    my $p = $1;
+	    my $n = $ifaces->{$p};
+
+	    die "vlan '$iface' - unable to find parent '$p'\n"
+		if !$n;
+
+	    die "stacked vlan '$iface' - parent '$p' is not a vlan interface "
+		if $n->{type} ne 'vlan';
+
+	    die "stacked vlan '$iface' - parent '$p' vlan-protocol is not 802.1ad" 
+		if !$n->{'vlan-protocol'} || $n->{'vlan-protocol'} ne '802.1ad';
+
+	    die "stacked vlan '$iface' - vlan-protocol can't be 802.1ad" 
+		if $d->{'vlan-protocol'} && $d->{'vlan-protocol'} eq '802.1ad';
+
+	    &$check_mtu($ifaces, $p, $iface);
+
+	} elsif ($d->{type} eq 'vlan' && $iface =~ m/^(\S+)\.\d+$/) {
 	    my $p = $1;
 	    my $n = $ifaces->{$p};
 
@@ -1445,8 +1464,13 @@ sub __write_etc_network_interfaces {
 		die "vlan '$iface' - wrong interface type on parent '$p' " .
 		    "('$n->{type}' != 'eth|bond|bridge' )\n";
 	    }
+
+	    die "bridge vlan '$iface' - vlan-protocol can't be 802.1ad"
+		if ($n->{'vlan-protocol'} && $n->{'vlan-protocol'} eq '802.1ad' && $n->{type} eq 'bridge');
+
 	    &$check_mtu($ifaces, $p, $iface);
 	}
+
     }
 
     # check bridgeport option
diff --git a/test/etc_network_interfaces/t.create_network.pl b/test/etc_network_interfaces/t.create_network.pl
index e446f53..bf5b4b6 100644
--- a/test/etc_network_interfaces/t.create_network.pl
+++ b/test/etc_network_interfaces/t.create_network.pl
@@ -305,6 +305,15 @@ $config->{ifaces}->{'bond0.100'} = {
     mtu => 1300,
     method => 'manual',
     families => ['inet'],
+    'vlan-protocol' => '802.1ad',
+    autostart => 1
+};
+
+$config->{ifaces}->{'bond0.100.10'} = {
+    type => 'vlan',
+    mtu => 1300,
+    method => 'manual',
+    families => ['inet'],
     autostart => 1
 };
 
@@ -336,6 +345,11 @@ $bond0_part
 auto bond0.100
 iface bond0.100 inet manual
 	mtu 1300
+	vlan-protocol 802.1ad
+
+auto bond0.100.10
+iface bond0.100.10 inet manual
+	mtu 1300
 
 $vmbr0_part
 
-- 
2.11.0




More information about the pve-devel mailing list