]> 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>
Sun, 3 Mar 2024 11:56:03 +0000 (12:56 +0100)
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 7da47ed6ad7a39e7ca04b5e0cc75f37c524b2541..ff1378a74f24c0e1b195e00333d238765f708e53 100644 (file)
@@ -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 ($) {