From: Stefan Hanreich <s.hanreich@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH pve-common v2 1/1] inotify/interfaces: use ip link for detecting physical interfaces
Date: Tue, 29 Jul 2025 19:16:43 +0200 [thread overview]
Message-ID: <20250729171649.708219-2-s.hanreich@proxmox.com> (raw)
In-Reply-To: <20250729171649.708219-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.47.2
_______________________________________________
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-29 17:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-29 17:16 [pve-devel] [PATCH common/manager v2 0/3] arbitrary prefixes for pinning network interfaces Stefan Hanreich
2025-07-29 17:16 ` Stefan Hanreich [this message]
2025-07-29 19:21 ` [pve-devel] applied: [PATCH pve-common v2 1/1] inotify/interfaces: use ip link for detecting physical interfaces Thomas Lamprecht
2025-07-29 17:16 ` [pve-devel] [PATCH pve-manager v2 1/2] pvestatd: pull metric: use ip link to detect " Stefan Hanreich
2025-07-29 19:21 ` [pve-devel] applied: " Thomas Lamprecht
2025-07-29 17:16 ` [pve-devel] [PATCH pve-manager v2 2/2] network-interface-pinning: allow arbitrary names Stefan Hanreich
2025-07-29 19:21 ` [pve-devel] applied: " Thomas Lamprecht
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=20250729171649.708219-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.