From 5b43e378e7f800bdf13a7e7096f6d203b2e97e2a Mon Sep 17 00:00:00 2001 From: Ratish Date: Fri, 7 Jul 2023 14:28:17 +0000 Subject: [PATCH] Added fix for Device.Firewall.Chain.{i}.Rule.{i}.Order re-ordering issue --- libbbfdm/dmtree/tr181/firewall.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/libbbfdm/dmtree/tr181/firewall.c b/libbbfdm/dmtree/tr181/firewall.c index e6e81146..c71aeb1d 100644 --- a/libbbfdm/dmtree/tr181/firewall.c +++ b/libbbfdm/dmtree/tr181/firewall.c @@ -180,30 +180,24 @@ static void update_rule_order(const char *start_order, const char *stop_order, b dmuci_get_value_by_section_string(s, "order", &order); - if (DM_STRTOUL(order) >= DM_STRTOUL(start_order)) { + if ((DM_STRTOUL(order) >= DM_STRTOUL(start_order)) && (DM_STRTOUL(order) <= DM_STRTOUL(stop_order))) { char buf[8] = {0}; snprintf(buf, sizeof(buf), "%lu", incr ? (DM_STRTOUL(order) + 1) : (DM_STRTOUL(order) - 1)); dmuci_set_value_by_section(s, "order", buf); } - - if (DM_STRTOUL(order) == DM_STRTOUL(stop_order)) - return; } uci_path_foreach_sections(bbfdm, "dmmap_firewall", "rule", s) { dmuci_get_value_by_section_string(s, "order", &order); - if (DM_STRTOUL(order) >= DM_STRTOUL(start_order)) { + if ((DM_STRTOUL(order) >= DM_STRTOUL(start_order)) && (DM_STRTOUL(order) <= DM_STRTOUL(stop_order))) { char buf[8] = {0}; snprintf(buf, sizeof(buf), "%lu", incr ? (DM_STRTOUL(order) + 1) : (DM_STRTOUL(order) - 1)); dmuci_set_value_by_section(s, "order", buf); } - - if (DM_STRTOUL(order) == DM_STRTOUL(stop_order)) - return; } }