my $default_log_level = 'nolog'; # avoid logs by default
+my $global_log_ratelimit = '--limit 1/sec';
+
my $log_level_hash = {
debug => 7,
info => 6,
],
'Razor' => [
"Razor Antispam System",
- { action => 'ACCEPT', proto => 'tcp', dport => '2703' },
+ { action => 'PARAM', proto => 'tcp', dport => '2703' },
],
'Rdate' => [
"Remote time retrieval (rdate)",
optional => 1,
enum => ['ACCEPT', 'REJECT', 'DROP'],
},
+ log_ratelimit => {
+ description => "Log ratelimiting settings",
+ type => 'string', format => {
+ enable => {
+ default_key => 1,
+ description => 'Enable or disable log rate limiting',
+ type => 'boolean',
+ default => '1',
+ },
+ rate => {
+ type => 'string',
+ description => 'Frequency with which the burst bucket gets refilled',
+ optional => 1,
+ pattern => '[1-9][0-9]*\/(second|minute|hour|day)',
+ format_description => 'rate',
+ default => '1/second',
+ },
+ burst => {
+ type => 'integer',
+ minimum => 0,
+ optional => 1,
+ description => 'Inital burst of packages which will get logged',
+ default => 5,
+ },
+ },
+ optional => 1,
+ },
};
our $host_option_properties = {
default => 0,
optional => 1,
},
+ log_nf_conntrack => {
+ description => "Enable logging of conntrack information.",
+ type => 'boolean',
+ default => 0,
+ optional => 1
+ },
};
our $vm_option_properties = {
}
my @iptcmds;
- if ($rule->{log} && $rule->{log} ne 'nolog') {
- my $log = $rule->{log};
+ my $log = $rule->{log};
+ if (defined($log) && $log ne 'nolog') {
my $loglevel = $log_level_hash->{$log};
my $logaction = get_log_rule_base($chain, $vmid, $rule->{logmsg}, $loglevel);
push @iptcmds, "-A $chain $matchstr $logaction";
$vmid = 0 if !defined($vmid);
$msg = "" if !defined($msg);
+ my $rlimit = '';
+ if (defined($global_log_ratelimit)) {
+ $rlimit = "-m limit $global_log_ratelimit ";
+ }
+
# Note: we use special format for prefix to pass further
# info to log daemon (VMID, LOGLEVEL and CHAIN)
-
- return "-m limit --limit 1/sec -j NFLOG --nflog-prefix \":$vmid:$loglevel:$chain: $msg\"";
+ return "${rlimit}-j NFLOG --nflog-prefix \":$vmid:$loglevel:$chain: $msg\"";
}
sub ruleset_add_chain_policy {
} elsif ($line =~ m/^(policy_(in|out)):\s*(ACCEPT|DROP|REJECT)\s*$/i) {
$opt = lc($1);
$value = uc($3);
+ } elsif ($line =~ m/^(log_ratelimit):\s*(\S+)\s*$/) {
+ $opt = lc($1);
+ $value = $2;
} else {
die "can't parse option '$line'\n"
}
return ++$int;
}
+my $set_global_log_ratelimit = sub {
+ my $cluster_opts = shift;
+
+ $global_log_ratelimit = '--limit 1/sec';
+ if (defined(my $log_rlimit = $cluster_opts->{log_ratelimit})) {
+ my $ll_format = $cluster_option_properties->{log_ratelimit}->{format};
+ my $limit = PVE::JSONSchema::parse_property_string($ll_format, $log_rlimit);
+
+ if ($limit->{enable}) {
+ if (my $rate = $limit->{rate}) {
+ $global_log_ratelimit = "--limit $rate";
+ }
+ if (my $burst = $limit->{burst}) {
+ $global_log_ratelimit .= " --limit-burst $burst";
+ }
+ } else {
+ $global_log_ratelimit = undef;
+ }
+ }
+};
+
sub load_clusterfw_conf {
my ($filename, $verbose) = @_;
my $cluster_conf = {};
if (my $fh = IO::File->new($filename, O_RDONLY)) {
$cluster_conf = parse_clusterfw_config($filename, $fh, $verbose);
+
+ $set_global_log_ratelimit->($cluster_conf->{options});
}
return $cluster_conf;