]> git.ipfire.org Git - people/stevee/ipfire-2.x.git/commitdiff
rules.pl: Use ipset_exists() function to avoid loading the same set
authorStefan Schantl <stefan.schantl@ipfire.org>
Fri, 14 Apr 2023 16:46:19 +0000 (18:46 +0200)
committerStefan Schantl <stefan.schantl@ipfire.org>
Fri, 14 Apr 2023 16:46:19 +0000 (18:46 +0200)
multiple times.

Asking the kernel if a set is allready loaded/know is much smarter.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
config/firewall/rules.pl

index 52fdc8206be3e83fcabcd267bbb9a58de4f06982..0916ec207e181d82f0358ae8f5551943d5f564a3 100644 (file)
@@ -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 ($) {