]> git.proxmox.com Git - pve-common.git/commitdiff
remove autostart property from bridge ports
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 14 Sep 2015 08:52:30 +0000 (10:52 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 14 Sep 2015 10:42:47 +0000 (12:42 +0200)
Fixes #711

src/PVE/INotify.pm
test/etc_network_interfaces/t.bridge_eth_remove_auto.pl [new file with mode: 0644]
test/etc_network_interfaces/t.ovs_bridge_allow.pl

index 564814e819b038d965ac9c4dfa0b91f527f5d16f..136dd90f36d22abf37bd596fd385c592346b9b6c 100644 (file)
@@ -1216,6 +1216,7 @@ sub __write_etc_network_interfaces {
                my $n = $ifaces->{$p};
                die "OVS bridge '$iface' - unable to find port '$p'\n"
                    if !$n;
+               $n->{autostart} = 0;
                if ($n->{type} eq 'eth') {
                    $n->{type} = 'OVSPort';
                    $n->{ovs_bridge} = $iface;              
@@ -1229,6 +1230,19 @@ sub __write_etc_network_interfaces {
        }
     }
 
+    # Remove autostart from linux bridge ports
+    foreach my $iface (keys %$ifaces) {
+       my $d = $ifaces->{$iface};
+       if ($d->{type} eq 'bridge' && $d->{bridge_ports}) {
+           foreach my $p (split (/\s+/, $d->{bridge_ports})) {
+               my $n = $ifaces->{$p};
+               die "bridge '$iface' - unable to find port '$p'\n"
+                   if !$n;
+               $n->{autostart} = 0;
+           }
+       }
+    }
+
     # check OVS bond ports
     foreach my $iface (keys %$ifaces) {
        my $d = $ifaces->{$iface};
diff --git a/test/etc_network_interfaces/t.bridge_eth_remove_auto.pl b/test/etc_network_interfaces/t.bridge_eth_remove_auto.pl
new file mode 100644 (file)
index 0000000..0b073d9
--- /dev/null
@@ -0,0 +1,24 @@
+use strict;
+
+# access to the current config
+our $config;
+
+# replace proc_net_dev with one with a bunch of interfaces
+save('proc_net_dev', <<'/proc/net/dev');
+eth0:
+eth1:
+/proc/net/dev
+
+r('');
+update_iface('eth0', [], autostart => 1);
+update_iface('eth1', [], autostart => 1);
+r(w());
+die "autostart lost" if !$config->{ifaces}->{eth0}->{autostart};
+die "autostart lost" if !$config->{ifaces}->{eth1}->{autostart};
+new_iface("vmbr0", 'bridge', [{ family => 'inet' }], bridge_ports => 'eth0');
+new_iface("vmbr1", 'OVSBridge', [{ family => 'inet' }], ovs_ports => 'eth1');
+r(w());
+die "autostart not removed for linux bridge port" if $config->{ifaces}->{eth0}->{autostart};
+die "autostart not removed for ovs bridge port" if $config->{ifaces}->{eth1}->{autostart};
+
+1;
index 7a0b8cec7103d42b52220079703d321da16933b5..6d22243b3d7563660a20e283a139e4b1680e0cd5 100644 (file)
@@ -48,19 +48,18 @@ iface vmbr0 inet static
 
 /etc/network/interfaces
 
-# Adding an interface to the bridge needs to add allow- lines:
+# Adding an interface to the bridge needs to add allow- lines and remove
+# its autostart property.
 update_iface('vmbr0', [], ovs_ports => 'eth1 eth2');
 expect load('loopback') . <<"/etc/network/interfaces";
 auto eth0
 iface eth0 inet manual
 
-auto eth1
 allow-vmbr0 eth1
 iface eth1 inet manual
        ovs_type OVSPort
        ovs_bridge vmbr0
 
-auto eth2
 allow-vmbr0 eth2
 iface eth2 inet manual
        ovs_type OVSPort