From: Gabriel Goller <g.goller@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH pve-network v5 10/21] sdn: frr: add daemon status to frr helper
Date: Wed, 16 Jul 2025 15:08:05 +0200 [thread overview]
Message-ID: <20250716130837.585796-45-g.goller@proxmox.com> (raw)
In-Reply-To: <20250716130837.585796-1-g.goller@proxmox.com>
From: Stefan Hanreich <s.hanreich@proxmox.com>
Add functions that allow reading and manipulating values in the
/etc/frr/daemons file. We need this for en/disabling daemons depending
on which fabric types are configured. We enable daemons dynamically,
depending on the currently configured fabrics. If a daemon is enabled
but all fabrics using it get deleted, we disable them as well.
The helper works by iterating over the lines of the daemons file from
FRR, parsing the key and checking if the key is managed by the SDN
configuration, then sets it. As a safeguard, keys that can be changed
by SDN have to be explicitly configured in the respective hash of the
Frr module.
Co-authored-by: Gabriel Goller <g.goller@proxmox.com>
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
---
src/PVE/Network/SDN.pm | 18 +++++++++-
src/PVE/Network/SDN/Fabrics.pm | 15 ++++++++
src/PVE/Network/SDN/Frr.pm | 64 ++++++++++++++++++++++++++++++++++
3 files changed, 96 insertions(+), 1 deletion(-)
diff --git a/src/PVE/Network/SDN.pm b/src/PVE/Network/SDN.pm
index b321013708a9..bd6f7a28dd54 100644
--- a/src/PVE/Network/SDN.pm
+++ b/src/PVE/Network/SDN.pm
@@ -293,16 +293,32 @@ sub generate_frr_raw_config {
return $raw_config;
}
+=head3 get_frr_daemon_status(\%fabric_config)
+
+Returns a hash that indicates which FRR daemons, that are managed by SDN, should
+be enabled / disabled.
+
+=cut
+
+sub get_frr_daemon_status {
+ my ($fabric_config) = @_;
+
+ return PVE::Network::SDN::Fabrics::get_frr_daemon_status($fabric_config);
+}
+
sub generate_frr_config {
my ($apply) = @_;
my $running_config = PVE::Network::SDN::running_config();
my $fabric_config = PVE::Network::SDN::Fabrics::config(1);
+ my $daemon_status = PVE::Network::SDN::get_frr_daemon_status($fabric_config);
+ my $needs_restart = PVE::Network::SDN::Frr::set_daemon_status($daemon_status, 1);
+
my $raw_config = PVE::Network::SDN::generate_frr_raw_config($running_config, $fabric_config);
PVE::Network::SDN::Frr::write_raw_config($raw_config);
- PVE::Network::SDN::Frr::apply() if $apply;
+ PVE::Network::SDN::Frr::apply($needs_restart) if $apply;
}
sub generate_dhcp_config {
diff --git a/src/PVE/Network/SDN/Fabrics.pm b/src/PVE/Network/SDN/Fabrics.pm
index e5e3428b278e..94f4e97a2f46 100644
--- a/src/PVE/Network/SDN/Fabrics.pm
+++ b/src/PVE/Network/SDN/Fabrics.pm
@@ -44,6 +44,21 @@ sub write_config {
cfs_write_file("sdn/fabrics.cfg", $config->to_raw(), 1);
}
+sub get_frr_daemon_status {
+ my ($fabric_config) = @_;
+
+ my $daemon_status = {};
+ my $nodename = PVE::INotify::nodename();
+
+ my $enabled_daemons = $fabric_config->enabled_daemons($nodename);
+
+ for my $daemon (@$enabled_daemons) {
+ $daemon_status->{$daemon} = 1;
+ }
+
+ return $daemon_status;
+}
+
sub generate_frr_raw_config {
my ($fabric_config) = @_;
diff --git a/src/PVE/Network/SDN/Frr.pm b/src/PVE/Network/SDN/Frr.pm
index 2698928c9b03..62a71e50d9bf 100644
--- a/src/PVE/Network/SDN/Frr.pm
+++ b/src/PVE/Network/SDN/Frr.pm
@@ -109,6 +109,70 @@ sub restart {
run_command(['systemctl', 'restart', 'frr'], errfunc => $err);
}
+my $SDN_DAEMONS_DEFAULT = {
+ ospfd => 0,
+ fabricd => 0,
+};
+
+=head3 set_daemon_status(\%daemons, $set_default)
+
+Sets the status of all daemons supplied in C<\%daemons>. This only works for
+daemons managed by SDN, as indicated in the C<$SDN_DAEMONS_DEFAULT> constant. If
+a daemon is supplied that isn't managed by SDN then this command will fail. If
+C<$set_default> is set, then additionally all sdn-managed daemons that are
+missing in C<\%daemons> are reset to their default value. It returns whether the
+status of any daemons has changed, which indicates that a restart of the daemon
+is required, rather than only a reload.
+
+=cut
+
+sub set_daemon_status {
+ my ($daemon_status, $set_default) = @_;
+
+ my $daemons_file = "/etc/frr/daemons";
+ die "daemons file does not exist" if !-e $daemons_file;
+
+ for my $daemon (keys %$daemon_status) {
+ die "$daemon is not SDN managed" if !defined $SDN_DAEMONS_DEFAULT->{$daemon};
+ }
+
+ if ($set_default) {
+ for my $daemon (keys %$SDN_DAEMONS_DEFAULT) {
+ $daemon_status->{$daemon} = $SDN_DAEMONS_DEFAULT->{$daemon}
+ if !defined($daemon_status->{$daemon});
+ }
+ }
+
+ my $old_config = PVE::Tools::file_get_contents($daemons_file);
+ my $new_config = "";
+
+ my $changed = 0;
+
+ my @lines = split(/\n/, $old_config);
+
+ for my $line (@lines) {
+ if ($line =~ m/^([a-z_]+)=/) {
+ my $key = $1;
+ my $status = $daemon_status->{$key};
+
+ if (defined $status) {
+ my $value = $status ? "yes" : "no";
+ my $new_line = "$key=$value";
+
+ $changed = 1 if $new_line ne $line;
+
+ $line = $new_line;
+ }
+ }
+
+ $new_config .= "$line\n";
+ }
+
+ PVE::Tools::file_set_contents($daemons_file, $new_config);
+
+ return $changed;
+}
+
=head3 to_raw_config(\%frr_config)
Converts a given C<\%frr_config> to the raw config format.
--
2.39.5
_______________________________________________
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-16 13:18 UTC|newest]
Thread overview: 83+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-16 13:07 [pve-devel] [PATCH access-control/cluster/docs/gui-tests/manager/network/proxmox{, -firewall, -ve-rs, -perl-rs, -widget-toolkit} v5 00/76] Add SDN Fabrics Gabriel Goller
2025-07-16 13:07 ` [pve-devel] [PATCH proxmox v5 1/4] network-types: initial commit Gabriel Goller
2025-07-16 13:07 ` [pve-devel] [PATCH proxmox v5 2/4] network-types: make cidr and mac-address types usable by the api Gabriel Goller
2025-07-16 13:07 ` [pve-devel] [PATCH proxmox v5 3/4] network-types: add api types for ipv4/6 Gabriel Goller
2025-07-16 13:07 ` [pve-devel] [PATCH proxmox v5 4/4] network-types: add CIDR overlap detection for IPv4 and IPv6 Gabriel Goller
2025-07-16 13:07 ` [pve-devel] [PATCH proxmox-firewall v5 1/1] firewall: nftables: migrate to proxmox-network-types Gabriel Goller
2025-07-16 13:07 ` [pve-devel] [PATCH proxmox-ve-rs v5 01/22] ve-config: move types " Gabriel Goller
2025-07-16 13:07 ` [pve-devel] [PATCH proxmox-ve-rs v5 02/22] sdn-types: initial commit Gabriel Goller
2025-07-16 13:07 ` [pve-devel] [PATCH proxmox-ve-rs v5 03/22] frr: create proxmox-frr crate Gabriel Goller
2025-07-16 13:07 ` [pve-devel] [PATCH proxmox-ve-rs v5 04/22] frr: add common frr types Gabriel Goller
2025-07-16 13:07 ` [pve-devel] [PATCH proxmox-ve-rs v5 05/22] frr: add openfabric types Gabriel Goller
2025-07-16 13:07 ` [pve-devel] [PATCH proxmox-ve-rs v5 06/22] frr: add ospf types Gabriel Goller
2025-07-16 13:07 ` [pve-devel] [PATCH proxmox-ve-rs v5 07/22] frr: add route-map types Gabriel Goller
2025-07-16 13:07 ` [pve-devel] [PATCH proxmox-ve-rs v5 08/22] frr: add generic types over openfabric and ospf Gabriel Goller
2025-07-16 13:07 ` [pve-devel] [PATCH proxmox-ve-rs v5 09/22] frr: add serializer for all FRR types Gabriel Goller
2025-07-16 13:07 ` [pve-devel] [PATCH proxmox-ve-rs v5 10/22] config: sdn: fabrics: add section types Gabriel Goller
2025-07-16 13:07 ` [pve-devel] [PATCH proxmox-ve-rs v5 11/22] config: sdn: fabrics: add node " Gabriel Goller
2025-07-16 13:07 ` [pve-devel] [PATCH proxmox-ve-rs v5 12/22] config: sdn: fabrics: add interface name struct Gabriel Goller
2025-07-16 13:07 ` [pve-devel] [PATCH proxmox-ve-rs v5 13/22] config: sdn: fabrics: add openfabric properties Gabriel Goller
2025-07-16 13:07 ` [pve-devel] [PATCH proxmox-ve-rs v5 14/22] config: sdn: fabrics: add ospf properties Gabriel Goller
2025-07-16 13:07 ` [pve-devel] [PATCH proxmox-ve-rs v5 15/22] config: sdn: fabrics: add api types Gabriel Goller
2025-07-16 13:07 ` [pve-devel] [PATCH proxmox-ve-rs v5 16/22] config: sdn: fabrics: add section config Gabriel Goller
2025-07-16 13:07 ` [pve-devel] [PATCH proxmox-ve-rs v5 17/22] config: sdn: fabrics: add fabric config Gabriel Goller
2025-07-16 13:07 ` [pve-devel] [PATCH proxmox-ve-rs v5 18/22] common: sdn: fabrics: implement validation Gabriel Goller
2025-07-16 13:07 ` [pve-devel] [PATCH proxmox-ve-rs v5 19/22] sdn: fabrics: config: add conversion from / to section config Gabriel Goller
2025-07-16 13:07 ` [pve-devel] [PATCH proxmox-ve-rs v5 20/22] sdn: fabrics: implement FRR configuration generation Gabriel Goller
2025-07-16 13:07 ` [pve-devel] [PATCH proxmox-ve-rs v5 21/22] ve-config: add integrations tests Gabriel Goller
2025-07-16 13:07 ` [pve-devel] [PATCH proxmox-ve-rs v5 22/22] ve-config: remove serde_plain and serde_with Gabriel Goller
2025-07-16 13:07 ` [pve-devel] [PATCH proxmox-perl-rs v5 1/5] pve-rs: Add PVE::RS::SDN::Fabrics module Gabriel Goller
2025-07-16 13:07 ` [pve-devel] [PATCH proxmox-perl-rs v5 2/5] pve-rs: sdn: fabrics: add api methods Gabriel Goller
2025-07-16 13:07 ` [pve-devel] [PATCH proxmox-perl-rs v5 3/5] pve-rs: sdn: fabrics: add frr config generation Gabriel Goller
2025-07-16 13:07 ` [pve-devel] [PATCH proxmox-perl-rs v5 4/5] pve-rs: sdn: fabrics: add helper to generate ifupdown2 configuration Gabriel Goller
2025-07-16 13:07 ` [pve-devel] [PATCH proxmox-perl-rs v5 5/5] pve-rs: sdn: fabrics: add helper for network API endpoint Gabriel Goller
2025-07-16 13:07 ` [pve-devel] [PATCH pve-cluster v5 1/1] cfs: add fabrics.cfg to observed files Gabriel Goller
2025-07-16 14:02 ` [pve-devel] applied: " Thomas Lamprecht
2025-07-16 14:41 ` [pve-devel] " Thomas Lamprecht
2025-07-16 13:07 ` [pve-devel] [PATCH pve-access-control v5 1/1] permissions: add ACL paths for SDN fabrics Gabriel Goller
2025-07-16 13:07 ` [pve-devel] [PATCH pve-network v5 01/21] sdn: fix value returned by pending_config Gabriel Goller
2025-07-16 13:07 ` [pve-devel] [PATCH pve-network v5 02/21] debian: add dependency to proxmox-perl-rs Gabriel Goller
2025-07-16 13:07 ` [pve-devel] [PATCH pve-network v5 03/21] fabrics: add fabrics module Gabriel Goller
2025-07-16 13:07 ` [pve-devel] [PATCH pve-network v5 04/21] refactor: controller: move frr methods into helper Gabriel Goller
2025-07-16 13:08 ` [pve-devel] [PATCH pve-network v5 05/21] frr: add new helpers for reloading frr configuration Gabriel Goller
2025-07-16 13:08 ` [pve-devel] [PATCH pve-network v5 06/21] controllers: define new api for frr config generation Gabriel Goller
2025-07-16 13:08 ` [pve-devel] [PATCH pve-network v5 07/21] sdn: add frr config generation helpers Gabriel Goller
2025-07-16 13:08 ` [pve-devel] [PATCH pve-network v5 08/21] sdn: api: add check for rewriting frr configuration Gabriel Goller
2025-07-16 13:08 ` [pve-devel] [PATCH pve-network v5 09/21] test: isis: add test for standalone configuration Gabriel Goller
2025-07-16 13:08 ` Gabriel Goller [this message]
2025-07-16 13:08 ` [pve-devel] [PATCH pve-network v5 11/21] sdn: commit fabrics config to running configuration Gabriel Goller
2025-07-16 13:08 ` [pve-devel] [PATCH pve-network v5 12/21] fabrics: generate ifupdown configuration Gabriel Goller
2025-07-16 13:08 ` [pve-devel] [PATCH pve-network v5 13/21] fabrics: add jsonschema for fabrics and nodes Gabriel Goller
2025-07-16 13:08 ` [pve-devel] [PATCH pve-network v5 14/21] api: fabrics: add root-level module Gabriel Goller
2025-07-16 13:08 ` [pve-devel] [PATCH pve-network v5 15/21] api: fabrics: add fabric submodule Gabriel Goller
2025-07-16 13:08 ` [pve-devel] [PATCH pve-network v5 16/21] api: fabrics: add node submodule Gabriel Goller
2025-07-16 13:08 ` [pve-devel] [PATCH pve-network v5 17/21] api: fabrics: add fabricnode submodule Gabriel Goller
2025-07-16 13:08 ` [pve-devel] [PATCH pve-network v5 18/21] controller: evpn: add fabrics integration Gabriel Goller
2025-07-16 13:08 ` [pve-devel] [PATCH pve-network v5 19/21] zone: vxlan: " Gabriel Goller
2025-07-16 13:08 ` [pve-devel] [PATCH pve-network v5 20/21] test: fabrics: add test cases for ospf and openfabric + evpn Gabriel Goller
2025-07-16 13:08 ` [pve-devel] [PATCH pve-network v5 21/21] frr: bump frr config version to 10.3.1 Gabriel Goller
2025-07-16 13:08 ` [pve-devel] [PATCH proxmox-widget-toolkit v5 1/1] network selector: add type parameter Gabriel Goller
2025-07-16 13:08 ` [pve-devel] [PATCH pve-manager v5 01/18] api: use new sdn config generation functions Gabriel Goller
2025-07-16 13:08 ` [pve-devel] [PATCH pve-manager v5 02/18] ui: fabrics: add model definitions for fabrics Gabriel Goller
2025-07-16 13:08 ` [pve-devel] [PATCH pve-manager v5 03/18] fabric: add common interface panel Gabriel Goller
2025-07-16 13:08 ` [pve-devel] [PATCH pve-manager v5 04/18] fabric: add OpenFabric interface properties Gabriel Goller
2025-07-16 13:08 ` [pve-devel] [PATCH pve-manager v5 05/18] fabric: add OSPF " Gabriel Goller
2025-07-16 13:08 ` [pve-devel] [PATCH pve-manager v5 06/18] fabric: add generic node edit panel Gabriel Goller
2025-07-16 13:08 ` [pve-devel] [PATCH pve-manager v5 07/18] fabric: add OpenFabric node edit Gabriel Goller
2025-07-16 13:08 ` [pve-devel] [PATCH pve-manager v5 08/18] fabric: add OSPF " Gabriel Goller
2025-07-16 13:08 ` [pve-devel] [PATCH pve-manager v5 09/18] fabric: add generic fabric edit panel Gabriel Goller
2025-07-16 13:08 ` [pve-devel] [PATCH pve-manager v5 10/18] fabric: add OpenFabric " Gabriel Goller
2025-07-16 13:08 ` [pve-devel] [PATCH pve-manager v5 11/18] fabric: add OSPF " Gabriel Goller
2025-07-16 13:08 ` [pve-devel] [PATCH pve-manager v5 12/18] fabrics: Add main FabricView Gabriel Goller
2025-07-16 13:08 ` [pve-devel] [PATCH pve-manager v5 13/18] utils: avoid line-break in pending changes message Gabriel Goller
2025-07-16 13:08 ` [pve-devel] [PATCH pve-manager v5 14/18] ui: permissions: add ACL path for fabrics Gabriel Goller
2025-07-16 13:08 ` [pve-devel] [PATCH pve-manager v5 15/18] api: network: add include_sdn / fabric type Gabriel Goller
2025-07-16 13:08 ` [pve-devel] [PATCH pve-manager v5 16/18] ui: add sdn networks to ceph / migration Gabriel Goller
2025-07-16 13:08 ` [pve-devel] [PATCH pve-manager v5 17/18] ui: sdn: add evpn controller fabric integration Gabriel Goller
2025-07-16 13:08 ` [pve-devel] [PATCH pve-manager v5 18/18] ui: sdn: vxlan: add fabric property Gabriel Goller
2025-07-16 13:08 ` [pve-devel] [PATCH pve-gui-tests v5 1/1] pve: add sdn/fabrics screenshots Gabriel Goller
2025-07-16 13:08 ` [pve-devel] [PATCH pve-docs v5 1/1] fabrics: add initial documentation for sdn fabrics Gabriel Goller
2025-07-18 7:37 ` Gabriel Goller
2025-07-18 7:51 ` Thomas Lamprecht
2025-07-18 8:09 ` Gabriel Goller
2025-07-17 0:10 ` [pve-devel] applied-series: [PATCH access-control/cluster/docs/gui-tests/manager/network/proxmox{, -firewall, -ve-rs, -perl-rs, -widget-toolkit} v5 00/76] Add SDN Fabrics 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=20250716130837.585796-45-g.goller@proxmox.com \
--to=g.goller@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.