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 158ccbffdcabce7b0522adf594576b22c28802c3..babf5e84ae3d1fdb5ff61eb021f0c9f496b41ff3 100644 (file)
@@ -88,7 +88,7 @@ fw3_load_forwards(struct fw3_state *state, struct uci_package *p)
 
                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))
index 202cd06f5636a73b8480b72b83d73d61cc60cce3..0bfb3e82daeeb87ec75edcf664e1fdc87641dfa5 100644 (file)
--- a/options.h
+++ b/options.h
@@ -279,11 +279,8 @@ struct fw3_zone
 
        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
index 2acfabc34cedad23a90a93450b896ac6aca83351..23dc0341c8cdff5440f6719f143fdd7418f3678c 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
                        {
-                               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)
                        {
-                               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
@@ -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
                        {
-                               setbit(redir->_dest->dst_flags, redir->target);
+                               setbit(redir->_dest->flags, redir->target);
                                redir->_dest->conntrack = true;
                                valid = true;
                        }
diff --git a/rules.c b/rules.c
index c3f03cf76377eba22235cf3fa873734ed3bcb965..77fe998f52edf6cb8dc4fae9e7d453c7989be46d 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)
-                       setbit(rule->_dest->dst_flags, rule->target);
+                       setbit(rule->_dest->flags, rule->target);
 
                list_add_tail(&rule->list, &state->rules);
                continue;
diff --git a/utils.c b/utils.c
index 9b383a35a414e764cad51a2b8d833deb3bb66b0d..ce9049ee289948b2044fa0765938b89086108402 100644 (file)
--- a/utils.c
+++ b/utils.c
@@ -405,7 +405,7 @@ fw3_read_statefile(void *state)
                                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;
 
@@ -464,7 +464,7 @@ fw3_write_statefile(void *state)
 
        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)
diff --git a/zones.c b/zones.c
index e3ec4abb178d230759ebb41d18ba483b1a1f86e2..c47391ca6b8cd7a9a64d29898d7afa86858e3daa 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)
                {
-                       setbit(zone->dst_flags, FW3_TARGET_SNAT);
+                       setbit(zone->flags, FW3_TARGET_SNAT);
                        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);
        }
@@ -285,30 +285,30 @@ print_zone_chain(enum fw3_table table, enum fw3_family family,
        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++)
-               if (hasbit(zone->running_dst_flags, f))
+               if (hasbit(zone->running_flags, f))
                        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)
-               setbit(zone->dst_flags, FW3_TARGET_NOTRACK);
+               setbit(zone->flags, FW3_TARGET_NOTRACK);
 
        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,
-                        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,
-                        zone->dst_flags,
+                        zone->flags,
                         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++)
                {
-                       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);
@@ -341,7 +341,7 @@ print_interface_rule(enum fw3_table table, enum fw3_family family,
                                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);
@@ -371,7 +371,7 @@ print_interface_rule(enum fw3_table table, enum fw3_family family,
        }
        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);
@@ -380,7 +380,7 @@ print_interface_rule(enum fw3_table table, enum fw3_family family,
                        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);
@@ -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++)
                        {
-                               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);
@@ -482,7 +482,7 @@ print_zone_rule(enum fw3_table table, enum fw3_family family,
                                                   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);
@@ -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)
        {
-               if (!hasbit(z->dst_flags, family))
+               if (!hasbit(z->flags, family))
                        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",
-                            z->name, z->running_dst_flags & custom_mask,
+                            z->name, z->running_flags & custom_mask,
                             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);
                }
        }