Remove src_flags and running_src_flags from fw3_zone struct, rename dst_flags and...
authorJo-Philipp Wich <jow@openwrt.org>
Sun, 10 Mar 2013 19:19:46 +0000 (20:19 +0100)
committerJo-Philipp Wich <jow@openwrt.org>
Sun, 10 Mar 2013 19:21:33 +0000 (20:21 +0100)
forwards.c
options.h
redirects.c
rules.c
utils.c
zones.c

index 158ccbf..babf5e8 100644 (file)
@@ -88,7 +88,7 @@ fw3_load_forwards(struct fw3_state *state, struct uci_package *p)
 
                if (forward->_dest)
                {
 
                if (forward->_dest)
                {
-                       setbit(forward->_dest->dst_flags, FW3_TARGET_ACCEPT);
+                       setbit(forward->_dest->flags, FW3_TARGET_ACCEPT);
 
                        if (forward->_src &&
                            (forward->_src->conntrack || forward->_dest->conntrack))
 
                        if (forward->_src &&
                            (forward->_src->conntrack || forward->_dest->conntrack))
index 202cd06..0bfb3e8 100644 (file)
--- a/options.h
+++ b/options.h
@@ -279,11 +279,8 @@ struct fw3_zone
 
        bool custom_chains;
 
 
        bool custom_chains;
 
-       uint32_t src_flags;
-       uint32_t dst_flags;
-
-       uint32_t running_src_flags;
-       uint32_t running_dst_flags;
+       uint32_t flags;
+       uint32_t running_flags;
 };
 
 struct fw3_rule
 };
 
 struct fw3_rule
index 2acfabc..23dc034 100644 (file)
@@ -203,16 +203,16 @@ fw3_load_redirects(struct fw3_state *state, struct uci_package *p)
                                warn_elem(e, "has no source specified");
                        else
                        {
                                warn_elem(e, "has no source specified");
                        else
                        {
-                               setbit(redir->_src->dst_flags, redir->target);
+                               setbit(redir->_src->flags, redir->target);
                                redir->_src->conntrack = true;
                                valid = true;
                        }
 
                        if (redir->reflection && redir->_dest && redir->_src->masq)
                        {
                                redir->_src->conntrack = true;
                                valid = true;
                        }
 
                        if (redir->reflection && redir->_dest && redir->_src->masq)
                        {
-                               setbit(redir->_dest->dst_flags, FW3_TARGET_ACCEPT);
-                               setbit(redir->_dest->dst_flags, FW3_TARGET_DNAT);
-                               setbit(redir->_dest->dst_flags, FW3_TARGET_SNAT);
+                               setbit(redir->_dest->flags, FW3_TARGET_ACCEPT);
+                               setbit(redir->_dest->flags, FW3_TARGET_DNAT);
+                               setbit(redir->_dest->flags, FW3_TARGET_SNAT);
                        }
                }
                else
                        }
                }
                else
@@ -225,7 +225,7 @@ fw3_load_redirects(struct fw3_state *state, struct uci_package *p)
                                warn_elem(e, "has no src_dip option specified");
                        else
                        {
                                warn_elem(e, "has no src_dip option specified");
                        else
                        {
-                               setbit(redir->_dest->dst_flags, redir->target);
+                               setbit(redir->_dest->flags, redir->target);
                                redir->_dest->conntrack = true;
                                valid = true;
                        }
                                redir->_dest->conntrack = true;
                                valid = true;
                        }
diff --git a/rules.c b/rules.c
index c3f03cf..77fe998 100644 (file)
--- a/rules.c
+++ b/rules.c
@@ -162,7 +162,7 @@ fw3_load_rules(struct fw3_state *state, struct uci_package *p)
                }
 
                if (rule->_dest)
                }
 
                if (rule->_dest)
-                       setbit(rule->_dest->dst_flags, rule->target);
+                       setbit(rule->_dest->flags, rule->target);
 
                list_add_tail(&rule->list, &state->rules);
                continue;
 
                list_add_tail(&rule->list, &state->rules);
                continue;
diff --git a/utils.c b/utils.c
index 9b383a3..ce9049e 100644 (file)
--- a/utils.c
+++ b/utils.c
@@ -405,7 +405,7 @@ fw3_read_statefile(void *state)
                                list_add_tail(&zone->list, &s->zones);
                        }
 
                                list_add_tail(&zone->list, &s->zones);
                        }
 
-                       zone->running_dst_flags = flags;
+                       zone->running_flags = flags;
                        list_add_tail(&zone->running_list, &s->running_zones);
                        break;
 
                        list_add_tail(&zone->running_list, &s->running_zones);
                        break;
 
@@ -464,7 +464,7 @@ fw3_write_statefile(void *state)
 
        list_for_each_entry(z, &s->running_zones, running_list)
        {
 
        list_for_each_entry(z, &s->running_zones, running_list)
        {
-               fprintf(sf, "%x %s %x\n", FW3_TYPE_ZONE, z->name, z->dst_flags);
+               fprintf(sf, "%x %s %x\n", FW3_TYPE_ZONE, z->name, z->flags);
        }
 
        list_for_each_entry(i, &s->running_ipsets, running_list)
        }
 
        list_for_each_entry(i, &s->running_ipsets, running_list)
diff --git a/zones.c b/zones.c
index e3ec4ab..c47391c 100644 (file)
--- a/zones.c
+++ b/zones.c
@@ -255,19 +255,19 @@ fw3_load_zones(struct fw3_state *state, struct uci_package *p)
 
                if (zone->masq)
                {
 
                if (zone->masq)
                {
-                       setbit(zone->dst_flags, FW3_TARGET_SNAT);
+                       setbit(zone->flags, FW3_TARGET_SNAT);
                        zone->conntrack = true;
                }
 
                if (zone->custom_chains)
                {
                        zone->conntrack = true;
                }
 
                if (zone->custom_chains)
                {
-                       setbit(zone->dst_flags, FW3_TARGET_SNAT);
-                       setbit(zone->dst_flags, FW3_TARGET_DNAT);
+                       setbit(zone->flags, FW3_TARGET_SNAT);
+                       setbit(zone->flags, FW3_TARGET_DNAT);
                }
 
                }
 
-               setbit(zone->dst_flags, fw3_to_src_target(zone->policy_input));
-               setbit(zone->dst_flags, zone->policy_output);
-               setbit(zone->dst_flags, zone->policy_forward);
+               setbit(zone->flags, fw3_to_src_target(zone->policy_input));
+               setbit(zone->flags, zone->policy_output);
+               setbit(zone->flags, zone->policy_forward);
 
                list_add_tail(&zone->list, &state->zones);
        }
 
                list_add_tail(&zone->list, &state->zones);
        }
@@ -285,30 +285,30 @@ print_zone_chain(enum fw3_table table, enum fw3_family family,
        if (!fw3_is_family(zone, family))
                return;
 
        if (!fw3_is_family(zone, family))
                return;
 
-       setbit(zone->dst_flags, family);
+       setbit(zone->flags, family);
 
        /* user chains already loaded, don't create again */
        for (f = FW3_TARGET_CUSTOM_CNS_V4; f <= FW3_TARGET_CUSTOM_CNS_V6; f++)
 
        /* user chains already loaded, don't create again */
        for (f = FW3_TARGET_CUSTOM_CNS_V4; f <= FW3_TARGET_CUSTOM_CNS_V6; f++)
-               if (hasbit(zone->running_dst_flags, f))
+               if (hasbit(zone->running_flags, f))
                        delbit(custom_mask, f);
 
        if (zone->custom_chains)
                        delbit(custom_mask, f);
 
        if (zone->custom_chains)
-               setbit(zone->dst_flags, (family == FW3_FAMILY_V4) ?
+               setbit(zone->flags, (family == FW3_FAMILY_V4) ?
                       FW3_TARGET_CUSTOM_CNS_V4 : FW3_TARGET_CUSTOM_CNS_V6);
 
        if (!zone->conntrack && !state->defaults.drop_invalid)
                       FW3_TARGET_CUSTOM_CNS_V4 : FW3_TARGET_CUSTOM_CNS_V6);
 
        if (!zone->conntrack && !state->defaults.drop_invalid)
-               setbit(zone->dst_flags, FW3_TARGET_NOTRACK);
+               setbit(zone->flags, FW3_TARGET_NOTRACK);
 
        s = print_chains(table, family, ":%s - [0:0]\n", zone->name,
 
        s = print_chains(table, family, ":%s - [0:0]\n", zone->name,
-                        zone->dst_flags,
+                        zone->flags,
                         src_chains, ARRAY_SIZE(src_chains));
 
        d = print_chains(table, family, ":%s - [0:0]\n", zone->name,
                         src_chains, ARRAY_SIZE(src_chains));
 
        d = print_chains(table, family, ":%s - [0:0]\n", zone->name,
-                        zone->dst_flags & custom_mask,
+                        zone->flags & custom_mask,
                         dst_chains, ARRAY_SIZE(dst_chains));
 
        r = print_chains(table, family, "-A %s\n", zone->name,
                         dst_chains, ARRAY_SIZE(dst_chains));
 
        r = print_chains(table, family, "-A %s\n", zone->name,
-                        zone->dst_flags,
+                        zone->flags,
                         def_rules, ARRAY_SIZE(def_rules));
 
        if (s || d || r)
                         def_rules, ARRAY_SIZE(def_rules));
 
        if (s || d || r)
@@ -332,7 +332,7 @@ print_interface_rule(enum fw3_table table, enum fw3_family family,
        {
                for (t = FW3_TARGET_ACCEPT; t <= FW3_TARGET_DROP; t++)
                {
        {
                for (t = FW3_TARGET_ACCEPT; t <= FW3_TARGET_DROP; t++)
                {
-                       if (hasbit(zone->dst_flags, fw3_to_src_target(t)))
+                       if (hasbit(zone->flags, fw3_to_src_target(t)))
                        {
                                fw3_pr("-A zone_%s_src_%s", zone->name, fw3_flag_names[t]);
                                fw3_format_in_out(dev, NULL);
                        {
                                fw3_pr("-A zone_%s_src_%s", zone->name, fw3_flag_names[t]);
                                fw3_format_in_out(dev, NULL);
@@ -341,7 +341,7 @@ print_interface_rule(enum fw3_table table, enum fw3_family family,
                                fw3_pr(" -j %s\n", jump_target(t));
                        }
 
                                fw3_pr(" -j %s\n", jump_target(t));
                        }
 
-                       if (hasbit(zone->dst_flags, t))
+                       if (hasbit(zone->flags, t))
                        {
                                fw3_pr("-A zone_%s_dest_%s", zone->name, fw3_flag_names[t]);
                                fw3_format_in_out(NULL, dev);
                        {
                                fw3_pr("-A zone_%s_dest_%s", zone->name, fw3_flag_names[t]);
                                fw3_format_in_out(NULL, dev);
@@ -371,7 +371,7 @@ print_interface_rule(enum fw3_table table, enum fw3_family family,
        }
        else if (table == FW3_TABLE_NAT)
        {
        }
        else if (table == FW3_TABLE_NAT)
        {
-               if (hasbit(zone->dst_flags, FW3_TARGET_DNAT))
+               if (hasbit(zone->flags, FW3_TARGET_DNAT))
                {
                        fw3_pr("-A delegate_prerouting");
                        fw3_format_in_out(dev, NULL);
                {
                        fw3_pr("-A delegate_prerouting");
                        fw3_format_in_out(dev, NULL);
@@ -380,7 +380,7 @@ print_interface_rule(enum fw3_table table, enum fw3_family family,
                        fw3_pr(" -j zone_%s_prerouting\n", zone->name);
                }
 
                        fw3_pr(" -j zone_%s_prerouting\n", zone->name);
                }
 
-               if (hasbit(zone->dst_flags, FW3_TARGET_SNAT))
+               if (hasbit(zone->flags, FW3_TARGET_SNAT))
                {
                        fw3_pr("-A delegate_postrouting");
                        fw3_format_in_out(NULL, dev);
                {
                        fw3_pr("-A delegate_postrouting");
                        fw3_format_in_out(NULL, dev);
@@ -474,7 +474,7 @@ print_zone_rule(enum fw3_table table, enum fw3_family family,
                {
                        for (t = FW3_TARGET_REJECT; t <= FW3_TARGET_DROP; t++)
                        {
                {
                        for (t = FW3_TARGET_REJECT; t <= FW3_TARGET_DROP; t++)
                        {
-                               if (hasbit(zone->dst_flags, fw3_to_src_target(t)))
+                               if (hasbit(zone->flags, fw3_to_src_target(t)))
                                {
                                        fw3_pr("-A zone_%s_src_%s", zone->name, fw3_flag_names[t]);
                                        fw3_format_limit(&zone->log_limit);
                                {
                                        fw3_pr("-A zone_%s_src_%s", zone->name, fw3_flag_names[t]);
                                        fw3_format_limit(&zone->log_limit);
@@ -482,7 +482,7 @@ print_zone_rule(enum fw3_table table, enum fw3_family family,
                                                   fw3_flag_names[t], zone->name);
                                }
 
                                                   fw3_flag_names[t], zone->name);
                                }
 
-                               if (hasbit(zone->dst_flags, t))
+                               if (hasbit(zone->flags, t))
                                {
                                        fw3_pr("-A zone_%s_dest_%s", zone->name, fw3_flag_names[t]);
                                        fw3_format_limit(&zone->log_limit);
                                {
                                        fw3_pr("-A zone_%s_dest_%s", zone->name, fw3_flag_names[t]);
                                        fw3_format_limit(&zone->log_limit);
@@ -551,22 +551,22 @@ fw3_flush_zones(enum fw3_table table, enum fw3_family family,
 
        list_for_each_entry_safe(z, tmp, &state->running_zones, running_list)
        {
 
        list_for_each_entry_safe(z, tmp, &state->running_zones, running_list)
        {
-               if (!hasbit(z->dst_flags, family))
+               if (!hasbit(z->flags, family))
                        continue;
 
                print_chains(table, family, pass2 ? "-X %s\n" : "-F %s\n",
                        continue;
 
                print_chains(table, family, pass2 ? "-X %s\n" : "-F %s\n",
-                            z->name, z->running_dst_flags,
+                            z->name, z->running_flags,
                             src_chains, ARRAY_SIZE(src_chains));
 
                print_chains(table, family, pass2 ? "-X %s\n" : "-F %s\n",
                             src_chains, ARRAY_SIZE(src_chains));
 
                print_chains(table, family, pass2 ? "-X %s\n" : "-F %s\n",
-                            z->name, z->running_dst_flags & custom_mask,
+                            z->name, z->running_flags & custom_mask,
                             dst_chains, ARRAY_SIZE(dst_chains));
 
                if (pass2)
                {
                             dst_chains, ARRAY_SIZE(dst_chains));
 
                if (pass2)
                {
-                       delbit(z->dst_flags, family);
+                       delbit(z->flags, family);
 
 
-                       if (!(z->dst_flags & family_mask))
+                       if (!(z->flags & family_mask))
                                fw3_set_running(z, NULL);
                }
        }
                                fw3_set_running(z, NULL);
                }
        }