From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 9206C1FF0B3 for ; Thu, 26 Nov 2026 16:40:28 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id C57A421804; Thu, 26 Nov 2026 16:39:42 +0100 (CET) From: Lukas Sichert To: pve-devel@lists.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 Message-ID: <20261126153925.54600-8-l.sichert@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261126153925.54600-1-l.sichert@proxmox.com> References: <20261126153925.54600-1-l.sichert@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1795707578025 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.412 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: NHG46DSJA52IMRTSWZN7JOWUZWUE4EJM X-Message-ID-Hash: NHG46DSJA52IMRTSWZN7JOWUZWUE4EJM X-MailFrom: l.sichert@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Lukas Sichert X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 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