[pve-devel] [PATCH pve-manager v2 1/1] network: improve reloading logic

Stefan Hanreich s.hanreich at proxmox.com
Tue Aug 5 10:35:01 CEST 2025


The old behavior was *always* reloading the network configuration,
which worked as long as FRR was not pre-installed, but the change in
db03d261 coupled with the fact that we now ship with FRR caused FRR to
be enabled on applying the network configuration via the Web UI.

The stop gap fix in e1b9466d solved this behavior, but had the issue
that we need to possibly regenerate the FRR configuration if the host
configuration changes, since some controllers generate their
configuration based on the host network configuration.

pve-network now always sends the regenerate-frr parameter, so we can
discern whether a request came from SDN or is a manual request that is
requesting a specific behavior. With this information the reloading
logic can be improved as follows:

* Honor the parameter if it is set
* reload only if there are any FRR entities in the SDN configuration

This should handle all cases that we need to consider:

* Do not overwrite existing FRR configurations, unless we need to
  generate our own FRR configuration.

* Do not trigger a FRR enable when reloading the host configuration,
  even though there is no FRR configuration.

* Overwrite the FRR configuration with an empty configuration if all
  SDN entities using FRR got deleted.

* Regenerate the FRR configuration when the host network configuration
  changes, since this might affect the generated FRR configuration.

Signed-off-by: Stefan Hanreich <s.hanreich at proxmox.com>
---
 PVE/API2/Network.pm | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/PVE/API2/Network.pm b/PVE/API2/Network.pm
index b423e19b5..7fb7667ee 100644
--- a/PVE/API2/Network.pm
+++ b/PVE/API2/Network.pm
@@ -932,7 +932,14 @@ __PACKAGE__->register_method({
             };
             PVE::Tools::run_command(['ifreload', '-a'], errfunc => $err);
 
-            if ($have_sdn && $regenerate_frr) {
+            if (defined($regenerate_frr)) {
+                # SDN (or a manual invocation) is requesting a
+                # specific behavior, so we abide by the parameter set.
+                PVE::Network::SDN::generate_frr_config(1) if $regenerate_frr;
+            } elsif (PVE::Network::SDN::running_config_has_frr()) {
+                # Reload is coming from the Web UI (or a manual
+                # invocation requesting no specific behavior), so we
+                # reload if there are FRR entities in the SDN config.
                 PVE::Network::SDN::generate_frr_config(1);
             }
         };
-- 
2.47.2




More information about the pve-devel mailing list