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=6dfa1854fb9ce74c0449b90f8475ac0fa9d87e2e;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 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 ($) {