From aeba5741d7ed3b53fb4f1bb3679feb0fa526f4c6 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Thu, 6 Jun 2013 11:40:02 +0200 Subject: [PATCH] For ingress rules, only jump into zone_name_src_ACTION chains if the target is not ACCEPT and if logging is enabled in the src zone, this cuts some overhead --- rules.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/rules.c b/rules.c index 3f2ca68..4750af7 100644 --- 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); -- 2.25.1