From: Stefan Hanreich <s.hanreich@proxmox.com>
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 [thread overview]
Message-ID: <20261119194547.674512-13-s.hanreich@proxmox.com> (raw)
In-Reply-To: <20261119194547.674512-1-s.hanreich@proxmox.com>
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 <s.hanreich@proxmox.com>
---
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
next prev parent reply other threads:[~2026-11-19 19:47 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 19:45 [PATCH docs/manager/network/proxmox{,-ve-rs,-firewall} 00/14] sdn: conntrack zones and SNAT for simple zones with a dedicated VRF Stefan Hanreich
2026-11-19 19:45 ` [PATCH proxmox 01/14] network-api: expose the master device of a link Stefan Hanreich
2026-11-19 19:45 ` [PATCH proxmox-ve-rs 02/14] sdn: config: read the conntrack zone of zones with a dedicated VRF Stefan Hanreich
2026-11-19 19:45 ` [PATCH proxmox-ve-rs 03/14] sdn: conntrack: map the interfaces of zone VRFs to their conntrack zone Stefan Hanreich
2026-11-19 19:45 ` [PATCH pve-network 04/14] sdn: simple: SNAT via the uplinks of zone VRFs Stefan Hanreich
2026-11-19 19:45 ` [PATCH pve-network 05/14] sdn: zones: assign a conntrack zone to zones with a dedicated VRF Stefan Hanreich
2026-11-19 19:45 ` [PATCH proxmox-firewall 06/14] firewall: apply vnet rules to host traffic from vnets in a VRF Stefan Hanreich
2026-11-19 19:45 ` [PATCH proxmox-firewall 07/14] nftables: expression: add a constructor for map lookups Stefan Hanreich
2026-11-19 19:45 ` [PATCH proxmox-firewall 08/14] nftables: statement: add a helper for setting the conntrack zone Stefan Hanreich
2026-11-19 19:45 ` [PATCH proxmox-firewall 09/14] nftables: expression: convert the conntrack zones of zone VRFs Stefan Hanreich
2026-11-19 19:45 ` [PATCH proxmox-firewall 10/14] firewall: add a command applying " Stefan Hanreich
2026-11-19 19:45 ` [PATCH proxmox-firewall 11/14] firewall: put guest traffic of zone VRFs into their conntrack zone Stefan Hanreich
2026-11-19 19:45 ` Stefan Hanreich [this message]
2026-11-19 19:45 ` [PATCH pve-manager 13/14] network: warn if pve-firewall cannot isolate guests in zone VRFs Stefan Hanreich
2026-11-19 19:45 ` [PATCH pve-docs 14/14] pvesdn: simple zones: document dedicated VRFs Stefan Hanreich
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=20261119194547.674512-13-s.hanreich@proxmox.com \
--to=s.hanreich@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.