[pve-devel] [PATCH v2 common 1/6] interfaces: allow arbitrary bridge names in network config
Stefan Hanreich
s.hanreich at proxmox.com
Fri Feb 23 15:36:46 CET 2024
Similar to other interface types, we can detect a bridge by the
presense of it's 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.
Originally-by: Jillian Morgan <jillian.morgan at primordial.ca>
Signed-off-by: Stefan Hanreich <s.hanreich at proxmox.com>
---
src/PVE/INotify.pm | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/src/PVE/INotify.pm b/src/PVE/INotify.pm
index bc33a8f..8a34128 100644
--- a/src/PVE/INotify.pm
+++ b/src/PVE/INotify.pm
@@ -1033,7 +1033,17 @@ sub __read_etc_network_interfaces {
foreach my $iface (keys %$ifaces) {
my $d = $ifaces->{$iface};
$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}) {
$d->{type} = 'bond';
} elsif ($d->{ovs_type} eq 'OVSBond') {
@@ -1053,18 +1063,6 @@ sub __read_etc_network_interfaces {
my $tag = &$extract_ovs_option($d, '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+$/) {
$d->{type} = 'alias';
if (defined ($ifaces->{$1})) {
--
2.39.2
More information about the pve-devel
mailing list