* [pve-devel] [RFC common/manager 0/3] arbitrary prefixes for pinning network interfaces
@ 2025-07-24 14:49 Stefan Hanreich
2025-07-24 14:49 ` [pve-devel] [PATCH pve-common 1/1] inotify/interfaces: use ip link for detecting physical interfaces Stefan Hanreich
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Stefan Hanreich @ 2025-07-24 14:49 UTC (permalink / raw)
To: pve-devel
This patch series lifts the restriction for naming physical interfaces.
Previously we relied on a regex (PHYSICAL_NIC_RE) for determining whether an
interface was physical or not. This patch series changes that, by querying the
kernel for the type of the interface and using that to determine whether an
interface is a physical interface or not. This allows us to use arbitrary names
for physical interfaces, which in turn allows proxmox-network-interface-pinning
to use arbitrary prefixes / target-names when pinning network interfaces.
The main change here is with pvestatd and metric collection, where we used the
regex to determine the type of interface in PullMetric. I introduced a new key
in the netdev hash that indicates the type of interface. Since my knowledge of
this component is almost zero, I'm not sure if this is the proper approach.
Maybe someone with more experience can chime in on possible issues /
improvements.
This patch series applies on top of my previous series that improves several
aspects of the pinning tool [1].
pve-manager depends on pve-common
[1] https://lore.proxmox.com/pve-devel/20250724093459.76397-1-s.hanreich@proxmox.com/T/#t
pve-common:
Stefan Hanreich (1):
inotify/interfaces: use ip link for detecting physical interfaces
src/PVE/INotify.pm | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
pve-manager:
Stefan Hanreich (2):
pvestatd: pull metric: use ip link to detect physical interfaces
network-interface-pinning: allow arbitrary names
PVE/CLI/proxmox_network_interface_pinning.pm | 7 ++++---
PVE/PullMetric.pm | 15 ++++++++++++---
PVE/Service/pvestatd.pm | 13 ++++++++++++-
3 files changed, 28 insertions(+), 7 deletions(-)
Summary over all repositories:
4 files changed, 41 insertions(+), 19 deletions(-)
--
Generated by git-murpp 0.8.0
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* [pve-devel] [PATCH pve-common 1/1] inotify/interfaces: use ip link for detecting physical interfaces
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
2025-07-24 14:49 ` [pve-devel] [PATCH pve-manager 1/2] pvestatd: pull metric: use ip link to detect " Stefan Hanreich
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Stefan Hanreich @ 2025-07-24 14:49 UTC (permalink / raw)
To: pve-devel
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* [pve-devel] [PATCH pve-manager 1/2] pvestatd: pull metric: use ip link to detect physical interfaces
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 ` [pve-devel] [PATCH pve-common 1/1] inotify/interfaces: use ip link for detecting physical interfaces Stefan Hanreich
@ 2025-07-24 14:49 ` 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
3 siblings, 0 replies; 5+ messages in thread
From: Stefan Hanreich @ 2025-07-24 14:49 UTC (permalink / raw)
To: pve-devel
pve-common now allows arbitrary names for physical interfaces, without
being restricted by PHYSICAL_NIC_RE. In order to detect physical
interfaces, pvestatd now needs to query 'ip link' for the type of an
interface instead of relying on the regular expression.
On the receiving end, PullMetric cannot consult 'ip link' for
determining which interface is physical or not. To work around that,
introduce a new type key, that carries information about the type of
an interface. When aggregating the metrics, PullMetric can now read
this additional parameter, to infer the type of the interface. For now
we only set the type for physical interfaces, otherwise to unknown.
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
---
PVE/PullMetric.pm | 15 ++++++++++++---
PVE/Service/pvestatd.pm | 13 ++++++++++++-
2 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/PVE/PullMetric.pm b/PVE/PullMetric.pm
index f55653505..24310c30e 100644
--- a/PVE/PullMetric.pm
+++ b/PVE/PullMetric.pm
@@ -91,9 +91,18 @@ my sub get_node_metrics {
push @$metrics, gauge($id, $timestamp, "uptime", $data->{uptime});
my ($netin, $netout) = (0, 0);
- for my $dev (grep { /^$PVE::Network::PHYSICAL_NIC_RE$/ } keys $data->{nics}->%*) {
- $netin += $data->{nics}->{$dev}->{receive};
- $netout += $data->{nics}->{$dev}->{transmit};
+
+ for my $dev (keys $data->{nics}->%*) {
+ my $nic_data = $data->{nics}->{$dev};
+
+ if ($nic_data->{type}) {
+ next if $nic_data->{type} ne 'physical';
+ } else {
+ next if $dev !~ /^$PVE::Network::PHYSICAL_NIC_RE$/;
+ }
+
+ $netin += $nic_data->{receive};
+ $netout += $nic_data->{transmit};
}
push @$metrics, derive($id, $timestamp, "net_in", $netin);
push @$metrics, derive($id, $timestamp, "net_out", $netout);
diff --git a/PVE/Service/pvestatd.pm b/PVE/Service/pvestatd.pm
index e645eec3c..c91adeca8 100755
--- a/PVE/Service/pvestatd.pm
+++ b/PVE/Service/pvestatd.pm
@@ -171,9 +171,20 @@ sub update_node_status {
my $sublevel = $subinfo->{level} || '';
my $netdev = PVE::ProcFSTools::read_proc_net_dev();
+ my $ip_links = PVE::Network::ip_link_details();
+
# traffic from/to physical interface cards
my ($netin, $netout) = (0, 0);
- for my $dev (grep { /^$PVE::Network::PHYSICAL_NIC_RE$/ } keys %$netdev) {
+ for my $dev (keys %$netdev) {
+ my $ip_link = $ip_links->{$dev};
+
+ if (PVE::Network::ip_link_is_physical($ip_link)) {
+ $netdev->{$dev}->{type} = 'physical';
+ } else {
+ $netdev->{$dev}->{type} = 'unknown';
+ next;
+ }
+
$netin += $netdev->{$dev}->{receive};
$netout += $netdev->{$dev}->{transmit};
}
--
2.39.5
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* [pve-devel] [PATCH pve-manager 2/2] network-interface-pinning: allow arbitrary names
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 ` [pve-devel] [PATCH pve-common 1/1] inotify/interfaces: use ip link for detecting physical interfaces Stefan Hanreich
2025-07-24 14:49 ` [pve-devel] [PATCH pve-manager 1/2] pvestatd: pull metric: use ip link to detect " Stefan Hanreich
@ 2025-07-24 14:49 ` Stefan Hanreich
2025-07-29 17:17 ` [pve-devel] superseded: [RFC common/manager 0/3] arbitrary prefixes for pinning network interfaces Stefan Hanreich
3 siblings, 0 replies; 5+ messages in thread
From: Stefan Hanreich @ 2025-07-24 14:49 UTC (permalink / raw)
To: pve-devel
With the changes to physical interface detection in pve-common and
pve-manager, it is now possible to use arbitrary names for physical
interfaces in our network stack. This allows the removal of the
existing, hardcoded, prefixes.
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
---
PVE/CLI/proxmox_network_interface_pinning.pm | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/PVE/CLI/proxmox_network_interface_pinning.pm b/PVE/CLI/proxmox_network_interface_pinning.pm
index e2ad8c69f..d09b380f4 100644
--- a/PVE/CLI/proxmox_network_interface_pinning.pm
+++ b/PVE/CLI/proxmox_network_interface_pinning.pm
@@ -367,16 +367,17 @@ __PACKAGE__->register_method({
optional => 1,
},
prefix => {
- description => 'Only pin a specific interface.',
+ description => 'Prefix for auto-generating network interface names. '
+ . 'Generated names will use that prefix + the index appended ("prefixN")',
type => 'string',
- enum => ['nic', 'if'],
+ pattern => '^[a-zA-Z][a-zA-Z0-9-_]{0,7}$',
default => 'nic', # just for the docs.
optional => 1,
},
'target-name' => {
description => 'Pin the interface to a specific name',
type => 'string',
- pattern => '(?:nic|if)\d+',
+ format => 'pve-iface',
optional => 1,
},
},
--
2.39.5
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* [pve-devel] superseded: [RFC common/manager 0/3] arbitrary prefixes for pinning network interfaces
2025-07-24 14:49 [pve-devel] [RFC common/manager 0/3] arbitrary prefixes for pinning network interfaces Stefan Hanreich
` (2 preceding siblings ...)
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 ` Stefan Hanreich
3 siblings, 0 replies; 5+ messages in thread
From: Stefan Hanreich @ 2025-07-29 17:17 UTC (permalink / raw)
To: pve-devel
https://lore.proxmox.com/pve-devel/20250729171649.708219-1-s.hanreich@proxmox.com/T/#t
On 7/24/25 4:49 PM, Stefan Hanreich wrote:
> This patch series lifts the restriction for naming physical interfaces.
> Previously we relied on a regex (PHYSICAL_NIC_RE) for determining whether an
> interface was physical or not. This patch series changes that, by querying the
> kernel for the type of the interface and using that to determine whether an
> interface is a physical interface or not. This allows us to use arbitrary names
> for physical interfaces, which in turn allows proxmox-network-interface-pinning
> to use arbitrary prefixes / target-names when pinning network interfaces.
>
> The main change here is with pvestatd and metric collection, where we used the
> regex to determine the type of interface in PullMetric. I introduced a new key
> in the netdev hash that indicates the type of interface. Since my knowledge of
> this component is almost zero, I'm not sure if this is the proper approach.
> Maybe someone with more experience can chime in on possible issues /
> improvements.
>
> This patch series applies on top of my previous series that improves several
> aspects of the pinning tool [1].
>
> pve-manager depends on pve-common
>
> [1] https://lore.proxmox.com/pve-devel/20250724093459.76397-1-s.hanreich@proxmox.com/T/#t
>
> pve-common:
>
> Stefan Hanreich (1):
> inotify/interfaces: use ip link for detecting physical interfaces
>
> src/PVE/INotify.pm | 25 +++++++++++++------------
> 1 file changed, 13 insertions(+), 12 deletions(-)
>
>
> pve-manager:
>
> Stefan Hanreich (2):
> pvestatd: pull metric: use ip link to detect physical interfaces
> network-interface-pinning: allow arbitrary names
>
> PVE/CLI/proxmox_network_interface_pinning.pm | 7 ++++---
> PVE/PullMetric.pm | 15 ++++++++++++---
> PVE/Service/pvestatd.pm | 13 ++++++++++++-
> 3 files changed, 28 insertions(+), 7 deletions(-)
>
>
> Summary over all repositories:
> 4 files changed, 41 insertions(+), 19 deletions(-)
>
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-07-29 17:16 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [pve-devel] [PATCH pve-common 1/1] inotify/interfaces: use ip link for detecting physical interfaces Stefan Hanreich
2025-07-24 14:49 ` [pve-devel] [PATCH pve-manager 1/2] pvestatd: pull metric: use ip link to detect " 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
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.