public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Lukas Sichert <l.sichert@proxmox.com>
To: pve-devel@lists.proxmox.com
Cc: Lukas Sichert <l.sichert@proxmox.com>
Subject: [PATCH manager v3 7/7] fix #5066: network: activate prepared SDN SNAT rules
Date: Thu, 26 Nov 2026 16:29:05 +0100	[thread overview]
Message-ID: <20261126153925.54600-8-l.sichert@proxmox.com> (raw)
In-Reply-To: <20261126153925.54600-1-l.sichert@proxmox.com>

After reloading the network configuration, activate the SNAT rules
prepared by the generated post-up hooks by replacing the active
PROXMOX-SDN chain with PROXMOX-SDN-NEW. Skip this if the reload failed,
as the post-up hooks may not have prepared the new chain then, and the
active chain keeps working.

During boot, networking.service executes the same post-up hooks without
going through the network reload API. In that case pve-sdn-commit may
find no pending SDN changes and exit early. Activate the prepared chain
before that early exit as well.

Signed-off-by: Lukas Sichert <l.sichert@proxmox.com>
Link: https://bugzilla.proxmox.com/show_bug.cgi?id=5066
---

Notes:
    changes v2 -> v3:
    - rebased on top of master
    - replaces "flush PROXMOX-SDN iptables chain at reload": activate the
      prepared chain after ifreload instead of flushing before it
    - also activate it from pve-sdn-commit when no changes are pending
    
    changes v1 -> v2:
    - rebased on top of master

 PVE/API2/Network.pm | 1 +
 bin/pve-sdn-commit  | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/PVE/API2/Network.pm b/PVE/API2/Network.pm
index bff98791..b3f477f4 100644
--- a/PVE/API2/Network.pm
+++ b/PVE/API2/Network.pm
@@ -1019,6 +1019,7 @@ __PACKAGE__->register_method({
             my $ifreload_err = $@;
 
             if ($have_sdn) {
+                PVE::Network::SDN::Zones::apply_new_snat_rules() if !$ifreload_err;
                 apply_vrf_ct_zones();
                 eval { warn_vrf_zones_with_legacy_firewall() };
                 warn $@ if $@;
diff --git a/bin/pve-sdn-commit b/bin/pve-sdn-commit
index 30d10689..fc1b3ff3 100644
--- a/bin/pve-sdn-commit
+++ b/bin/pve-sdn-commit
@@ -117,6 +117,11 @@ sub sdn_changed {
 }
 
 if (!sdn_changed()) {
+    # At boot, networking.service executes the generated post-up hooks and
+    # populates PROXMOX-SDN-NEW. Activate the prepared chain even when there
+    # are no pending SDN changes.
+    PVE::Network::SDN::Zones::apply_new_snat_rules();
+
     print "No changes to SDN configuration detected, skipping reload\n";
     apply_vrf_ct_zones();
     exit 0;
@@ -146,6 +151,7 @@ my $err = sub {
 eval { PVE::Tools::run_command(['ifreload', '-a'], errfunc => $err) };
 my $ifreload_err = $@;
 
+PVE::Network::SDN::Zones::apply_new_snat_rules() if !$ifreload_err;
 apply_vrf_ct_zones();
 
 # needs the zone VRFs created by ifreload, because dnsmasq is started inside
-- 
2.47.3





      parent reply	other threads:[~2026-11-26 15:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26 15:28 [PATCH manager/network v3 0/7] fix #5066: make generated snat rules flushable Lukas Sichert
2026-11-26 15:28 ` [PATCH network v3 1/7] style: zones: use fully qualified JSONSchema calls for standard options Lukas Sichert
2026-11-26 15:29 ` [PATCH network v3 2/7] fix #5066: zones: factor out SNAT rule generation Lukas Sichert
2026-11-26 15:29 ` [PATCH network v3 3/7] fix #5066: zones: add helper to activate prepared SNAT rules Lukas Sichert
2026-11-26 15:29 ` [PATCH network v3 4/7] fix #5066: evpn: prepare SNAT rules in temporary chain Lukas Sichert
2026-11-26 15:29 ` [PATCH network v3 5/7] fix #5066: simple zone: " Lukas Sichert
2026-11-26 15:29 ` [PATCH network v3 6/7] fix #5066: zones: add test for generating and applying SNAT rules Lukas Sichert
2026-11-26 15:29 ` Lukas Sichert [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=20261126153925.54600-8-l.sichert@proxmox.com \
    --to=l.sichert@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