public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Gabriel Goller <g.goller@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH pve-network v2 06/19] controllers: implement new api for frr config generation
Date: Fri,  4 Apr 2025 18:28:42 +0200	[thread overview]
Message-ID: <20250404162908.563060-32-g.goller@proxmox.com> (raw)
In-Reply-To: <20250404162908.563060-1-g.goller@proxmox.com>

From: Stefan Hanreich <s.hanreich@proxmox.com>

With the changes to how we handle the frr config generation,
controllers are now no longer responsible for generating the FRR
configuration. Instead, we pass the existing frr_config perl hash to
every controller, where controllers append their respective
configuration.

This requires a few changes in the controller API, so that they now
append to a passed perl hash, instead of directly writing their own
configuration which is now handled externally by the SDN module.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
Co-authored-by: Gabriel Goller <g.goller@proxmox.com>
Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
 src/PVE/Network/SDN/Controllers.pm            | 67 +++----------------
 src/PVE/Network/SDN/Controllers/BgpPlugin.pm  | 21 +-----
 src/PVE/Network/SDN/Controllers/EvpnPlugin.pm |  6 +-
 src/PVE/Network/SDN/Controllers/IsisPlugin.pm | 21 +-----
 src/PVE/Network/SDN/Controllers/Plugin.pm     | 31 +--------
 5 files changed, 19 insertions(+), 127 deletions(-)

diff --git a/src/PVE/Network/SDN/Controllers.pm b/src/PVE/Network/SDN/Controllers.pm
index 9e8f3aa12a89..788bfccd3aff 100644
--- a/src/PVE/Network/SDN/Controllers.pm
+++ b/src/PVE/Network/SDN/Controllers.pm
@@ -79,12 +79,12 @@ sub read_etc_network_interfaces {
     return $interfaces_config;
 }
 
-sub generate_controller_config {
+sub generate_frr_config {
+    my ($frr_config, $sdn_config) = @_;
 
-    my $cfg = PVE::Network::SDN::running_config();
-    my $vnet_cfg = $cfg->{vnets};
-    my $zone_cfg = $cfg->{zones};
-    my $controller_cfg = $cfg->{controllers};
+    my $vnet_cfg = $sdn_config->{vnets};
+    my $zone_cfg = $sdn_config->{zones};
+    my $controller_cfg = $sdn_config->{controllers};
 
     return if !$vnet_cfg && !$zone_cfg && !$controller_cfg;
 
@@ -101,13 +101,10 @@ sub generate_controller_config {
 	}
     }
 
-    # generate configuration
-    my $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_controller_config($plugin_config, $controller_cfg, $id, $uplinks, $config);
+	$plugin->generate_frr_config($plugin_config, $controller_cfg, $id, $uplinks, $frr_config);
     }
 
     foreach my $id (sort keys %{$zone_cfg->{ids}}) {
@@ -117,7 +114,7 @@ sub generate_controller_config {
 	my $controller = $controller_cfg->{ids}->{$controllerid};
 	if ($controller) {
 	    my $controller_plugin = PVE::Network::SDN::Controllers::Plugin->lookup($controller->{type});
-	    $controller_plugin->generate_controller_zone_config($plugin_config, $controller, $controller_cfg, $id, $uplinks, $config);
+	    $controller_plugin->generate_zone_frr_config($plugin_config, $controller, $controller_cfg, $id, $uplinks, $frr_config);
 	}
     }
 
@@ -132,57 +129,11 @@ sub generate_controller_config {
 	my $controller = $controller_cfg->{ids}->{$controllerid};
 	if ($controller) {
 	    my $controller_plugin = PVE::Network::SDN::Controllers::Plugin->lookup($controller->{type});
-	    $controller_plugin->generate_controller_vnet_config($plugin_config, $controller, $zone, $zoneid, $id, $config);
+	    $controller_plugin->generate_vnet_frr_config($plugin_config, $controller, $zone, $zoneid, $id, $frr_config);
 	}
     }
 
-    return $config;
-}
-
-
-sub reload_controller {
-
-    my $cfg = PVE::Network::SDN::running_config();
-    my $controller_cfg = $cfg->{controllers};
-
-    return if !$controller_cfg;
-
-    foreach my $id (keys %{$controller_cfg->{ids}}) {
-	my $plugin_config = $controller_cfg->{ids}->{$id};
-	my $plugin = PVE::Network::SDN::Controllers::Plugin->lookup($plugin_config->{type});
-	$plugin->reload_controller();
-    }
-}
-
-sub generate_controller_rawconfig {
-    my ($config) = @_;
-
-    my $cfg = PVE::Network::SDN::running_config();
-    my $controller_cfg = $cfg->{controllers};
-    return if !$controller_cfg;
-
-    my $rawconfig = "";
-    foreach my $id (keys %{$controller_cfg->{ids}}) {
-	my $plugin_config = $controller_cfg->{ids}->{$id};
-	my $plugin = PVE::Network::SDN::Controllers::Plugin->lookup($plugin_config->{type});
-	$rawconfig .= $plugin->generate_controller_rawconfig($plugin_config, $config);
-    }
-    return $rawconfig;
-}
-
-sub write_controller_config {
-    my ($config) = @_;
-
-    my $cfg = PVE::Network::SDN::running_config();
-    my $controller_cfg = $cfg->{controllers};
-    return if !$controller_cfg;
-
-    foreach my $id (keys %{$controller_cfg->{ids}}) {
-	my $plugin_config = $controller_cfg->{ids}->{$id};
-	my $plugin = PVE::Network::SDN::Controllers::Plugin->lookup($plugin_config->{type});
-	$plugin->write_controller_config($plugin_config, $config);
-    }
+    return $frr_config;
 }
 
 1;
-
diff --git a/src/PVE/Network/SDN/Controllers/BgpPlugin.pm b/src/PVE/Network/SDN/Controllers/BgpPlugin.pm
index 53963e5ad7f4..3b21cada2d8d 100644
--- a/src/PVE/Network/SDN/Controllers/BgpPlugin.pm
+++ b/src/PVE/Network/SDN/Controllers/BgpPlugin.pm
@@ -53,7 +53,7 @@ sub options {
 }
 
 # Plugin implementation
-sub generate_controller_config {
+sub generate_frr_config {
     my ($class, $plugin_config, $controller, $id, $uplinks, $config) = @_;
 
     my @peers;
@@ -132,7 +132,7 @@ sub generate_controller_config {
     return $config;
 }
 
-sub generate_controller_zone_config {
+sub generate_zone_frr_config {
     my ($class, $plugin_config, $controller, $controller_cfg, $id, $uplinks, $config) = @_;
 
 }
@@ -164,21 +164,4 @@ sub on_update_hook {
     }
 }
 
-sub generate_controller_rawconfig {
-    my ($class, $plugin_config, $config) = @_;
-    return "";
-}
-
-sub write_controller_config {
-    my ($class, $plugin_config, $config) = @_;
-    return;
-}
-
-sub reload_controller {
-    my ($class) = @_;
-    return;
-}
-
 1;
-
-
diff --git a/src/PVE/Network/SDN/Controllers/EvpnPlugin.pm b/src/PVE/Network/SDN/Controllers/EvpnPlugin.pm
index f9241a097798..bde331fb12c4 100644
--- a/src/PVE/Network/SDN/Controllers/EvpnPlugin.pm
+++ b/src/PVE/Network/SDN/Controllers/EvpnPlugin.pm
@@ -41,7 +41,7 @@ sub options {
 }
 
 # Plugin implementation
-sub generate_controller_config {
+sub generate_frr_config {
     my ($class, $plugin_config, $controller_cfg, $id, $uplinks, $config) = @_;
 
     my @peers;
@@ -119,7 +119,7 @@ sub generate_controller_config {
     return $config;
 }
 
-sub generate_controller_zone_config {
+sub generate_zone_frr_config {
     my ($class, $plugin_config, $controller, $controller_cfg, $id, $uplinks, $config) = @_;
 
     my $local_node = PVE::INotify::nodename();
@@ -279,7 +279,7 @@ sub generate_controller_zone_config {
     return $config;
 }
 
-sub generate_controller_vnet_config {
+sub generate_vnet_frr_config {
     my ($class, $plugin_config, $controller, $zone, $zoneid, $vnetid, $config) = @_;
 
     my $exitnodes = $zone->{'exitnodes'};
diff --git a/src/PVE/Network/SDN/Controllers/IsisPlugin.pm b/src/PVE/Network/SDN/Controllers/IsisPlugin.pm
index 97c6876db303..ace19aa7ffdc 100644
--- a/src/PVE/Network/SDN/Controllers/IsisPlugin.pm
+++ b/src/PVE/Network/SDN/Controllers/IsisPlugin.pm
@@ -55,7 +55,7 @@ sub options {
 }
 
 # Plugin implementation
-sub generate_controller_config {
+sub generate_frr_config {
     my ($class, $plugin_config, $controller, $id, $uplinks, $config) = @_;
 
     my $isis_ifaces = $plugin_config->{'isis-ifaces'};
@@ -87,7 +87,7 @@ sub generate_controller_config {
     return $config;
 }
 
-sub generate_controller_zone_config {
+sub generate_zone_frr_config {
     my ($class, $plugin_config, $controller, $controller_cfg, $id, $uplinks, $config) = @_;
 
 }
@@ -113,21 +113,4 @@ sub on_update_hook {
     }
 }
 
-sub generate_controller_rawconfig {
-    my ($class, $plugin_config, $config) = @_;
-    return "";
-}
-
-sub write_controller_config {
-    my ($class, $plugin_config, $config) = @_;
-    return;
-}
-
-sub reload_controller {
-    my ($class) = @_;
-    return;
-}
-
 1;
-
-
diff --git a/src/PVE/Network/SDN/Controllers/Plugin.pm b/src/PVE/Network/SDN/Controllers/Plugin.pm
index d6ffc5f35c74..26beff3370a8 100644
--- a/src/PVE/Network/SDN/Controllers/Plugin.pm
+++ b/src/PVE/Network/SDN/Controllers/Plugin.pm
@@ -63,48 +63,23 @@ sub parse_section_header {
     return undef;
 }
 
-sub generate_sdn_config {
-    my ($class, $plugin_config, $node, $data, $ctime) = @_;
-
-    die "please implement inside plugin";
-}
-
-sub generate_controller_config {
+sub generate_frr_config {
     my ($class, $plugin_config, $controller_cfg, $id, $uplinks, $config) = @_;
 
     die "please implement inside plugin";
 }
 
-
-sub generate_controller_zone_config {
+sub generate_zone_frr_config {
     my ($class, $plugin_config, $controller, $controller_cfg, $id, $uplinks, $config) = @_;
 
     die "please implement inside plugin";
 }
 
-sub generate_controller_vnet_config {
+sub generate_vnet_frr_config {
     my ($class, $plugin_config, $controller, $zoneid, $vnetid, $config) = @_;
 
 }
 
-sub generate_controller_rawconfig {
-    my ($class, $plugin_config, $config) = @_;
-
-    die "please implement inside plugin";
-}
-
-sub write_controller_config {
-    my ($class, $plugin_config, $config) = @_;
-
-    die "please implement inside plugin";
-}
-
-sub controller_reload {
-    my ($class) = @_;
-
-    die "please implement inside plugin";
-}
-
 sub on_delete_hook {
     my ($class, $controllerid, $zone_cfg) = @_;
 
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


  parent reply	other threads:[~2025-04-04 16:39 UTC|newest]

Thread overview: 76+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-04 16:28 [pve-devel] [PATCH access-control/cluster/docs/gui-tests/manager/network/proxmox{, -ve-rs, -perl-rs} v2 00/57] Add SDN Fabrics Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH proxmox v2 1/1] serde: add string_as_bool module for boolean string parsing Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH proxmox-ve-rs v2 01/15] sdn-types: initial commit Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH proxmox-ve-rs v2 02/15] frr: create proxmox-frr crate Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH proxmox-ve-rs v2 03/15] frr: add common frr types Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH proxmox-ve-rs v2 04/15] frr: add openfabric types Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH proxmox-ve-rs v2 05/15] frr: add ospf types Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH proxmox-ve-rs v2 06/15] frr: add route-map types Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH proxmox-ve-rs v2 07/15] frr: add generic types over openfabric and ospf Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH proxmox-ve-rs v2 08/15] frr: add serializer for all FRR types Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH proxmox-ve-rs v2 09/15] ve-config: add common section-config types for OpenFabric and OSPF Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH proxmox-ve-rs v2 10/15] ve-config: add openfabric section-config Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH proxmox-ve-rs v2 11/15] ve-config: add ospf section-config Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH proxmox-ve-rs v2 12/15] ve-config: add FRR conversion helpers for openfabric and ospf Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH proxmox-ve-rs v2 13/15] ve-config: add validation for section-config Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH proxmox-ve-rs v2 14/15] ve-config: add section-config to frr types conversion Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH proxmox-ve-rs v2 15/15] ve-config: add integrations tests Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH proxmox-perl-rs v2 1/7] perl-rs: sdn: initial fabric infrastructure Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH proxmox-perl-rs v2 2/7] perl-rs: sdn: add CRUD helpers for OpenFabric fabric management Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH proxmox-perl-rs v2 3/7] perl-rs: sdn: OpenFabric perlmod methods Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH proxmox-perl-rs v2 4/7] perl-rs: sdn: implement Openfabric interface file generation Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH proxmox-perl-rs v2 5/7] perl-rs: sdn: add CRUD helpers for OSPF fabric management Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH proxmox-perl-rs v2 6/7] perl-rs: sdn: OSPF perlmod methods Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH proxmox-perl-rs v2 7/7] perl-rs: sdn: implement OSPF interface file configuration generation Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH pve-cluster v2 1/1] cluster: add sdn fabrics config files Gabriel Goller
2025-04-04 17:03   ` [pve-devel] applied: " Thomas Lamprecht
2025-04-04 16:28 ` [pve-devel] [PATCH pve-access-control v2 1/1] permissions: add ACL paths for SDN fabrics Gabriel Goller
2025-04-04 17:20   ` Thomas Lamprecht
2025-04-07  7:24     ` Fabian Grünbichler
2025-04-07  8:12       ` Thomas Lamprecht
2025-04-07  8:51         ` Stefan Hanreich
2025-04-07  9:27           ` Fabian Grünbichler
2025-04-07  9:44             ` Stefan Hanreich
2025-04-11 11:12             ` Stefan Hanreich
2025-04-11 11:14               ` Stefan Hanreich
2025-04-11 16:51               ` Stefan Hanreich
2025-04-07  9:34           ` Thomas Lamprecht
2025-04-07 10:08             ` Stefan Hanreich
2025-04-07 10:12               ` Thomas Lamprecht
2025-04-07 11:41                 ` Gilberto Ferreira via pve-devel
     [not found]                 ` <CAOKSTBsu8vrw8_nSu_LozwNwTc+ReTb6TEg3K_iM8uYh9oRRFg@mail.gmail.com>
2025-04-07 11:59                   ` Stefan Hanreich
2025-04-07 12:22                     ` Gilberto Ferreira via pve-devel
2025-04-04 16:28 ` [pve-devel] [PATCH pve-network v2 01/19] sdn: fix value returned by pending_config Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH pve-network v2 02/19] debian: add dependency to proxmox-perl-rs Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH pve-network v2 03/19] fabrics: add fabrics module Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH pve-network v2 04/19] refactor: controller: move frr methods into helper Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH pve-network v2 05/19] frr: add new helpers for reloading frr configuration Gabriel Goller
2025-04-04 16:28 ` Gabriel Goller [this message]
2025-04-04 16:28 ` [pve-devel] [PATCH pve-network v2 07/19] sdn: add frr config generation helper Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH pve-network v2 08/19] test: isis: add test for standalone configuration Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH pve-network v2 09/19] sdn: frr: add daemon status to frr helper Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH pve-network v2 10/19] sdn: commit fabrics config to running configuration Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH pve-network v2 11/19] fabrics: generate ifupdown configuration Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH pve-network v2 12/19] api: fabrics: add common helpers Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH pve-network v2 13/19] api: openfabric: add api endpoints Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH pve-network v2 14/19] api: openfabric: add node endpoints Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH pve-network v2 15/19] api: ospf: add fabric endpoints Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH pve-network v2 16/19] api: ospf: add node endpoints Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH pve-network v2 17/19] api: fabrics: add module / subfolder Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH pve-network v2 18/19] test: fabrics: add test cases for ospf and openfabric + evpn Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH pve-network v2 19/19] frr: bump frr config version to 10.2.1 Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH pve-manager v2 01/11] api: use new generalized frr and etc network config helper functions Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH pve-manager v2 02/11] fabric: add common interface panel Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH pve-manager v2 03/11] fabric: add OpenFabric interface properties Gabriel Goller
2025-04-04 16:28 ` [pve-devel] [PATCH pve-manager v2 04/11] fabric: add OSPF " Gabriel Goller
2025-04-04 16:29 ` [pve-devel] [PATCH pve-manager v2 05/11] fabric: add generic node edit panel Gabriel Goller
2025-04-04 16:29 ` [pve-devel] [PATCH pve-manager v2 06/11] fabric: add generic fabric " Gabriel Goller
2025-04-04 16:29 ` [pve-devel] [PATCH pve-manager v2 07/11] fabric: add OpenFabric " Gabriel Goller
2025-04-04 16:29 ` [pve-devel] [PATCH pve-manager v2 08/11] fabric: add OSPF " Gabriel Goller
2025-04-04 16:29 ` [pve-devel] [PATCH pve-manager v2 09/11] fabrics: Add main FabricView Gabriel Goller
2025-04-04 16:29 ` [pve-devel] [PATCH pve-manager v2 10/11] utils: avoid line-break in pending changes message Gabriel Goller
2025-04-04 16:29 ` [pve-devel] [PATCH pve-manager v2 11/11] ui: permissions: add ACL paths for fabrics Gabriel Goller
2025-04-04 16:29 ` [pve-devel] [PATCH pve-gui-tests v2 1/1] pve: add sdn/fabrics screenshots Gabriel Goller
2025-04-04 16:29 ` [pve-devel] [PATCH pve-docs v2 1/1] fabrics: add initial documentation for sdn fabrics Gabriel Goller
2025-04-07  8:53 ` [pve-devel] [PATCH access-control/cluster/docs/gui-tests/manager/network/proxmox{, -ve-rs, -perl-rs} v2 00/57] Add SDN Fabrics Friedrich Weber
2025-04-07  9:39   ` Stefan Hanreich

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=20250404162908.563060-32-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal