From: Arthur Bied-Charreton <a.bied-charreton@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH pve-firewall 2/3] firewall: parser: factor out error logging
Date: Wed, 4 Nov 2026 15:19:30 +0100 [thread overview]
Message-ID: <20261104141931.399659-3-a.bied-charreton@proxmox.com> (raw)
In-Reply-To: <20261104141931.399659-1-a.bied-charreton@proxmox.com>
The next commit will add a new caller.
Also print errors in deterministic order, no functional changes intended
besides that.
Signed-off-by: Arthur Bied-Charreton <a.bied-charreton@proxmox.com>
---
src/PVE/Firewall.pm | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/src/PVE/Firewall.pm b/src/PVE/Firewall.pm
index dd5d92c..a1fd6a3 100644
--- a/src/PVE/Firewall.pm
+++ b/src/PVE/Firewall.pm
@@ -3343,6 +3343,19 @@ sub get_mark_values {
return ($value, $mask);
}
+my $log_rule_errors = sub {
+ my ($prefix, $line, $rule) = @_;
+
+ # The verbose flag really means we're running from the CLI and want
+ # output on the console - in the other case we really want such errors
+ # to go into the syslog instead.
+ my $log = $verbose ? sub { warn @_ } : sub { syslog(err => @_) };
+ $log->("$prefix - errors in rule parameters: $line\n");
+ for my $p (sort keys $rule->{errors}->%*) {
+ $log->(" $p: $rule->{errors}->{$p}\n");
+ }
+};
+
sub parse_fw_rule {
my ($prefix, $line, $cluster_conf, $fw_conf, $rule_env) = @_;
@@ -3417,16 +3430,7 @@ sub parse_fw_rule {
die "unable to parse rule parameters: $line\n" if length($line);
$rule = verify_rule($rule, $cluster_conf, $fw_conf, $rule_env, 1);
- if ($rule->{errors}) {
- # The verbose flag really means we're running from the CLI and want
- # output on the console - in the other case we really want such errors
- # to go into the syslog instead.
- my $log = $verbose ? sub { warn @_ } : sub { syslog(err => @_) };
- $log->("$prefix - errors in rule parameters: $orig_line\n");
- foreach my $p (keys %{ $rule->{errors} }) {
- $log->(" $p: $rule->{errors}->{$p}\n");
- }
- }
+ $log_rule_errors->($prefix, $orig_line, $rule) if $rule->{errors};
return $rule;
}
--
2.47.3
next prev parent reply other threads:[~2026-11-04 14:19 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 14:19 [PATCH firewall 0/3] fix #1965: cache the cluster firewall config Arthur Bied-Charreton
2026-11-04 14:19 ` [PATCH pve-firewall 1/3] firewall: run make tidy Arthur Bied-Charreton
2026-11-04 14:19 ` Arthur Bied-Charreton [this message]
2026-11-04 14:19 ` [PATCH pve-firewall 3/3] fix #1965: firewall: cache cluster config Arthur Bied-Charreton
2026-11-04 16:15 ` Stefan Hanreich
2026-11-05 8:19 ` Arthur Bied-Charreton
2026-11-04 16:36 ` Stefan Hanreich
2026-11-05 8:15 ` 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=20261104141931.399659-3-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.