]> git.proxmox.com Git - pve-common.git/commitdiff
Inotify : add check vlan
authorAlexandre Derumier <aderumier@odiso.com>
Thu, 5 Jul 2018 00:56:33 +0000 (02:56 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Tue, 10 Jul 2018 09:38:54 +0000 (11:38 +0200)
verify than parent interface exist
verify than parent interface type is eth,bond,bridge
verify than parent bridge is vlan aware if type bridge

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

index f4a594571a49bfef69c4344bbcb0b2104919e70a..f0f3144355c7d35319b9e4e2cc39f82bbbc7b29b 100644 (file)
@@ -1358,6 +1358,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+$/) {
+           my $p = $1;
+           my $n = $ifaces->{$p};
+
+           die "vlan '$iface' - unable to find parent '$p'\n"
+               if $n->{exists} eq 0;
+
+           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') {
+               die "vlan '$iface' - wrong interface type on parent '$p' " .
+                   "('$n->{type}' != 'eth|bond|bridge' )\n";
+           }
+       }
+    }
+
     # check bridgeport option
     my $bridgeports = {};
     my $bridges = {};
index da479999a02909b09250c6bcaa2b8374b89068af..fda7237edd99dd3911ccd482bf3a6bb8e806ada8 100644 (file)
@@ -60,7 +60,6 @@ $config->{ifaces}->{vmbr1} = {
     autostart => 1
 };
 
-
 $config->{ifaces}->{vmbr2} = {
     type => 'bridge',
     method => 'manual',
@@ -116,6 +115,26 @@ $config->{ifaces}->{vxlan3} = {
     autostart => 1
 };
 
+$config->{ifaces}->{'vmbr1.100'} = {
+    type => 'vlan',
+    method => 'manual',
+    families => ['inet'],
+    autostart => 1
+};
+
+$config->{ifaces}->{'bond0.100'} = {
+    type => 'vlan',
+    method => 'manual',
+    families => ['inet'],
+    autostart => 1
+};
+
+$config->{ifaces}->{'eth1.100'} = {
+    type => 'vlan',
+    method => 'manual',
+    families => ['inet'],
+    autostart => 1
+};
 
 expect load('loopback') . <<"CHECK";
 source-directory interfaces.d
@@ -134,6 +153,9 @@ iface eth2 inet manual
 auto eth3
 iface eth3 inet manual
 
+auto eth1.100
+iface eth1.100 inet manual
+
 auto bond0
 iface bond0 inet manual
        bond-slaves eth2 eth3
@@ -141,6 +163,9 @@ iface bond0 inet manual
        bond-mode 802.3ad
        bond-xmit-hash-policy layer3+4
 
+auto bond0.100
+iface bond0.100 inet manual
+
 auto vmbr0
 iface vmbr0 inet static
        address  10.0.0.2
@@ -172,6 +197,9 @@ iface vmbr3 inet manual
        bridge-vlan-aware yes
        bridge-vids 2-10
 
+auto vmbr1.100
+iface vmbr1.100 inet manual
+
 auto vxlan1
 iface vxlan1 inet manual
        vxlan-id 1