From: Stefan Schantl Date: Fri, 14 Apr 2023 16:46:19 +0000 (+0200) Subject: rules.pl: Use ipset_exists() function to avoid loading the same set X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ad0bd8a49a6ad7a532064e64d714e5bd5a3f5a60;p=people%2Fstevee%2Fipfire-2.x.git 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 --- diff --git a/config/firewall/rules.pl b/config/firewall/rules.pl index 7da47ed6a..ff1378a74 100644 --- a/config/firewall/rules.pl +++ b/config/firewall/rules.pl @@ -80,7 +80,6 @@ my %blocklistsettings= ( "ENABLE" => "off", ); -my %ipset_loaded_sets = (); my @ipset_used_sets = (); my $configfwdfw = "${General::swroot}/firewall/config"; @@ -1043,10 +1042,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) { @@ -1096,9 +1092,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 ($) {