5
0
mirror of git://git.proxmox.com/git/pve-common.git synced 2024-12-22 21:33:47 +03:00

remove autostart property from bridge ports

Fixes #711
This commit is contained in:
Wolfgang Bumiller 2015-09-14 10:52:30 +02:00 committed by Dietmar Maurer
parent ef69578b74
commit 21d32c95cd
3 changed files with 40 additions and 3 deletions

View 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};

View File

@ -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;

View 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