From: Stefan Hanreich <s.hanreich@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v3 common 1/6] interfaces: allow arbitrary bridge names in network config
Date: Thu, 29 Feb 2024 11:40:59 +0100 [thread overview]
Message-ID: <20240229104104.111188-2-s.hanreich@proxmox.com> (raw)
In-Reply-To: <20240229104104.111188-1-s.hanreich@proxmox.com>
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>
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
---
Warning in the read function is a bit awkward, since for one
interfaces multiple warnings are generated - due to multiple calls to
the read function during the apply process. I think it's ok though due
to this being a relatively fringe warning which hopefully shouldn't
come up too often...
src/PVE/INotify.pm | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/src/PVE/INotify.pm b/src/PVE/INotify.pm
index bc33a8f..13724f7 100644
--- a/src/PVE/INotify.pm
+++ b/src/PVE/INotify.pm
@@ -22,6 +22,7 @@ use PVE::Network;
use PVE::ProcFSTools;
use PVE::SafeSyslog;
use PVE::Tools;
+use PVE::RESTEnvironment qw(log_warn);
use base 'Exporter';
@@ -1033,7 +1034,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 +1064,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})) {
@@ -1116,6 +1115,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
if (my $addr = $d->{address}) {
if (_address_is_cidr($addr)) {
--
2.39.2
next prev parent reply other threads:[~2024-02-29 10:41 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-29 10:40 [pve-devel] [PATCH v3 common/docs/widget-toolkit/manager/firewall 0/6] drop vmbr prefix for bridges Stefan Hanreich
2024-02-29 10:40 ` Stefan Hanreich [this message]
2024-02-29 10:41 ` [pve-devel] [PATCH v3 docs 2/6] network: update specification for bridge names Stefan Hanreich
2024-04-11 14:21 ` Fabian Grünbichler
2024-02-29 10:41 ` [pve-devel] [PATCH v3 widget-toolkit 3/6] network: allow bridges to have any valid interface name Stefan Hanreich
2024-02-29 10:41 ` [pve-devel] [PATCH v3 manager 4/6] sdn: qinq: vlan: properly validate bridge name Stefan Hanreich
2024-02-29 10:41 ` [pve-devel] [PATCH v3 manager 5/6] sdn: vlan: fix indentation in vlan edit dialogue Stefan Hanreich
2024-02-29 10:41 ` [pve-devel] [PATCH v3 firewall 6/6] simulator: use new bridge naming scheme Stefan Hanreich
2024-04-11 14:21 ` [pve-devel] [PATCH v3 common/docs/widget-toolkit/manager/firewall 0/6] drop vmbr prefix for bridges Fabian Grünbichler
2024-04-12 7:46 ` Stefan Hanreich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240229104104.111188-2-s.hanreich@proxmox.com \
--to=s.hanreich@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox