Skip to content

Commit

Permalink
Sort filter rules after changes. Fix #15935
Browse files Browse the repository at this point in the history
When rules are added/removed, they should also be re-sorted.
  • Loading branch information
marcos-ng committed Dec 16, 2024
1 parent f79dfc8 commit 2470d8f
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/etc/inc/easyrule.inc
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ function easyrule_block_rule_create($int = 'wan', $ipproto = "inet") {
$ridx = get_interface_ruleindex($int);
array_splice($a_filter, $ridx['first'], 0, array($filterent));
config_set_path('filter/rule', $a_filter);
filter_rules_sort();

// shift the separators
$a_separators = config_get_path('filter/separator/' . strtolower($int), []);
Expand Down
1 change: 1 addition & 0 deletions src/etc/inc/itemid.inc
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function delete_id($id) {
config_set_path('filter/separator/' . strtolower($if), $a_separators);

config_set_path('filter/rule', $array);
filter_rules_sort();
return true;
}

Expand Down
2 changes: 2 additions & 0 deletions src/etc/inc/upgrade_config.inc
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ function upgrade_010_to_011() {
}

config_set_path('filter/rule', $filter_rule_config);
filter_rules_sort();

/* convert shaper rules */
$shaper_rule_config = config_get_path('pfqueueing/rule', []);
Expand Down Expand Up @@ -3803,6 +3804,7 @@ function upgrade_122_to_123() {
}
}
config_set_path('filter/rule', $filter_rules_config);
filter_rules_sort();
}

$binat_config = config_get_path('nat/onetoone', []);
Expand Down
1 change: 1 addition & 0 deletions src/usr/local/pfSense/include/www/firewall_nat.inc
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@ function saveNATrule($post, $id, $json = false) {
$filter_rule_config[] = $filterent;
}
config_set_path('filter/rule', $filter_rule_config);
filter_rules_sort();

if (!$json) {
mark_subsystem_dirty('filter');
Expand Down
2 changes: 2 additions & 0 deletions src/usr/local/www/firewall_rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ function delete_nat_association(array $associations_to_remove = []) {
delete_nat_association($associations_to_remove);
config_set_path('filter/separator/' . strtolower($if), $a_separators);
config_set_path('filter/rule', $a_rules);
filter_rules_sort();
if (write_config(gettext("Firewall: Rules - deleted selected firewall rules."))) {
mark_subsystem_dirty('filter');
}
Expand Down Expand Up @@ -316,6 +317,7 @@ function delete_nat_association(array $associations_to_remove = []) {

if (config_get_path('filter/rule') !== $a_filter_new) {
config_set_path('filter/rule', $a_filter_new);
filter_rules_sort();
$dirty = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1772,6 +1772,7 @@ function apply_all_chosen_items() {
}

config_set_path('filter/rule', $filter_rules);
filter_rules_sort();
write_config(gettext("Shaper configuration saved via traffic shaper wizard."));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1840,6 +1840,7 @@ function apply_all_chosen_items() {
}

config_set_path('filter/rule', $filter_rules);
filter_rules_sort();
write_config(gettext("Shaper configuration saved via traffic shaper wizard."));
}

Expand Down

0 comments on commit 2470d8f

Please sign in to comment.