From: Stefan Hanreich <s.hanreich@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH pve-common 1/1] inotify/interfaces: use ip link for detecting physical interfaces
Date: Thu, 24 Jul 2025 16:49:57 +0200 [thread overview]
Message-ID: <20250724144959.374061-2-s.hanreich@proxmox.com> (raw)
In-Reply-To: <20250724144959.374061-1-s.hanreich@proxmox.com>
The parser for /e/n/i relied on PHYSICAL_NIC_RE for detecting physical
interfaces. In order to allow arbitrary interface names for pinning
physical interfaces, switch over to detecting physical interfaces via
'ip link' instead.
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
---
src/PVE/INotify.pm | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/src/PVE/INotify.pm b/src/PVE/INotify.pm
index 7466c40..d7e5add 100644
--- a/src/PVE/INotify.pm
+++ b/src/PVE/INotify.pm
@@ -878,6 +878,8 @@ sub __read_etc_network_interfaces {
my $ifaces = $config->{ifaces} = {};
my $options = $config->{options} = [];
+ my $altnames = PVE::Network::altname_mapping($ip_links);
+
my $options_alternatives = {
'ovs_mtu' => 'mtu',
'bond-slaves' => 'slaves',
@@ -1042,7 +1044,7 @@ OUTER:
for my $iface_name (keys $ip_links->%*) {
my $ip_link = $ip_links->{$iface_name};
- next if $iface_name !~ m/^$PVE::Network::PHYSICAL_NIC_RE$/;
+ next if !PVE::Network::ip_link_is_physical($ip_link);
for my $altname ($ip_link->{altnames}->@*) {
if ($ifaces->{$altname}) {
@@ -1072,6 +1074,9 @@ OUTER:
foreach my $iface (sort keys %$ifaces) {
my $d = $ifaces->{$iface};
$d->{type} = 'unknown';
+
+ my $ip_link = $ip_links->{$altnames->{$iface} // $iface};
+
if (defined $d->{'bridge_ports'}) {
$d->{type} = 'bridge';
if (!defined($d->{bridge_stp})) {
@@ -1140,7 +1145,7 @@ OUTER:
$ifaces->{$raw_iface}->{exists} = 0;
$d->{exists} = 0;
}
- } elsif ($iface =~ m/^$PVE::Network::PHYSICAL_NIC_RE$/) {
+ } elsif ($ip_link && PVE::Network::ip_link_is_physical($ip_link)) {
if (!$d->{ovs_type}) {
$d->{type} = 'eth';
} elsif ($d->{ovs_type} eq 'OVSPort') {
@@ -1550,16 +1555,12 @@ sub __write_etc_network_interfaces {
if ($d->{type} eq 'OVSPort' || $d->{type} eq 'OVSIntPort' || $d->{type} eq 'OVSBond') {
my $brname = $used_ports->{$iface};
if (!$brname || !$ifaces->{$brname}) {
- if ($iface =~ /^$PVE::Network::PHYSICAL_NIC_RE/) {
- $ifaces->{$iface} = {
- type => 'eth',
- exists => 1,
- method => 'manual',
- families => ['inet'],
- };
- } else {
- delete $ifaces->{$iface};
- }
+ $ifaces->{$iface} = {
+ type => 'eth',
+ exists => 1,
+ method => 'manual',
+ families => ['inet'],
+ };
next;
}
my $bd = $ifaces->{$brname};
--
2.39.5
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
next prev parent reply other threads:[~2025-07-24 14:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-24 14:49 [pve-devel] [RFC common/manager 0/3] arbitrary prefixes for pinning network interfaces Stefan Hanreich
2025-07-24 14:49 ` Stefan Hanreich [this message]
2025-07-24 14:49 ` [pve-devel] [PATCH pve-manager 1/2] pvestatd: pull metric: use ip link to detect physical interfaces Stefan Hanreich
2025-07-24 14:49 ` [pve-devel] [PATCH pve-manager 2/2] network-interface-pinning: allow arbitrary names Stefan Hanreich
2025-07-29 17:17 ` [pve-devel] superseded: [RFC common/manager 0/3] arbitrary prefixes for pinning network interfaces 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=20250724144959.374061-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