firewall3: defaults: fix uci flow_offloading option
authorWangYanlong <yanlong.wang@naiver.org>
Fri, 13 Mar 2020 12:29:27 +0000 (12:29 +0000)
committerJo-Philipp Wich <jo@mein.io>
Fri, 13 Mar 2020 12:40:23 +0000 (13:40 +0100)
Fixes 7cc2a84 ("defaults: robustify flow table detection.")

7cc2a84 made disabling flow_offloading impossible.
This is to fix the buggy behavior.

Signed-off-by: Yanlong Wang <yanlong.wang@naiver.org>
[move variable declaration to the top, remove braces from conditional]
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
defaults.c

index c78ab5169dc1b174751649f8c312a2debac2c6db..60a4c81f773bf9527407ac61b0731e940f9c5463 100644 (file)
@@ -126,6 +126,7 @@ fw3_load_defaults(struct fw3_state *state, struct uci_package *p)
        struct uci_element *e;
        struct fw3_defaults *defs = &state->defaults;
 
+       bool flow_offload_avaliable = false;
        bool seen = false;
 
        defs->tcp_reject_code      = FW3_REJECT_CODE_TCP_RESET;
@@ -160,7 +161,10 @@ fw3_load_defaults(struct fw3_state *state, struct uci_package *p)
                check_any_reject_code(e, &defs->any_reject_code);
 
                /* exists in both ipv4 and ipv6, if at all, so only check ipv4 */
-               check_target(e, &defs->flow_offloading, "FLOWOFFLOAD", false);
+               check_target(e, &flow_offload_avaliable, "FLOWOFFLOAD", false);
+
+               if (!flow_offload_avaliable)
+                       defs->flow_offloading = false;
        }
 }