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 304521FF0B3 for ; Thu, 26 Nov 2026 16:39:58 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 695822175C; Thu, 26 Nov 2026 16:39:41 +0100 (CET) From: Lukas Sichert To: pve-devel@lists.proxmox.com Subject: [PATCH manager/network v3 0/7] fix #5066: make generated snat rules flushable Date: Thu, 26 Nov 2026 16:28:58 +0100 Message-ID: <20261126153925.54600-1-l.sichert@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1795707574090 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.434 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: 743HQR2VLP2BSZGFUN77ZYSMQZJP4RDQ X-Message-ID-Hash: 743HQR2VLP2BSZGFUN77ZYSMQZJP4RDQ 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: Disabling SNAT for an existing subnet can leave its iptables rule active. This happens because 'ifreload -a' does not execute down hooks when reloading an existing interface [1]. Move generated Simple (including dedicated VRF) and EVPN SNAT rules from POSTROUTING into a dedicated chain. Post-up hooks prepare the complete new ruleset in PROXMOX-SDN-NEW while the existing PROXMOX-SDN chain remains active. After ifreload, replace the old chain with the prepared one. This removes stale rules without affecting unrelated POSTROUTING rules or leaving a window during which SNAT does not work. At boot, networking.service prepares the temporary chain directly with the post-up commands in /etc/network/interfaces.d/sdn. Therefore, also activate it from pve-sdn-commit when no SDN changes are pending. Maintainer Note: This series requires a version bump of pve-network and a dependency bump on it in pve-manager, as that calls the new apply_new_snat_rules(). Notes: - Rules generated by an older version sit directly in POSTROUTING and cannot be told apart from user-set rules, so they are not flushed with the new chain and are only gone after a reboot. - A manual ifreload populates PROXMOX-SDN-NEW without switching it over. This may leave stale rules, which are cleaned up with the next SDN apply or reboot. [1] https://manpages.debian.org/testing/ifupdown2/ifreload.8.en.html Link: https://bugzilla.proxmox.com/show_bug.cgi?id=5066 changes from v2 to v3 (thanks @Stefan): - prepare rules in a temporary chain before replacing the active chain, avoiding an interruption of SNAT - share SNAT rule generation between Simple and EVPN zones - activate rules generated during boot - also handle zones with a dedicated VRF, which masquerade on their uplinks changes from v1 to v2 (thanks @Stefan): - rebase on top of master - create chain only when '$is_evpn_gateway' is true - add Links to commits network: Lukas Sichert (6): style: zones: use fully qualified JSONSchema calls for standard options fix #5066: zones: factor out SNAT rule generation fix #5066: zones: add helper to activate prepared SNAT rules fix #5066: evpn: prepare SNAT rules in temporary chain fix #5066: simple zone: prepare SNAT rules in temporary chain fix #5066: zones: add test for generating and applying SNAT rules src/PVE/Network/SDN/Zones.pm | 39 +++- src/PVE/Network/SDN/Zones/EvpnPlugin.pm | 31 +-- src/PVE/Network/SDN/Zones/Plugin.pm | 58 ++++- src/PVE/Network/SDN/Zones/SimplePlugin.pm | 44 +--- src/test/Makefile | 5 +- src/test/run_test_apply_snat.pl | 209 ++++++++++++++++++ .../exitnode_snat/expected_sdn_interfaces | 16 +- .../simple/ipv4snat/expected_sdn_interfaces | 8 +- .../simple/ipv6snat/expected_sdn_interfaces | 8 +- .../simple/vrf_snat/expected_sdn_interfaces | 35 ++- 10 files changed, 348 insertions(+), 105 deletions(-) create mode 100755 src/test/run_test_apply_snat.pl manager: Lukas Sichert (1): fix #5066: network: activate prepared SDN SNAT rules PVE/API2/Network.pm | 1 + bin/pve-sdn-commit | 6 ++++++ 2 files changed, 7 insertions(+) Summary over all repositories: 12 files changed, 355 insertions(+), 105 deletions(-) -- Generated by murpp 0.12.0