Further fixes for zone reloads
[project/firewall3.git] / zones.c
diff --git a/zones.c b/zones.c
index 11ec569..3d3812c 100644 (file)
--- a/zones.c
+++ b/zones.c
@@ -23,7 +23,7 @@
 #define C(f, tbl, tgt, fmt) \
        { FW3_FAMILY_##f, FW3_TABLE_##tbl, FW3_FLAG_##tgt, fmt }
 
 #define C(f, tbl, tgt, fmt) \
        { FW3_FAMILY_##f, FW3_TABLE_##tbl, FW3_FLAG_##tgt, fmt }
 
-static const struct fw3_rule_spec zone_chains[] = {
+static const struct fw3_chain_spec zone_chains[] = {
        C(ANY, FILTER, UNSPEC,        "zone_%s_input"),
        C(ANY, FILTER, UNSPEC,        "zone_%s_output"),
        C(ANY, FILTER, UNSPEC,        "zone_%s_forward"),
        C(ANY, FILTER, UNSPEC,        "zone_%s_input"),
        C(ANY, FILTER, UNSPEC,        "zone_%s_output"),
        C(ANY, FILTER, UNSPEC,        "zone_%s_forward"),
@@ -232,7 +232,7 @@ print_zone_chain(struct fw3_ipt_handle *handle, struct fw3_state *state,
 {
        int i;
        struct fw3_ipt_rule *r;
 {
        int i;
        struct fw3_ipt_rule *r;
-       const struct fw3_rule_spec *c;
+       const struct fw3_chain_spec *c;
 
        const char *flt_chains[] = {
                "input",   "input",
 
        const char *flt_chains[] = {
                "input",   "input",
@@ -563,7 +563,7 @@ fw3_flush_zones(struct fw3_ipt_handle *handle, struct fw3_state *state,
                 bool reload)
 {
        struct fw3_zone *z, *tmp;
                 bool reload)
 {
        struct fw3_zone *z, *tmp;
-       const struct fw3_rule_spec *c;
+       const struct fw3_chain_spec *c;
        char chain[32];
 
        list_for_each_entry_safe(z, tmp, &state->zones, list)
        char chain[32];
 
        list_for_each_entry_safe(z, tmp, &state->zones, list)
@@ -574,7 +574,7 @@ fw3_flush_zones(struct fw3_ipt_handle *handle, struct fw3_state *state,
                for (c = zone_chains; c->format; c++)
                {
                        /* don't touch user chains on selective stop */
                for (c = zone_chains; c->format; c++)
                {
                        /* don't touch user chains on selective stop */
-                       if (reload && hasbit(c->flag, FW3_FLAG_CUSTOM_CHAINS))
+                       if (reload && c->flag == FW3_FLAG_CUSTOM_CHAINS)
                                continue;
 
                        if (!fw3_is_family(c, handle->family))
                                continue;
 
                        if (!fw3_is_family(c, handle->family))
@@ -583,6 +583,9 @@ fw3_flush_zones(struct fw3_ipt_handle *handle, struct fw3_state *state,
                        if (c->table != handle->table)
                                continue;
 
                        if (c->table != handle->table)
                                continue;
 
+                       if (c->flag && !has(z->flags, handle->family, c->flag))
+                               continue;
+
                        snprintf(chain, sizeof(chain), c->format, z->name);
                        fw3_ipt_delete_rules(handle, chain);
                        fw3_ipt_delete_chain(handle, chain);
                        snprintf(chain, sizeof(chain), c->format, z->name);
                        fw3_ipt_delete_rules(handle, chain);
                        fw3_ipt_delete_chain(handle, chain);