From: Arthur Bied-Charreton <a.bied-charreton@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH proxmox-firewall 10/13] fix #5759: firewall: do not clear rules on system shutdown
Date: Tue, 21 Jul 2026 15:54:04 +0200 [thread overview]
Message-ID: <20260721135407.372150-11-a.bied-charreton@proxmox.com> (raw)
In-Reply-To: <20260721135407.372150-1-a.bied-charreton@proxmox.com>
The assumption until now was that the firewall rules should always be
cleared when receiving SIGTERM. This is correct when SIGTERM is received
as the result of `systemctl stop`, should however not be handled the
same way in case of a system shutdown.
Because of the way the proxmox-firewall service is ordered, it comes
down before the network. Clearing the rules in that case creates a
window where the network is up without firewall protection.
Check the operational state of the system when receiving a stop signal
and only clear the nftables rules if the system is not currently
shutting down.
Fixes: https://bugzilla.proxmox.com/show_bug.cgi?id=5759
Signed-off-by: Arthur Bied-Charreton <a.bied-charreton@proxmox.com>
---
Cargo.toml | 1 +
proxmox-firewall/Cargo.toml | 1 +
proxmox-firewall/src/bin/proxmox-firewall.rs | 12 +++++++++++-
3 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/Cargo.toml b/Cargo.toml
index 1dd2784..5f2fa1c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -33,6 +33,7 @@ proxmox-network-api = "1"
proxmox-network-types = "1"
proxmox-serde = "1"
proxmox-sys = "1"
+proxmox-systemd = "1.0.1"
proxmox-ve-config = "0.10"
# workspace crates
diff --git a/proxmox-firewall/Cargo.toml b/proxmox-firewall/Cargo.toml
index 6ad7e79..fa7fd34 100644
--- a/proxmox-firewall/Cargo.toml
+++ b/proxmox-firewall/Cargo.toml
@@ -22,6 +22,7 @@ proxmox-log.workspace = true
proxmox-network-types.workspace = true
proxmox-network-api = { workspace = true, features = [ "impl" ] }
proxmox-nftables = { workspace = true, features = [ "config-ext" ] }
+proxmox-systemd.workspace = true
proxmox-ve-config.workspace = true
[dev-dependencies]
diff --git a/proxmox-firewall/src/bin/proxmox-firewall.rs b/proxmox-firewall/src/bin/proxmox-firewall.rs
index e8ed477..27fd67d 100644
--- a/proxmox-firewall/src/bin/proxmox-firewall.rs
+++ b/proxmox-firewall/src/bin/proxmox-firewall.rs
@@ -10,6 +10,7 @@ use proxmox_firewall::firewall::Firewall;
use proxmox_log as log;
use proxmox_log::{LevelFilter, Logger};
use proxmox_nftables::{NftClient, client::NftError};
+use proxmox_systemd::systemctl;
use proxmox_ve_config::firewall::host::Config as HostConfig;
const HELP: &str = r#"
@@ -115,7 +116,16 @@ fn run_firewall() -> Result<(), Error> {
std::thread::sleep(Duration::from_secs(5));
}
- remove_firewall().with_context(|| "Could not remove firewall rules")
+ match systemctl::is_system_running() {
+ // Got SIGTERM as the result of a shutdown, do not remove rules.
+ Ok(systemctl::SystemState::Stopping) => {
+ log::info!("system is stopping, not removing firewall rules");
+ Ok(())
+ }
+ Err(e) => bail!("{e}"),
+ // System is not stopping, firewall was shut down explicitly, remove rules.
+ _ => remove_firewall().with_context(|| "could not remove firewall rules"),
+ }
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
--
2.47.3
next prev parent reply other threads:[~2026-07-21 13:55 UTC|newest]
Thread overview: 14+ 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 ` Arthur Bied-Charreton [this message]
2026-07-21 13:54 ` [PATCH proxmox-firewall 11/13] firewall: dump config to local directory after apply Arthur Bied-Charreton
2026-07-21 13:54 ` [PATCH proxmox-firewall 12/13] firewall: add restore command 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
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=20260721135407.372150-11-a.bied-charreton@proxmox.com \
--to=a.bied-charreton@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox