[pve-devel] [PATCH pve-common] remove autostart property from bridge ports

Wolfgang Bumiller w.bumiller at proxmox.com
Mon Sep 14 10:52:30 CEST 2015


Fixes #711
---
 src/PVE/INotify.pm                                 | 14 +++++++++++++
 .../t.bridge_eth_remove_auto.pl                    | 24 ++++++++++++++++++++++
 test/etc_network_interfaces/t.ovs_bridge_allow.pl  |  5 ++---
 3 files changed, 40 insertions(+), 3 deletions(-)
 create mode 100644 test/etc_network_interfaces/t.bridge_eth_remove_auto.pl

diff --git a/src/PVE/INotify.pm b/src/PVE/INotify.pm
index 564814e..136dd90 100644
--- a/src/PVE/INotify.pm
+++ b/src/PVE/INotify.pm
@@ -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
index 0000000..0b073d9
--- /dev/null
+++ b/test/etc_network_interfaces/t.bridge_eth_remove_auto.pl
@@ -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;
diff --git a/test/etc_network_interfaces/t.ovs_bridge_allow.pl b/test/etc_network_interfaces/t.ovs_bridge_allow.pl
index 7a0b8ce..6d22243 100644
--- a/test/etc_network_interfaces/t.ovs_bridge_allow.pl
+++ b/test/etc_network_interfaces/t.ovs_bridge_allow.pl
@@ -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
-- 
2.1.4





More information about the pve-devel mailing list