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 C4DA41FF0AF for ; Fri, 20 Nov 2026 16:28:38 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 78824217FA; Fri, 20 Nov 2026 16:28:24 +0100 (CET) From: Stefan Hanreich To: pve-devel@lists.proxmox.com Subject: [PATCH proxmox-ve-rs 2/4] sdn: conntrack: only map the VRFs of zones that exist on the node Date: Fri, 20 Nov 2026 16:28:07 +0100 Message-ID: <20261120152811.473269-3-s.hanreich@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261120152811.473269-1-s.hanreich@proxmox.com> References: <20261120152811.473269-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: 1795188499563 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.215 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: 3IHSCFRPLJV5IGDTSB3QN6M4MPIP3EHH X-Message-ID-Hash: 3IHSCFRPLJV5IGDTSB3QN6M4MPIP3EHH 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: If a zone is restricted to certain nodes, then proxmox-firewall would still have put an interface on other nodes with the name of the VRF device of the zone, and the interfaces enslaved to it, into the conntrack zone of the zone. To prevent this, replace the conversion from the SDN config with a constructor that only takes the zones that exist on the given node. Signed-off-by: Stefan Hanreich --- proxmox-ve-config/src/sdn/conntrack.rs | 26 ++++++++++---------- proxmox-ve-config/tests/sdn/main.rs | 33 +++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 13 deletions(-) diff --git a/proxmox-ve-config/src/sdn/conntrack.rs b/proxmox-ve-config/src/sdn/conntrack.rs index a8f91658..c1a916cc 100644 --- a/proxmox-ve-config/src/sdn/conntrack.rs +++ b/proxmox-ve-config/src/sdn/conntrack.rs @@ -86,6 +86,20 @@ impl VrfCtZones { format!("vrf_{}", zone.name()) } + /// The VRFs of the zones with a conntrack zone that exist on `node`. + /// + /// The VRF device of a zone is only created on the nodes of the zone, so an interface with the + /// same name on another node is not the VRF of the zone and must not get its conntrack zone. + pub fn for_node(config: &SdnConfig, node: &str) -> Self { + let mut ct_zones = Self::default(); + + for zone in config.zones().filter(|zone| zone.is_on_node(node)) { + ct_zones.add_zone(zone); + } + + ct_zones + } + /// Adds the VRF of a zone, if the zone has a conntrack zone. pub fn add_zone(&mut self, zone: &ZoneConfig) { if let Some(ct_zone) = zone.ct_zone() { @@ -135,18 +149,6 @@ impl VrfCtZones { } } -impl From<&SdnConfig> for VrfCtZones { - fn from(config: &SdnConfig) -> Self { - let mut ct_zones = Self::default(); - - for zone in config.zones() { - ct_zones.add_zone(zone); - } - - ct_zones - } -} - #[cfg(test)] mod tests { use super::*; diff --git a/proxmox-ve-config/tests/sdn/main.rs b/proxmox-ve-config/tests/sdn/main.rs index d1071771..bd0b6dd9 100644 --- a/proxmox-ve-config/tests/sdn/main.rs +++ b/proxmox-ve-config/tests/sdn/main.rs @@ -170,7 +170,7 @@ fn parse_running_config_ct_zone() { assert_eq!(ct_zone("zone3"), None); assert_eq!(ct_zone("zone4"), None); - let vrfs: Vec<_> = VrfCtZones::from(&sdn_config) + let vrfs: Vec<_> = VrfCtZones::for_node(&sdn_config, "pve1") .iter() .map(|(vrf, entry)| (vrf.to_string(), entry.ct_zone().id())) .collect(); @@ -214,6 +214,37 @@ fn parse_running_config_nodes() { assert!(!is_on_node("zone2", "pve1")); } +#[test] +fn vrf_ct_zones_for_node() { + let running_config: RunningConfig = serde_json::from_value(serde_json::json!({ + "zones": { + "ids": { + "zone0": { "type": "simple", "dedicated-vrf": 1, "ct-zone": 16384 }, + "zone1": { + "type": "simple", + "dedicated-vrf": 1, + "ct-zone": 16385, + "nodes": { "pve1": 1 }, + }, + "zone2": { "type": "simple", "dedicated-vrf": 1, "ct-zone": 16386, "nodes": {} }, + }, + }, + })) + .expect("valid running config"); + + let sdn_config = SdnConfig::try_from(running_config).expect("valid SDN config"); + + let vrfs = |node: &str| -> Vec { + VrfCtZones::for_node(&sdn_config, node) + .iter() + .map(|(vrf, _)| vrf.to_string()) + .collect() + }; + + assert_eq!(vrfs("pve1"), ["vrf_zone0", "vrf_zone1"]); + assert_eq!(vrfs("pve2"), ["vrf_zone0"]); +} + #[test] fn sdn_config() { let mut sdn_config = SdnConfig::new(); -- 2.47.3