]> git.ipfire.org Git - people/stevee/ipfire-2.x.git/commitdiff
rules.pl: Avoid creating iptables rules if the corresponding blocklist is not loaded
authorStefan Schantl <stefan.schantl@ipfire.org>
Fri, 14 Apr 2023 16:32:54 +0000 (18:32 +0200)
committerStefan Schantl <stefan.schantl@ipfire.org>
Fri, 14 Apr 2023 16:32:54 +0000 (18:32 +0200)
In case a blocklist is empty after de-duplication of the entries, it
would not be loaded. In such a case we also can skip creating any
iptables rules for this list.

This avoids us checking against an empty list and therefore saves a few cpu cycles.

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

index 143161b55123a60328284e031448e7b3a1eb431c..52fdc8206be3e83fcabcd267bbb9a58de4f06982 100644 (file)
@@ -749,8 +749,8 @@ sub ipblocklist () {
        foreach my $blocklist (@blocklists) {
                # Check if the blocklist feature and the current processed blocklist is enabled.
                if(($blocklistsettings{'ENABLE'} eq "on") && ($blocklistsettings{$blocklist}) && ($blocklistsettings{$blocklist} eq "on")) {
-                       # Call function to load the blocklist.
-                       &ipset_restore($blocklist);
+                       # Skip the blocklist if the set does not exist.
+                       next unless(&IPSet::Functions::ipset_exists($blocklist));
 
                        # Call function to check if the corresponding iptables drop chain already has been created.
                        if(&firewall_chain_exists("${blocklist}_DROP")) {