From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id DE4E31FF16B for ; Tue, 15 Jul 2025 11:07:01 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 8B92836BCD; Tue, 15 Jul 2025 11:07:53 +0200 (CEST) From: Dominik Csapak To: pve-devel@lists.proxmox.com Date: Tue, 15 Jul 2025 11:07:49 +0200 Message-Id: <20250715090749.1608768-3-d.csapak@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250715090749.1608768-1-d.csapak@proxmox.com> References: <20250715090749.1608768-1-d.csapak@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.020 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_MSPIKE_H2 0.001 Average reputation (+2) RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [network.pm] Subject: [pve-devel] [PATCH pve-manager v2 1/1] api/ui: show/return alternative interface names X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" in api listing for all interfaces, and in the GET call for an individual interface. For intefaces that are already using an 'altname' in the iface stanza, we look up the 'legacy' interface name and the remaining altnames and show those. If we don't show them, the user might be confused if the bridge ports and interface names don't correlate. enables the additional alternative names column in the network view on the gui. Signed-off-by: Dominik Csapak --- changes from v1: * also show alternative names for ifaces with altname stanza (include legacy iface in that case) * sort the altnames PVE/API2/Network.pm | 41 +++++++++++++++++++++++++++++++++++-- www/manager6/node/Config.js | 1 + 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/PVE/API2/Network.pm b/PVE/API2/Network.pm index a8cd7649..53e0ea0e 100644 --- a/PVE/API2/Network.pm +++ b/PVE/API2/Network.pm @@ -12,6 +12,7 @@ use PVE::RESTHandler; use PVE::RPCEnvironment; use PVE::JSONSchema qw(get_standard_option); use PVE::AccessControl; +use PVE::Network; use IO::File; use base qw(PVE::RESTHandler); @@ -231,6 +232,32 @@ sub json_config_properties { return $prop; } +sub extract_altnames { + my ($iface, $altnames) = @_; + + $altnames = PVE::Network::altname_mapping() if !defined($altnames); + + my $iface_altnames = []; + my $original_iface; + + # when we get an altname, first extract the legacy iface name + if (my $legacy_iface = $altnames->{$iface}) { + push $iface_altnames->@*, $legacy_iface; + $original_iface = $iface; + $iface = $legacy_iface; + } + + for my $altname (keys $altnames->%*) { + next if defined($original_iface) && $original_iface eq $altname; + if ($altnames->{$altname} eq $iface) { + push $iface_altnames->@*, $altname; + } + } + + return [sort $iface_altnames->@*] if scalar($iface_altnames->@*) > 0; + return undef; +} + __PACKAGE__->register_method({ name => 'index', path => '', @@ -390,6 +417,8 @@ __PACKAGE__->register_method({ my $ifaces = $config->{ifaces}; + my $altnames = PVE::Network::altname_mapping(); + delete $ifaces->{lo}; # do not list the loopback device if (my $tfilter = $param->{type}) { @@ -424,6 +453,9 @@ __PACKAGE__->register_method({ my $type = $ifaces->{$k}->{type}; delete $ifaces->{$k} if ($type eq 'bridge' || $type eq 'OVSBridge') && !$can_access_vnet->($k); + + my $iface_altnames = extract_altnames($k, $altnames); + $ifaces->{$k}->{altnames} = $iface_altnames if defined($iface_altnames); } return PVE::RESTHandler::hash_to_array($ifaces, 'iface'); @@ -789,10 +821,15 @@ __PACKAGE__->register_method({ my $config = PVE::INotify::read_file('interfaces'); my $ifaces = $config->{ifaces}; + my $iface = $param->{iface}; + raise_param_exc({ iface => "interface does not exist" }) - if !$ifaces->{ $param->{iface} }; + if !$ifaces->{$iface}; + + my $altnames = extract_altnames($iface); + $ifaces->{$iface}->{altnames} = $altnames if defined($altnames); - return $ifaces->{ $param->{iface} }; + return $ifaces->{$iface}; }, }); diff --git a/www/manager6/node/Config.js b/www/manager6/node/Config.js index 4cd1671c..f6cd8749 100644 --- a/www/manager6/node/Config.js +++ b/www/manager6/node/Config.js @@ -190,6 +190,7 @@ Ext.define('PVE.node.Config', { iconCls: 'fa fa-exchange', itemId: 'network', showApplyBtn: true, + showAltNames: true, groups: ['services'], nodename: nodename, editOptions: { -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel