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 B62011FF0B3 for ; Fri, 11 Sep 2026 11:38:10 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id C580521538; Fri, 11 Sep 2026 11:38:07 +0200 (CEST) Date: Fri, 11 Sep 2026 11:37:58 +0200 From: Arthur Bied-Charreton To: Thomas Ellmenreich Subject: Re: [PATCH proxmox-firewall 12/13] firewall: add restore command Message-ID: References: <20260721135407.372150-1-a.bied-charreton@proxmox.com> <20260721135407.372150-13-a.bied-charreton@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1789119469396 X-SPAM-LEVEL: Spam detection results: 0 AWL 1.580 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: PHPO52BRUOTIN4PCLEJGWJDWB4YQTOZE X-Message-ID-Hash: PHPO52BRUOTIN4PCLEJGWJDWB4YQTOZE X-MailFrom: a.bied-charreton@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: pve-devel@lists.proxmox.com X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Fri, Sep 11, 2026 at 11:14:30AM +0200, Thomas Ellmenreich wrote: > One comment inline ;) > > On Tue Jul 21, 2026 at 3:54 PM CEST, Arthur Bied-Charreton wrote: > > Add a 'restore' command that recompiles and applies the firewall from > > the config dumped to /var/lib/pve/firewall, to bridge the boot window > > before pmxcfs (and thus the real config) is available. > > > > It reuses handle_firewall() along with a local firewall config loader. > > The config files are loaded from the local dump instead of pmxcfs and > > nothing is dumped back. A missing or unreadable SDN dump is treated as > > empty and rules referencing an unavailable IPSet are skipped, so a > > partial dump still restores the rest on a best-effort basis. > > > > For the cluster and host config, a user-provided .override or a .new > > written by the pve-network-interface-pinning tool take precedence over > > the plain dump when present (.override -> .new -> plain). > > > > Signed-off-by: Arthur Bied-Charreton > > --- > > [snip] > > > diff --git a/proxmox-firewall/src/config.rs b/proxmox-firewall/src/config.rs > > index eb8dd21..83b9161 100644 > > --- a/proxmox-firewall/src/config.rs > > +++ b/proxmox-firewall/src/config.rs > > [snip] > > > @@ -247,6 +249,81 @@ impl FirewallConfigLoader for PveFirewallConfigLoader { > > } > > } > > > > +#[derive(Debug, Default)] > > +pub struct LocalFirewallConfigLoader {} > > + > > +impl LocalFirewallConfigLoader { > > + pub fn new() -> Self { > > + Self::default() > > + } > > +} > > + > > +fn load_first_of(candidates: &[&str], what: &str) -> Result>, Error> { > > + for p in candidates.iter().map(|p| Path::new(DUMP_DIR).join(p)) { > > + if let Some(fd) = open_config_file(&p)? { > > + log::info!("loaded {what} config from {p:?}"); > > + let reader = Box::new(BufReader::new(fd)) as Box; > > + return Ok(Some(reader)); > > + } > > + } > > + Ok(None) > > +} > > + > > +impl FirewallConfigLoader for LocalFirewallConfigLoader { > > + fn cluster(&self) -> Result>, Error> { > > + load_first_of(&["cluster.fw.override", "cluster.fw"], "cluster") > ^ > Reading the commit message it sounds like a 'cluster.fw.new' > should also exist? Whats the reason for that not being the > case? > host.fw.new files are created by the pve-network-interface-pinning tool [0][1] when changing network interface pinnings, since this only takes effect at the next boot and the old config should still be used until then. This tool never creates a .new file for the cluster config, since network interface name pinnings are node-specific. [0] https://git.proxmox.com/?p=pve-manager.git;a=blob;f=PVE/CLI/pve_network_interface_pinning.pm;h=9dff181dcd9d616e725380e98aba2fb36c6efbcf;hb=refs/heads/master [1] https://lore.proxmox.com/pve-devel/20260721135407.372150-2-a.bied-charreton@proxmox.com/ > > + } > > + > > + fn host(&self) -> Result>, Error> { > > + load_first_of(&["host.fw.override", "host.fw.new", "host.fw"], "host") > > + } > > + > > + fn sdn_running_config(&self) -> Result>, Error> { > > + let path = Path::new(DUMP_DIR).join("sdn.json"); > > + if let Some(fd) = open_config_file(&path)? { > > + let reader = Box::new(BufReader::new(fd)) as Box; > > + return Ok(Some(reader)); > > + } > > + > > + Ok(None) > > + } > > + > > + fn guest_config( > > + &self, > > + _: &Vmid, > > + _: &GuestEntry, > > + ) -> Result>, Error> { > > + Ok(None) > > + } > > + > > + fn guest_firewall_config(&self, _: &Vmid) -> Result>, Error> { > > + Ok(None) > > + } > > + > > + fn guest_list(&self) -> Result { > > + Ok(GuestMap::from(HashMap::new())) > > + } > > + > > + fn bridge_firewall_config( > > + &self, > > + _: &BridgeName, > > + ) -> Result>, Error> { > > + Ok(None) > > + } > > + > > + fn bridge_list(&self) -> Result, Error> { > > + Ok(vec![]) > > + } > > + > > + fn ipam(&self) -> Result>, Error> { > > + Ok(None) > > + } > > + > > + fn interface_mapping(&self) -> Result { > > + Ok(AltnameMapping::from_iter([])) > > + } > > +}