From 9da5c28f40b39a2de9c1ffdde39360cfee475c22 Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Tue, 21 Sep 2021 15:27:44 +0200 Subject: [PATCH] Firewall / Rules - specify overload table on max new connections, closes https://github.com/opnsense/core/issues/5229 --- .../library/OPNsense/Firewall/FilterRule.php | 3 +- src/www/firewall_rules_edit.php | 28 ++++++++++++++++--- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/opnsense/mvc/app/library/OPNsense/Firewall/FilterRule.php b/src/opnsense/mvc/app/library/OPNsense/Firewall/FilterRule.php index 3a6096a5a..468aecae2 100644 --- a/src/opnsense/mvc/app/library/OPNsense/Firewall/FilterRule.php +++ b/src/opnsense/mvc/app/library/OPNsense/Firewall/FilterRule.php @@ -236,8 +236,9 @@ class FilterRule extends Rule $rule['state']['options'][] = "tcp.established " . $rule['statetimeout']; } if (!empty($rule['max-src-conn-rate']) && !empty($rule['max-src-conn-rates'])) { + $otbl = !empty($rule['overload']) ? $rule['overload'] : "virusprot"; $rule['state']['options'][] = "max-src-conn-rate " . $rule['max-src-conn-rate'] . " " . - "/" . $rule['max-src-conn-rates'] . ", overload flush global "; + "/" . $rule['max-src-conn-rates'] . ", overload <{$otbl}> flush global "; } } } diff --git a/src/www/firewall_rules_edit.php b/src/www/firewall_rules_edit.php index ed800c8e1..730665b55 100644 --- a/src/www/firewall_rules_edit.php +++ b/src/www/firewall_rules_edit.php @@ -109,6 +109,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { 'max-src-conn', 'max-src-conn-rate', 'max-src-conn-rates', + 'overload', 'max-src-nodes', 'max-src-states', 'nopfsync', @@ -433,6 +434,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { $input_errors[] = gettext('Priority match must be an integer between 0 and 7.'); } + if (!empty($pconfig['overload']) && !is_alias($pconfig['overload'])) { + $input_errors[] = gettext('Max new connections overload table should be a valid alias.'); + } + if (count($input_errors) == 0) { $filterent = array(); // 1-on-1 copy of form values @@ -451,6 +456,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { } } + // only flush non default max new connection overload table + if (!empty($pconfig['overload']) && $pconfig['overload'] != 'virusprot') { + $filterent['overload'] = $pconfig['overload']; + } + // attributes with some kind of logic if (!empty($pconfig['floating'])) { $filterent['floating'] = "yes"; @@ -1490,13 +1500,13 @@ endforeach;?> - +
- + + +
- + / + +