From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 1A8C01FF0DA for ; Thu, 19 Nov 2026 20:47:45 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id E9D4D21828; Thu, 19 Nov 2026 20:46:44 +0100 (CET) From: Stefan Hanreich To: pve-devel@lists.proxmox.com Subject: [PATCH pve-manager 12/14] network: apply the conntrack zones of zone VRFs Date: Thu, 19 Nov 2026 20:45:44 +0100 Message-ID: <20261119194547.674512-13-s.hanreich@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261119194547.674512-1-s.hanreich@proxmox.com> References: <20261119194547.674512-1-s.hanreich@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1795117557562 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.226 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: USJ7FCD2IN4JCMK5VFSPF2B6ER6FEN7U X-Message-ID-Hash: USJ7FCD2IN4JCMK5VFSPF2B6ER6FEN7U X-MailFrom: s.hanreich@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 X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Apply the conntrack zones of zone VRFs with 'proxmox-firewall sdn-ct-zones' whenever the network configuration is applied. The command sets them for the interfaces that the kernel reports as enslaved to a zone VRF, so it has to run after ifreload. Failing to apply them only causes a warning, as the network configuration is already applied at that point. At boot, apply them in pve-sdn-commit after the cluster file system is quorate, also if there are no pending changes, as the running config may have changed while the node was offline. Start guests only after that, so their connections are tracked in the right conntrack zone from the start. proxmox-firewall is only recommended, so warn if it is not installed while there are zone VRFs with a conntrack zone. Signed-off-by: Stefan Hanreich --- PVE/API2/Network.pm | 18 ++++++++++++++++++ bin/pve-sdn-commit | 20 ++++++++++++++++++++ services/pve-sdn-commit.service | 2 ++ 3 files changed, 40 insertions(+) diff --git a/PVE/API2/Network.pm b/PVE/API2/Network.pm index 21157877..064fe40a 100644 --- a/PVE/API2/Network.pm +++ b/PVE/API2/Network.pm @@ -26,6 +26,22 @@ eval { my $iflockfn = "/etc/network/.pve-interfaces.lock"; +my $proxmox_firewall = '/usr/libexec/proxmox/proxmox-firewall'; + +# the conntrack zones are set for the interfaces that the kernel reports as enslaved to a zone VRF, +# so this needs to run after ifreload +my sub apply_vrf_ct_zones { + if (!-x $proxmox_firewall) { + my $zones = PVE::Network::SDN::running_config()->{zones}->{ids} // {}; + warn "proxmox-firewall is not installed, connections are not isolated between zone VRFs\n" + if grep { defined($_->{'ct-zone'}) } values $zones->%*; + return; + } + + eval { PVE::Tools::run_command([$proxmox_firewall, 'sdn-ct-zones']) }; + warn "failed to apply the conntrack zones of zone VRFs - $@" if $@; +} + my $bond_mode_enum = [ 'balance-rr', 'active-backup', # OVS and Linux @@ -969,6 +985,8 @@ __PACKAGE__->register_method({ }; PVE::Tools::run_command(['ifreload', '-a'], errfunc => $err); + apply_vrf_ct_zones() if $have_sdn; + # needs the zone VRFs created by ifreload, because dnsmasq is started inside # them with 'ip vrf exec' PVE::Network::SDN::generate_dhcp_config() if $have_sdn; diff --git a/bin/pve-sdn-commit b/bin/pve-sdn-commit index ab4175b8..57c2feba 100644 --- a/bin/pve-sdn-commit +++ b/bin/pve-sdn-commit @@ -22,6 +22,23 @@ for (my $i = 0; !PVE::Cluster::check_cfs_quorum(1); $i++) { usleep(100 * 1000); } +my $proxmox_firewall = '/usr/libexec/proxmox/proxmox-firewall'; + +# The conntrack zones are set for the interfaces that the kernel reports as enslaved to a zone VRF, +# so this needs to run after ifreload. The running config may have changed while the node was +# offline, so apply them even without pending changes. +sub apply_vrf_ct_zones { + if (!-x $proxmox_firewall) { + my $zones = PVE::Network::SDN::running_config()->{zones}->{ids} // {}; + warn "proxmox-firewall is not installed, connections are not isolated between zone VRFs\n" + if grep { defined($_->{'ct-zone'}) } values $zones->%*; + return; + } + + eval { PVE::Tools::run_command([$proxmox_firewall, 'sdn-ct-zones']) }; + warn "failed to apply the conntrack zones of zone VRFs - $@" if $@; +} + sub has_pending_changes { my ($pending_config) = @_; @@ -98,6 +115,7 @@ sub sdn_changed { if (!sdn_changed()) { print "No changes to SDN configuration detected, skipping reload\n"; + apply_vrf_ct_zones(); exit 0; } @@ -118,6 +136,8 @@ my $err = sub { PVE::Tools::run_command(['ifreload', '-a'], errfunc => $err); +apply_vrf_ct_zones(); + # needs the zone VRFs created by ifreload, because dnsmasq is started inside # them with 'ip vrf exec' PVE::Network::SDN::generate_dhcp_config(); diff --git a/services/pve-sdn-commit.service b/services/pve-sdn-commit.service index ff723725..2dfe7872 100644 --- a/services/pve-sdn-commit.service +++ b/services/pve-sdn-commit.service @@ -3,6 +3,8 @@ Description=Commit Proxmox VE SDN changes DefaultDependencies=no Wants=pve-cluster.service network.target After=frr.service network.target corosync.service +# guests must only start once the zone VRFs have their conntrack zones +Before=pve-guests.service [Service] ExecStart=/usr/share/pve-manager/helpers/pve-sdn-commit -- 2.47.3