public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Arthur Bied-Charreton <a.bied-charreton@proxmox.com>
To: Thomas Ellmenreich <t.ellmenreich@proxmox.com>
Cc: pve-devel@lists.proxmox.com
Subject: Re: [PATCH proxmox-firewall 12/13] firewall: add restore command
Date: Fri, 11 Sep 2026 11:37:58 +0200	[thread overview]
Message-ID: <lwqvamiskwdd7tpa32eozr72m4y54eea66etl45pvshnoe2mwv@pe7pkrqansb2> (raw)
In-Reply-To: <DLCDFB2MK7US.21TQX8UDG80MQ@proxmox.com>

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 <a.bied-charreton@proxmox.com>
> > ---
> 
> [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<Option<Box<dyn BufRead>>, 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<dyn BufRead>;
> > +            return Ok(Some(reader));
> > +        }
> > +    }
> > +    Ok(None)
> > +}
> > +
> > +impl FirewallConfigLoader for LocalFirewallConfigLoader {
> > +    fn cluster(&self) -> Result<Option<Box<dyn BufRead>>, 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<Option<Box<dyn BufRead>>, Error> {
> > +        load_first_of(&["host.fw.override", "host.fw.new", "host.fw"], "host")
> > +    }
> > +
> > +    fn sdn_running_config(&self) -> Result<Option<Box<dyn BufRead>>, 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<dyn BufRead>;
> > +            return Ok(Some(reader));
> > +        }
> > +
> > +        Ok(None)
> > +    }
> > +
> > +    fn guest_config(
> > +        &self,
> > +        _: &Vmid,
> > +        _: &GuestEntry,
> > +    ) -> Result<Option<Box<dyn io::BufRead>>, Error> {
> > +        Ok(None)
> > +    }
> > +
> > +    fn guest_firewall_config(&self, _: &Vmid) -> Result<Option<Box<dyn io::BufRead>>, Error> {
> > +        Ok(None)
> > +    }
> > +
> > +    fn guest_list(&self) -> Result<GuestMap, Error> {
> > +        Ok(GuestMap::from(HashMap::new()))
> > +    }
> > +
> > +    fn bridge_firewall_config(
> > +        &self,
> > +        _: &BridgeName,
> > +    ) -> Result<Option<Box<dyn io::BufRead>>, Error> {
> > +        Ok(None)
> > +    }
> > +
> > +    fn bridge_list(&self) -> Result<Vec<BridgeName>, Error> {
> > +        Ok(vec![])
> > +    }
> > +
> > +    fn ipam(&self) -> Result<Option<Box<dyn io::BufRead>>, Error> {
> > +        Ok(None)
> > +    }
> > +
> > +    fn interface_mapping(&self) -> Result<AltnameMapping, Error> {
> > +        Ok(AltnameMapping::from_iter([]))
> > +    }
> > +}




  reply	other threads:[~2026-09-11  9:38 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-21 13:53 [RFC firewall/manager/proxmox{,-firewall} 00/13] fix #5759: keep firewall rules up across boot and shutdown Arthur Bied-Charreton
2026-07-21 13:53 ` [PATCH pve-manager 01/13] network interface pinning: write new firewall config to local dir Arthur Bied-Charreton
2026-07-21 13:53 ` [PATCH pve-firewall 02/13] firewall: config: sort OPTIONS when serializing Arthur Bied-Charreton
2026-07-21 13:53 ` [PATCH pve-firewall 03/13] d/control: bump libpve-common-perl Arthur Bied-Charreton
2026-07-21 13:53 ` [PATCH pve-firewall 04/13] firewall: dump configs locally after applying Arthur Bied-Charreton
2026-07-21 13:53 ` [PATCH pve-firewall 05/13] fix #5759: firewall: do not remove chains when host is shutting down Arthur Bied-Charreton
2026-07-21 13:54 ` [PATCH pve-firewall 06/13] firewall: add restore command Arthur Bied-Charreton
2026-07-21 13:54 ` [PATCH pve-firewall 07/13] fix #5759: firewall: restore from dumped config before network-pre Arthur Bied-Charreton
2026-07-21 13:54 ` [PATCH proxmox 08/13] systemd: systemctl: add is-system-running helper Arthur Bied-Charreton
2026-07-21 13:54 ` [PATCH proxmox-firewall 09/13] firewall: fix clippy warnings Arthur Bied-Charreton
2026-07-21 13:54 ` [PATCH proxmox-firewall 10/13] fix #5759: firewall: do not clear rules on system shutdown Arthur Bied-Charreton
2026-07-21 13:54 ` [PATCH proxmox-firewall 11/13] firewall: dump config to local directory after apply Arthur Bied-Charreton
2026-09-11  9:10   ` Thomas Ellmenreich
2026-09-11  9:28     ` Arthur Bied-Charreton
2026-07-21 13:54 ` [PATCH proxmox-firewall 12/13] firewall: add restore command Arthur Bied-Charreton
2026-09-11  9:14   ` Thomas Ellmenreich
2026-09-11  9:37     ` Arthur Bied-Charreton [this message]
2026-09-11  9:54       ` Arthur Bied-Charreton
2026-07-21 13:54 ` [PATCH proxmox-firewall 13/13] fix #5759: firewall: restore from dumped config before network-pre Arthur Bied-Charreton
2026-09-11 12:26 ` [RFC firewall/manager/proxmox{,-firewall} 00/13] fix #5759: keep firewall rules up across boot and shutdown Thomas Ellmenreich

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=lwqvamiskwdd7tpa32eozr72m4y54eea66etl45pvshnoe2mwv@pe7pkrqansb2 \
    --to=a.bied-charreton@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    --cc=t.ellmenreich@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal