]> 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>
Sun, 3 Mar 2024 11:56:03 +0000 (12:56 +0100)
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 d8c2702298af0851bbabad5d96fd79a50c3090f3..bbd417d305af4f75663c33a118964ea7b8e789d0 100644 (file)
@@ -80,6 +80,7 @@ my %blocklistsettings= (
        "ENABLE" => "off",
 );
 
+my %ipset_loaded_sets = ();
 my @ipset_used_sets = ();
 
 my $configfwdfw                = "${General::swroot}/firewall/config";
@@ -1042,7 +1043,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) {
@@ -1072,6 +1076,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 ($) {