Use zone_name_src_ACTION chain for input rules with non-wildcard source
authorJo-Philipp Wich <jow@openwrt.org>
Wed, 5 Jun 2013 10:49:17 +0000 (12:49 +0200)
committerJo-Philipp Wich <jow@openwrt.org>
Wed, 5 Jun 2013 10:55:09 +0000 (12:55 +0200)
rules.c

diff --git a/rules.c b/rules.c
index a251f7c46855cf46f10a6d8ad770e03dcab50a82..3f2ca68708a80a2b48342d325038960963dc4c66 100644 (file)
--- a/rules.c
+++ b/rules.c
@@ -200,6 +200,11 @@ fw3_load_rules(struct fw3_state *state, struct uci_package *p)
                        setbit(rule->_dest->flags[0], rule->target);
                        setbit(rule->_dest->flags[1], rule->target);
                }
+               else if (rule->_src)
+               {
+                       setbit(rule->_src->flags[0], fw3_to_src_target(rule->target));
+                       setbit(rule->_src->flags[1], fw3_to_src_target(rule->target));
+               }
 
                list_add_tail(&rule->list, &state->rules);
                continue;
@@ -274,21 +279,24 @@ static void set_target(struct fw3_ipt_rule *r, struct fw3_rule *rule)
                fw3_ipt_rule_addarg(r, false, name, buf);
                return;
 
+       case FW3_FLAG_NOTRACK:
+               fw3_ipt_rule_target(r, fw3_flag_names[rule->target]);
+               return;
+
        case FW3_FLAG_ACCEPT:
        case FW3_FLAG_DROP:
-       case FW3_FLAG_NOTRACK:
                name = fw3_flag_names[rule->target];
                break;
 
        default:
-               name = fw3_flag_names[FW3_FLAG_REJECT];
+               name = "reject";
                break;
        }
 
        if (rule->dest.set && !rule->dest.any)
                fw3_ipt_rule_target(r, "zone_%s_dest_%s", rule->dest.name, name);
-       else if (rule->target == FW3_FLAG_REJECT)
-               fw3_ipt_rule_target(r, "reject");
+       else if (rule->src.set && !rule->src.any)
+               fw3_ipt_rule_target(r, "zone_%s_src_%s", rule->src.name, name);
        else
                fw3_ipt_rule_target(r, name);
 }