For ingress rules, only jump into zone_name_src_ACTION chains if the target is not...
authorJo-Philipp Wich <jow@openwrt.org>
Thu, 6 Jun 2013 09:40:02 +0000 (11:40 +0200)
committerJo-Philipp Wich <jow@openwrt.org>
Thu, 6 Jun 2013 09:50:06 +0000 (11:50 +0200)
rules.c

diff --git a/rules.c b/rules.c
index 3f2ca68708a80a2b48342d325038960963dc4c66..4750af7ef2d9dee6050d567c7c15c633a030ae54 100644 (file)
--- a/rules.c
+++ b/rules.c
@@ -63,6 +63,12 @@ const struct fw3_option fw3_rule_opts[] = {
 };
 
 
+static bool
+need_src_action_chain(struct fw3_rule *r)
+{
+       return (r->_src && r->_src->log && (r->target > FW3_FLAG_ACCEPT));
+}
+
 void
 fw3_load_rules(struct fw3_state *state, struct uci_package *p)
 {
@@ -200,7 +206,7 @@ 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)
+               else if (need_src_action_chain(rule))
                {
                        setbit(rule->_src->flags[0], fw3_to_src_target(rule->target));
                        setbit(rule->_src->flags[1], fw3_to_src_target(rule->target));
@@ -295,7 +301,7 @@ static void set_target(struct fw3_ipt_rule *r, struct fw3_rule *rule)
 
        if (rule->dest.set && !rule->dest.any)
                fw3_ipt_rule_target(r, "zone_%s_dest_%s", rule->dest.name, name);
-       else if (rule->src.set && !rule->src.any)
+       else if (need_src_action_chain(rule))
                fw3_ipt_rule_target(r, "zone_%s_src_%s", rule->src.name, name);
        else
                fw3_ipt_rule_target(r, name);