From: Jo-Philipp Wich Date: Fri, 14 Oct 2022 15:45:08 +0000 (+0200) Subject: main.uc: reintroduce set reload restriction X-Git-Url: http://git.openwrt.org/?a=commitdiff_plain;h=c7201a3d24eb2a9ae122a0d6e4bb41146edebf10;p=project%2Ffirewall4.git main.uc: reintroduce set reload restriction Only reload sets which either declare a file to load or a set of static entries in order to avoid clearing externally managed sets that might take a long time to repopulate. Also guard the entry file loading in order to avoid a stray warning message. Ref: https://forum.openwrt.org/t/x/138579/57 Signed-off-by: Jo-Philipp Wich --- diff --git a/root/usr/share/firewall4/main.uc b/root/usr/share/firewall4/main.uc index 1d8a405..36df85f 100644 --- a/root/usr/share/firewall4/main.uc +++ b/root/usr/share/firewall4/main.uc @@ -18,6 +18,9 @@ function reload_sets() { sets = fw4.check_set_types(); for (let set in state.ipsets) { + if (!set.loadfile && !length(set.entries)) + continue; + if (!exists(sets, set.name)) { warn(`Named set '${set.name}' does not exist - do you need to restart the firewall?\n`); continue; @@ -40,7 +43,9 @@ function reload_sets() { print(`flush set inet fw4 ${set.name}\n`); map(set.entries, printer); - fw4.parse_setfile(set, printer); + + if (set.loadfile) + fw4.parse_setfile(set, printer); if (!first) print("}\n\n");