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 95a9e22a041b3507ac23c5a4403a17e9389c52c1..fc24d0b5294bb041431457f697aa5f45c5f8d849 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 cd821fcd8dadb3d2be9e7f8211e75de4ec243d16..ad349686b088c21c746b89e46c312f5cfda8286c 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 10546585845f7620aa29cf2348c7850a4cc15f57..e731eefff4d430cab63cfd7458f55ee51316307c 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 5de2964f286a3294a3acaa40a3b7230d98a69ecd..fbc6a9a7dbab9fe8f510a64554635dc52a637306 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: