mirror of
git://git.proxmox.com/git/pve-common.git
synced 2024-12-22 21:33:47 +03:00
fix #545: interfaces: allow arbitrary bridge names in network config
Similar to other interface types, we can detect a bridge by the presence of its bridge_ports attribute, rather than solely relying on the "vmbr" ifname prefix heuristic. For OVS bridges we need to examine the OVS type instead. The check needs to be moved up since other prefixes could theoretically be included in a bridge name and then would otherwise get picked up wrongly. Also added a warning for interfaces named vmbrX that are not bridges to catch possible misconfigurations. Originally-by: Jillian Morgan <jillian.morgan@primordial.ca> Reviewed-by: Fabian Grünbichler <f.gruenbichler@proxmox.com> Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
This commit is contained in:
parent
55ba8536f0
commit
e68ebda4f1
@ -22,6 +22,7 @@ use PVE::Network;
|
|||||||
use PVE::ProcFSTools;
|
use PVE::ProcFSTools;
|
||||||
use PVE::SafeSyslog;
|
use PVE::SafeSyslog;
|
||||||
use PVE::Tools;
|
use PVE::Tools;
|
||||||
|
use PVE::RESTEnvironment qw(log_warn);
|
||||||
|
|
||||||
use base 'Exporter';
|
use base 'Exporter';
|
||||||
|
|
||||||
@ -1033,7 +1034,17 @@ sub __read_etc_network_interfaces {
|
|||||||
foreach my $iface (sort keys %$ifaces) {
|
foreach my $iface (sort keys %$ifaces) {
|
||||||
my $d = $ifaces->{$iface};
|
my $d = $ifaces->{$iface};
|
||||||
$d->{type} = 'unknown';
|
$d->{type} = 'unknown';
|
||||||
if ($iface =~ m/^bond\d+$/) {
|
if (defined $d->{'bridge_ports'}) {
|
||||||
|
$d->{type} = 'bridge';
|
||||||
|
if (!defined ($d->{bridge_stp})) {
|
||||||
|
$d->{bridge_stp} = 'off';
|
||||||
|
}
|
||||||
|
if (!defined($d->{bridge_fd}) && $d->{bridge_stp} eq 'off') {
|
||||||
|
$d->{bridge_fd} = 0;
|
||||||
|
}
|
||||||
|
} elsif ($d->{ovs_type} && $d->{ovs_type} eq 'OVSBridge') {
|
||||||
|
$d->{type} = $d->{ovs_type};
|
||||||
|
} elsif ($iface =~ m/^bond\d+$/) {
|
||||||
if (!$d->{ovs_type}) {
|
if (!$d->{ovs_type}) {
|
||||||
$d->{type} = 'bond';
|
$d->{type} = 'bond';
|
||||||
} elsif ($d->{ovs_type} eq 'OVSBond') {
|
} elsif ($d->{ovs_type} eq 'OVSBond') {
|
||||||
@ -1053,18 +1064,6 @@ sub __read_etc_network_interfaces {
|
|||||||
my $tag = &$extract_ovs_option($d, 'tag');
|
my $tag = &$extract_ovs_option($d, 'tag');
|
||||||
$d->{ovs_tag} = $tag if defined($tag);
|
$d->{ovs_tag} = $tag if defined($tag);
|
||||||
}
|
}
|
||||||
} elsif ($iface =~ m/^vmbr\d+$/) {
|
|
||||||
if (!$d->{ovs_type}) {
|
|
||||||
$d->{type} = 'bridge';
|
|
||||||
if (!defined ($d->{bridge_stp})) {
|
|
||||||
$d->{bridge_stp} = 'off';
|
|
||||||
}
|
|
||||||
if (!defined($d->{bridge_fd}) && $d->{bridge_stp} eq 'off') {
|
|
||||||
$d->{bridge_fd} = 0;
|
|
||||||
}
|
|
||||||
} elsif ($d->{ovs_type} eq 'OVSBridge') {
|
|
||||||
$d->{type} = $d->{ovs_type};
|
|
||||||
}
|
|
||||||
} elsif ($iface =~ m/^(\S+):\d+$/) {
|
} elsif ($iface =~ m/^(\S+):\d+$/) {
|
||||||
$d->{type} = 'alias';
|
$d->{type} = 'alias';
|
||||||
if (defined ($ifaces->{$1})) {
|
if (defined ($ifaces->{$1})) {
|
||||||
@ -1127,6 +1126,9 @@ sub __read_etc_network_interfaces {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log_warn("detected a interface $iface that is not a bridge!")
|
||||||
|
if !($d->{type} eq 'OVSBridge' || $d->{type} eq 'bridge') && $iface =~ m/^vmbr\d+$/;
|
||||||
|
|
||||||
# map address and netmask to cidr
|
# map address and netmask to cidr
|
||||||
if (my $addr = $d->{address}) {
|
if (my $addr = $d->{address}) {
|
||||||
if (_address_is_cidr($addr)) {
|
if (_address_is_cidr($addr)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user