From: Krzysztof Klimonda <kklimonda@syntaxhighlighted.com>
To: pve-devel@lists.proxmox.com
Cc: Krzysztof Klimonda <kklimonda@syntaxhighlighted.com>
Subject: [pve-devel] [PATCH sdn 1/1] fix #7152: sdn: pass interfaces config to avoid repeated ip link calls
Date: Wed, 17 Dec 2025 16:10:40 +0100 [thread overview]
Message-ID: <20251217151040.34005-2-kklimonda@syntaxhighlighted.com> (raw)
In-Reply-To: <20251217151040.34005-1-kklimonda@syntaxhighlighted.com>
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
prev parent reply other threads:[~2025-12-18 13:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-17 15:10 [pve-devel] [PATCH sdn 0/1] fix #7152: avoid repeated ip link calls during SDN configuration Krzysztof Klimonda
2025-12-17 15:10 ` Krzysztof Klimonda [this message]
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=20251217151040.34005-2-kklimonda@syntaxhighlighted.com \
--to=kklimonda@syntaxhighlighted.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