From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <pve-devel-bounces@lists.proxmox.com> Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id CD9011FF16F for <inbox@lore.proxmox.com>; Thu, 13 Feb 2025 11:10:07 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 1B9612F77B; Thu, 13 Feb 2025 11:10:03 +0100 (CET) Date: Thu, 13 Feb 2025 11:09:29 +0100 From: Gabriel Goller <g.goller@proxmox.com> To: Stefan Hanreich <s.hanreich@proxmox.com> Message-ID: <xnmnu4jaztd2eroz7edyx36z3rjbpz75irzhwwkwixrexwqmc5@vyffklel42dp> References: <20250205161340.740740-1-g.goller@proxmox.com> <ebe83020-28b3-4e02-a3d1-4de9e76ebf8e@proxmox.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <ebe83020-28b3-4e02-a3d1-4de9e76ebf8e@proxmox.com> User-Agent: NeoMutt/20241002-35-39f9a6 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.032 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_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 Subject: Re: [pve-devel] [PATCH network] sdn: factor out frr config generation and writing X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com> List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe> List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/> List-Post: <mailto:pve-devel@lists.proxmox.com> List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help> List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe> Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com> Cc: Proxmox VE development discussion <pve-devel@lists.proxmox.com> Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com> On 12.02.2025 12:17, Stefan Hanreich wrote: >This still has some issues (see below), maybe we can look at it together >next week (will be gone after today) and see if we can make some >additional structural improvements to the whole controller / frr logic? >There were also some regressions/bugs with FRR config generation while >testing, so this series needs some work still. We checked this together offliste, the patch doesn't change the output, so no regressions. >On 2/5/25 17:13, Gabriel Goller wrote: >> diff --git a/src/PVE/Network/SDN/Controllers.pm b/src/PVE/Network/SDN/Controllers.pm >> index fd7ad54ac38c..43f154b7338e 100644 >> --- a/src/PVE/Network/SDN/Controllers.pm >> +++ b/src/PVE/Network/SDN/Controllers.pm >> @@ -148,10 +149,22 @@ sub reload_controller { >> >> return if !$controller_cfg; >> >> + my $frr_reload = 0; >> + >> 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(); >> + my $type = $plugin_config->{type}; >> + my @frr_types = ("bgp", "isis", "evpn"); >> + if (grep {$type} @frr_types) { > >this doesn't work. you need: > > grep {$_ eq $type} @frr_types > >(or what thomas said is even better - just for future reference) Yup, my bad, will fix this. >> + $frr_reload = 1; >> + } else { >> + my $plugin = PVE::Network::SDN::Controllers::Plugin->lookup($type); >> + $plugin->reload_controller(); >> + } >> + } >> + >> + if ($frr_reload) { >> + PVE::Network::SDN::Controllers::Frr::reload_controller(); >> } >> } >> >> @@ -161,12 +174,22 @@ sub generate_controller_rawconfig { > >This actually never gets called (except in the tests, ..). It works, but >still takes the old code path without going through the new FRR helper. >Probably not the intention? Yep, this function is only really called in the unit tests. With the usual flow, we call write_controller_config, which resolves the plugin and calls this function on the each plugin. We could call the generate_controller_rawconfig function here though: src/PVE/Network/SDN/Controllers.pm:212. So instead of getting the plugin and calling the rawconfig implementations in write_controller_config, just use this function. >> my $cfg = PVE::Network::SDN::running_config(); >> my $controller_cfg = $cfg->{controllers}; >> return if !$controller_cfg; >> + my $frr_generate = 0; >> >> 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); >> + my $type = $plugin_config->{type}; >> + my @frr_types = ("bgp", "isis", "evpn"); >> + if (grep {$type} @frr_types) { >> @@ -323,6 +323,21 @@ sub vnet_update_hook { >> } >> } >> >> +sub reload_controller { >> + my ($class) = @_; >> + die "implemented in the Frr helper"; >> +} >> + >> +sub generate_controller_rawconfig { >> + my ($class, $config) = @_; >> + die "implemented in the Frr helper"; >> +} >> + >> +sub write_controller_config { >> + my ($class, $config) = @_; >> + die "implemented in the Frr helper"; >> +} >> + >> 1; > >Those methods are only needed in the Controllers, not Zones - they serve >no purpose here afaict? Yep, true, didn't check the directory I was in (zone vs controller) :) Thanks for the review! _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel