From 6dfa1854fb9ce74c0449b90f8475ac0fa9d87e2e Mon Sep 17 00:00:00 2001 From: Stefan Schantl Date: Fri, 14 Apr 2023 18:46:19 +0200 Subject: [PATCH] rules.pl: Use ipset_exists() function to avoid loading the same set multiple times. Asking the kernel if a set is allready loaded/know is much smarter. Signed-off-by: Stefan Schantl --- config/firewall/rules.pl | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/config/firewall/rules.pl b/config/firewall/rules.pl index 52fdc8206b..0916ec207e 100644 --- a/config/firewall/rules.pl +++ b/config/firewall/rules.pl @@ -79,7 +79,6 @@ my %blocklistsettings= ( "ENABLE" => "off", ); -my %ipset_loaded_sets = (); my @ipset_used_sets = (); my $configfwdfw = "${General::swroot}/firewall/config"; @@ -1042,10 +1041,7 @@ sub ipset_restore ($) { my $db_file; # Check if the set already has been loaded. - if($ipset_loaded_sets{$set}) { - # It already has been loaded - so there is nothing to do. - return; - } + return if(&IPSet::Functions::ipset_exists($set)); # Check if the given set name is a country code. if($set ~~ @locations) { @@ -1095,9 +1091,6 @@ sub ipset_restore ($) { run("$IPSET rename $set_name $set"); } } - - # Store the restored set to the hash to prevent from loading it again. - $ipset_loaded_sets{$set} = "1"; } sub ipset_call_restore ($) { -- 2.39.5