From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 8EDF41FF184 for ; Thu, 18 Dec 2025 14:25:39 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 0E8081C9EA; Thu, 18 Dec 2025 14:26:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= syntaxhighlighted.com; h=cc:cc:content-transfer-encoding :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to; s=fm3; t=1765984331; x=1766070731; bh=cZM0sGp4/8nsYDOr3vd8y lk6VdOplOEw5Galgibfupw=; b=ZgwMGaY9Of2Dc5DNloLEVg6oWR8zJ4fbUrRS/ znGWNBnRHwguuAIdT6XH5nO86kxg4qFX/ZnOE74+MxXWOQYQe420GIHhyOYDms1H QMzP1rzpcJWirSu2pTabP/QbmUwxttPFN/OC9htbpyi++CzM5GEsz2QO/fzTlp+E pnZubfVITeGYNKJb5vWuhy94DwMJ3QANnLony24uTlJKhyWMQUecnLTjGquzIe5+ TePCYsrDmGrDZytMUoRktkEYc1VcOm0jGqk6ZaKU/esESec+fQbQU+E7kTo6d244 Exy6yKhPJHkFR42rGlRVrhthIAS6uPG/6j6Nb2OiW7ilntHkQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1765984331; x=1766070731; bh=c ZM0sGp4/8nsYDOr3vd8ylk6VdOplOEw5Galgibfupw=; b=xMmj3RCA9BshuMVhZ gATZusrvdJZW7pUyWHWeu9CKZcORHCvg/8gYry8OXKgkwlCIQwbYfZSfR0zwTzs3 jzAlgvpq+tUT1LQSVo3nFSMersZK8IkS4Y/aqpDNuqKhztqb5yp9r4Xdjz2fz6CK MIMPmjYS8Cz3UE6KHHGs9Ok3n4Dt/Ae9gS9VtnLwqKjX6bpNsVzMusoX+ZSAPc6R TdR7VSP/+tHpNKUka357D3dgj89vrTWWkyF2rQvR9vD061ogMtLTJKnU8a4j3HVd 8DJJCcnNOls/ZklbreRtRfISlk/vluE052YVLyn/lxF+7142t50qkMzytCn/bGWy 7qCJQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdegvdeklecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekredtre dttdenucfhrhhomhepmfhriiihshiithhofhcumfhlihhmohhnuggruceokhhklhhimhho nhgurgesshihnhhtrgighhhighhhlhhighhhthgvugdrtghomheqnecuggftrfgrthhtvg hrnhepudejudejfffgveeihedvueeugeeujeeiheeiieetjeektdetveejieetffffteeg necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepkhhklh himhhonhgurgesshihnhhtrgighhhighhhlhhighhhthgvugdrtghomhdpnhgspghrtghp thhtohepvddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepphhvvgdquggvvhgvlh eslhhishhtshdrphhrohigmhhogidrtghomhdprhgtphhtthhopehkkhhlihhmohhnuggr sehshihnthgrgihhihhghhhlihhghhhtvggurdgtohhm X-ME-Proxy: Feedback-ID: i3888429f:Fastmail From: Krzysztof Klimonda To: pve-devel@lists.proxmox.com Date: Wed, 17 Dec 2025 16:10:40 +0100 Message-ID: <20251217151040.34005-2-kklimonda@syntaxhighlighted.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251217151040.34005-1-kklimonda@syntaxhighlighted.com> References: <20251217151040.34005-1-kklimonda@syntaxhighlighted.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.501 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain DMARC_MISSING 0.1 Missing DMARC policy KAM_MAILER 2 Automated Mailer Tag Left in Email RCVD_IN_DNSWL_LOW -0.7 Sender listed at https://www.dnswl.org/, low trust SPF_HELO_PASS -0.001 SPF: HELO matches 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. [syntaxhighlighted.com, bgpplugin.pm, vxlanplugin.pm, controllers.pm, messagingengine.com, evpnplugin.pm, plugin.pm, isisplugin.pm] X-Mailman-Approved-At: Thu, 18 Dec 2025 14:26:19 +0100 Subject: [pve-devel] [PATCH sdn 1/1] fix #7152: sdn: pass interfaces config to avoid repeated ip link calls 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 Cc: Krzysztof Klimonda Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" During FRR configuration generation, find_local_ip_interface_peers is called multiple times from various controller and zone plugins, each call triggering a subprocess execution of ip -details -json link show (via PVE::INotify::read_etc_network_interfaces). Reuse the return value of read_etc_network_interfaces by reading it once in Controllers::generate_frr_config and passing it to functions that need it. --- src/PVE/Network/SDN/Controllers.pm | 4 ++-- src/PVE/Network/SDN/Controllers/BgpPlugin.pm | 4 ++-- src/PVE/Network/SDN/Controllers/EvpnPlugin.pm | 8 ++++---- src/PVE/Network/SDN/Controllers/IsisPlugin.pm | 4 ++-- src/PVE/Network/SDN/Controllers/Plugin.pm | 4 ++-- src/PVE/Network/SDN/Zones/EvpnPlugin.pm | 2 +- src/PVE/Network/SDN/Zones/Plugin.pm | 5 ++--- src/PVE/Network/SDN/Zones/VxlanPlugin.pm | 2 +- 8 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/PVE/Network/SDN/Controllers.pm b/src/PVE/Network/SDN/Controllers.pm index 3c18552..6bf02aa 100644 --- a/src/PVE/Network/SDN/Controllers.pm +++ b/src/PVE/Network/SDN/Controllers.pm @@ -106,7 +106,7 @@ sub generate_frr_config { foreach my $id (sort keys %{ $controller_cfg->{ids} }) { my $plugin_config = $controller_cfg->{ids}->{$id}; my $plugin = PVE::Network::SDN::Controllers::Plugin->lookup($plugin_config->{type}); - $plugin->generate_frr_config($plugin_config, $controller_cfg, $id, $uplinks, $frr_config); + $plugin->generate_frr_config($plugin_config, $controller_cfg, $id, $uplinks, $frr_config, $interfaces_config); } foreach my $id (sort keys %{ $zone_cfg->{ids} }) { @@ -118,7 +118,7 @@ sub generate_frr_config { my $controller_plugin = PVE::Network::SDN::Controllers::Plugin->lookup($controller->{type}); $controller_plugin->generate_zone_frr_config( - $plugin_config, $controller, $controller_cfg, $id, $uplinks, $frr_config, + $plugin_config, $controller, $controller_cfg, $id, $uplinks, $frr_config, $interfaces_config, ); } } diff --git a/src/PVE/Network/SDN/Controllers/BgpPlugin.pm b/src/PVE/Network/SDN/Controllers/BgpPlugin.pm index c84b384..c3e7910 100644 --- a/src/PVE/Network/SDN/Controllers/BgpPlugin.pm +++ b/src/PVE/Network/SDN/Controllers/BgpPlugin.pm @@ -57,7 +57,7 @@ sub options { # Plugin implementation sub generate_frr_config { - my ($class, $plugin_config, $controller, $id, $uplinks, $config) = @_; + my ($class, $plugin_config, $controller, $id, $uplinks, $config, $interfaces_config) = @_; my @peers; @peers = PVE::Tools::split_list($plugin_config->{'peers'}) if $plugin_config->{'peers'}; @@ -76,7 +76,7 @@ sub generate_frr_config { my $bgp = $config->{frr}->{router}->{"bgp $asn"} //= {}; my ($ifaceip, $interface) = - PVE::Network::SDN::Zones::Plugin::find_local_ip_interface_peers(\@peers, $loopback); + PVE::Network::SDN::Zones::Plugin::find_local_ip_interface_peers(\@peers, $loopback, $interfaces_config); my $routerid = PVE::Network::SDN::Controllers::Plugin::get_router_id($ifaceip, $interface); my $remoteas = $ebgp ? "external" : $asn; diff --git a/src/PVE/Network/SDN/Controllers/EvpnPlugin.pm b/src/PVE/Network/SDN/Controllers/EvpnPlugin.pm index e53000a..8e42a05 100644 --- a/src/PVE/Network/SDN/Controllers/EvpnPlugin.pm +++ b/src/PVE/Network/SDN/Controllers/EvpnPlugin.pm @@ -50,7 +50,7 @@ sub options { # Plugin implementation sub generate_frr_config { - my ($class, $plugin_config, $controller_cfg, $id, $uplinks, $config) = @_; + my ($class, $plugin_config, $controller_cfg, $id, $uplinks, $config, $interfaces_config) = @_; my $local_node = PVE::INotify::nodename(); @@ -109,7 +109,7 @@ sub generate_frr_config { } ($ifaceip, my $interface) = - PVE::Network::SDN::Zones::Plugin::find_local_ip_interface_peers(\@peers, $loopback); + PVE::Network::SDN::Zones::Plugin::find_local_ip_interface_peers(\@peers, $loopback, $interfaces_config); $routerid = PVE::Network::SDN::Controllers::Plugin::get_router_id($ifaceip, $interface); } else { log_warn("neither fabric nor peers configured for EVPN controller $plugin_config->{id}"); @@ -173,7 +173,7 @@ sub generate_frr_config { } sub generate_zone_frr_config { - my ($class, $plugin_config, $controller, $controller_cfg, $id, $uplinks, $config) = @_; + my ($class, $plugin_config, $controller, $controller_cfg, $id, $uplinks, $config, $interfaces_config) = @_; my $local_node = PVE::INotify::nodename(); @@ -242,7 +242,7 @@ sub generate_zone_frr_config { } ($ifaceip, my $interface) = - PVE::Network::SDN::Zones::Plugin::find_local_ip_interface_peers(\@peers, $loopback); + PVE::Network::SDN::Zones::Plugin::find_local_ip_interface_peers(\@peers, $loopback, $interfaces_config); $routerid = PVE::Network::SDN::Controllers::Plugin::get_router_id($ifaceip, $interface); } else { diff --git a/src/PVE/Network/SDN/Controllers/IsisPlugin.pm b/src/PVE/Network/SDN/Controllers/IsisPlugin.pm index 3a9acfd..cc92f72 100644 --- a/src/PVE/Network/SDN/Controllers/IsisPlugin.pm +++ b/src/PVE/Network/SDN/Controllers/IsisPlugin.pm @@ -59,7 +59,7 @@ sub options { # Plugin implementation sub generate_frr_config { - my ($class, $plugin_config, $controller, $id, $uplinks, $config) = @_; + my ($class, $plugin_config, $controller, $id, $uplinks, $config, $interfaces_config) = @_; my $isis_ifaces = $plugin_config->{'isis-ifaces'}; my $isis_net = $plugin_config->{'isis-net'}; @@ -92,7 +92,7 @@ sub generate_frr_config { } sub generate_zone_frr_config { - my ($class, $plugin_config, $controller, $controller_cfg, $id, $uplinks, $config) = @_; + my ($class, $plugin_config, $controller, $controller_cfg, $id, $uplinks, $config, $interfaces_config) = @_; } diff --git a/src/PVE/Network/SDN/Controllers/Plugin.pm b/src/PVE/Network/SDN/Controllers/Plugin.pm index d70e518..4c82af1 100644 --- a/src/PVE/Network/SDN/Controllers/Plugin.pm +++ b/src/PVE/Network/SDN/Controllers/Plugin.pm @@ -73,13 +73,13 @@ sub parse_section_header { } sub generate_frr_config { - my ($class, $plugin_config, $controller_cfg, $id, $uplinks, $config) = @_; + my ($class, $plugin_config, $controller_cfg, $id, $uplinks, $config, $interfaces_config) = @_; die "please implement inside plugin"; } sub generate_zone_frr_config { - my ($class, $plugin_config, $controller, $controller_cfg, $id, $uplinks, $config) = @_; + my ($class, $plugin_config, $controller, $controller_cfg, $id, $uplinks, $config, $interfaces_config) = @_; die "please implement inside plugin"; } diff --git a/src/PVE/Network/SDN/Zones/EvpnPlugin.pm b/src/PVE/Network/SDN/Zones/EvpnPlugin.pm index 6d89499..a496c4a 100644 --- a/src/PVE/Network/SDN/Zones/EvpnPlugin.pm +++ b/src/PVE/Network/SDN/Zones/EvpnPlugin.pm @@ -164,7 +164,7 @@ sub generate_sdn_config { } ($ifaceip, $iface) = - PVE::Network::SDN::Zones::Plugin::find_local_ip_interface_peers(\@peers, $loopback); + PVE::Network::SDN::Zones::Plugin::find_local_ip_interface_peers(\@peers, $loopback, $interfaces_config); } elsif ($controller->{fabric}) { my $config = PVE::Network::SDN::Fabrics::config(1); diff --git a/src/PVE/Network/SDN/Zones/Plugin.pm b/src/PVE/Network/SDN/Zones/Plugin.pm index 826ebdf..11d1ca9 100644 --- a/src/PVE/Network/SDN/Zones/Plugin.pm +++ b/src/PVE/Network/SDN/Zones/Plugin.pm @@ -300,10 +300,9 @@ sub get_local_route_ip { } sub find_local_ip_interface_peers { - my ($peers, $iface) = @_; + my ($peers, $iface, $interfaces_config) = @_; - my $network_config = PVE::INotify::read_file('interfaces'); - my $ifaces = $network_config->{ifaces}; + my $ifaces = $interfaces_config->{ifaces}; #if iface is defined, return ip if exist (if not,try to find it on other ifaces) if ($iface) { diff --git a/src/PVE/Network/SDN/Zones/VxlanPlugin.pm b/src/PVE/Network/SDN/Zones/VxlanPlugin.pm index 1db610f..553e07d 100644 --- a/src/PVE/Network/SDN/Zones/VxlanPlugin.pm +++ b/src/PVE/Network/SDN/Zones/VxlanPlugin.pm @@ -91,7 +91,7 @@ sub generate_sdn_config { if ($plugin_config->{peers}) { @peers = PVE::Tools::split_list($plugin_config->{'peers'}) if $plugin_config->{'peers'}; ($ifaceip, $iface) = - PVE::Network::SDN::Zones::Plugin::find_local_ip_interface_peers(\@peers); + PVE::Network::SDN::Zones::Plugin::find_local_ip_interface_peers(\@peers, undef, $interfaces_config); } elsif ($plugin_config->{fabric}) { my $local_node = PVE::INotify::nodename(); my $config = PVE::Network::SDN::Fabrics::config(1); -- 2.52.0 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel