Get rid of redundant fw3_defaults object, instead add a running_flags bitfield to...
authorJo-Philipp Wich <jow@openwrt.org>
Sun, 10 Mar 2013 18:16:55 +0000 (19:16 +0100)
committerJo-Philipp Wich <jow@openwrt.org>
Sun, 10 Mar 2013 18:42:31 +0000 (19:42 +0100)
defaults.c
main.c
options.h
utils.c

index 95a9e22..fc24d0b 100644 (file)
@@ -193,7 +193,7 @@ fw3_print_default_chains(enum fw3_table table, enum fw3_family family,
        }
 
        /* user chains already loaded, don't create again */
-       if (hasbit(state->running_defaults.flags, FW3_DEFAULT_CUSTOM_CHAINS))
+       if (hasbit(state->defaults.running_flags, FW3_DEFAULT_CUSTOM_CHAINS))
                delbit(custom_mask, FW3_DEFAULT_CUSTOM_CHAINS);
 
        print_chains(table, family, ":%s - [0:0]\n", defs->flags & custom_mask,
@@ -340,10 +340,10 @@ void
 fw3_flush_rules(enum fw3_table table, enum fw3_family family,
                 bool pass2, struct fw3_state *state, enum fw3_target policy)
 {
-       struct fw3_defaults *d = &state->running_defaults;
+       struct fw3_defaults *defs = &state->defaults;
        uint32_t custom_mask = ~0;
 
-       if (!hasbit(d->flags, family))
+       if (!hasbit(defs->running_flags, family))
                return;
 
        /* don't touch user chains on selective stop */
@@ -353,18 +353,21 @@ fw3_flush_rules(enum fw3_table table, enum fw3_family family,
        {
                reset_policy(table, policy);
 
-               print_chains(table, family, "-D %s\n", d->flags & custom_mask,
+               print_chains(table, family, "-D %s\n",
+                            defs->running_flags & custom_mask,
                                         toplevel_rules, ARRAY_SIZE(toplevel_rules));
 
-               print_chains(table, family, "-F %s\n", d->flags & custom_mask,
+               print_chains(table, family, "-F %s\n",
+                            defs->running_flags & custom_mask,
                                         default_chains, ARRAY_SIZE(default_chains));
        }
        else
        {
-               print_chains(table, family, "-X %s\n", d->flags & custom_mask,
+               print_chains(table, family, "-X %s\n",
+                            defs->running_flags & custom_mask,
                                         default_chains, ARRAY_SIZE(default_chains));
 
-               delbit(d->flags, family);
+               delbit(defs->flags, family);
        }
 }
 
diff --git a/main.c b/main.c
index cd821fc..ad34968 100644 (file)
--- a/main.c
+++ b/main.c
@@ -135,7 +135,7 @@ restore_pipe(enum fw3_family family, bool silent)
 static bool
 family_running(struct fw3_state *state, enum fw3_family family)
 {
-       return hasbit(state->running_defaults.flags, family);
+       return hasbit(state->defaults.running_flags, family);
 }
 
 static bool
index 1054658..e731eef 100644 (file)
--- a/options.h
+++ b/options.h
@@ -240,6 +240,7 @@ struct fw3_defaults
        bool disable_ipv6;
 
        uint32_t flags;
+       uint32_t running_flags;
 };
 
 struct fw3_zone
@@ -424,7 +425,6 @@ struct fw3_state
        struct list_head ipsets;
        struct list_head includes;
 
-       struct fw3_defaults running_defaults;
        struct list_head running_zones;
        struct list_head running_ipsets;
 
diff --git a/utils.c b/utils.c
index 5de2964..fbc6a9a 100644 (file)
--- a/utils.c
+++ b/utils.c
@@ -390,7 +390,7 @@ fw3_read_statefile(void *state)
                switch (type)
                {
                case FW3_TYPE_DEFAULTS:
-                       s->running_defaults.flags = flags[0];
+                       s->defaults.running_flags = flags[0];
                        break;
 
                case FW3_TYPE_ZONE: