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 4198C1FF0B3 for ; Fri, 11 Sep 2026 11:14:40 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 560CD21559; Fri, 11 Sep 2026 11:14:36 +0200 (CEST) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Fri, 11 Sep 2026 11:14:30 +0200 Message-Id: Subject: Re: [PATCH proxmox-firewall 12/13] firewall: add restore command From: "Thomas Ellmenreich" To: "Arthur Bied-Charreton" , X-Mailer: aerc 0.20.0 References: <20260721135407.372150-1-a.bied-charreton@proxmox.com> <20260721135407.372150-13-a.bied-charreton@proxmox.com> In-Reply-To: <20260721135407.372150-13-a.bied-charreton@proxmox.com> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1789118060517 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.615 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: RFSHJJ2WM7T3YVZEKEA6PULVEAK2HY7P X-Message-ID-Hash: RFSHJJ2WM7T3YVZEKEA6PULVEAK2HY7P X-MailFrom: t.ellmenreich@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: 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 PveFirewallConfigLoade= r { > } > } > =20 > +#[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) =3D open_config_file(&p)? { > + log::info!("loaded {what} config from {p:?}"); > + let reader =3D 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? > + } > + > + fn host(&self) -> Result>, Error> { > + load_first_of(&["host.fw.override", "host.fw.new", "host.fw"], "= host") > + } > + > + fn sdn_running_config(&self) -> Result>, Err= or> { > + let path =3D Path::new(DUMP_DIR).join("sdn.json"); > + if let Some(fd) =3D open_config_file(&path)? { > + let reader =3D 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([])) > + } > +}