]> git.ipfire.org Git - people/stevee/ipfire-2.x.git/commitdiff
Revert "rules.pl: Use ipset_exists() function to avoid loading the same set"
authorStefan Schantl <stefan.schantl@ipfire.org>
Fri, 14 Apr 2023 18:26:10 +0000 (20:26 +0200)
committerStefan Schantl <stefan.schantl@ipfire.org>
Fri, 14 Apr 2023 18:26:10 +0000 (20:26 +0200)
We need this to avoid from loading the same set multiple times during
one run but update allready loaded sets.

This reverts commit 6dfa1854fb9ce74c0449b90f8475ac0fa9d87e2e.

config/firewall/rules.pl

index 932268341a91168002b3cc6eba127915017d33a8..fc1be960e317a4d378590bbb906163ee212bfdf0 100644 (file)
@@ -79,6 +79,7 @@ my %blocklistsettings= (
        "ENABLE" => "off",
 );
 
+my %ipset_loaded_sets = ();
 my @ipset_used_sets = ();
 
 my $configfwdfw                = "${General::swroot}/firewall/config";
@@ -1041,7 +1042,10 @@ sub ipset_restore ($) {
        my $db_file;
 
        # Check if the set already has been loaded.
-       return if(&IPSet::Functions::ipset_exists($set));
+       if($ipset_loaded_sets{$set}) {
+               # It already has been loaded - so there is nothing to do.
+               return;
+       }
 
        # Check if the given set name is a country code.
        if($set ~~ @locations) {
@@ -1071,6 +1075,9 @@ sub ipset_restore ($) {
                        run("$IPSET rename $loc_set $set");
                }
        }
+
+       # Store the restored set to the hash to prevent from loading it again.
+       $ipset_loaded_sets{$set} = "1";
 }
 
 sub ipset_call_restore ($) {