Implement limit and limit_burst options for rules.
authorJo-Philipp Wich <jow@openwrt.org>
Thu, 6 Jun 2013 09:37:00 +0000 (11:37 +0200)
committerJo-Philipp Wich <jow@openwrt.org>
Thu, 6 Jun 2013 09:50:00 +0000 (11:50 +0200)
options.h
redirects.c

index 33c5d1449c2346ac97dc08cd7a9b2e70cb32e892..558013bd90ea2b9000f04f99f2b0da095278dff5 100644 (file)
--- a/options.h
+++ b/options.h
@@ -381,6 +381,7 @@ struct fw3_redirect
        struct fw3_address ip_redir;
        struct fw3_port port_redir;
 
+       struct fw3_limit limit;
        struct fw3_time time;
        struct fw3_mark mark;
 
index 6d33f905ffbddc1c662dd689fb4e5c5a92ca8768..e5945f048ef94b74e0b543b34bae3ea8832ff77d 100644 (file)
@@ -44,6 +44,9 @@ const struct fw3_option fw3_redirect_opts[] = {
 
        FW3_OPT("extra",               string,    redirect,     extra),
 
+       FW3_OPT("limit",               limit,     redirect,     limit),
+       FW3_OPT("limit_burst",         int,       redirect,     limit.burst),
+
        FW3_OPT("utc_time",            bool,      redirect,     time.utc),
        FW3_OPT("start_date",          date,      redirect,     time.datestart),
        FW3_OPT("stop_date",           date,      redirect,     time.datestop),
@@ -445,6 +448,7 @@ print_redirect(struct fw3_ipt_handle *h, struct fw3_state *state,
                fw3_ipt_rule_sport_dport(r, spt, dpt);
                fw3_ipt_rule_mac(r, mac);
                fw3_ipt_rule_ipset(r, &redir->ipset);
+               fw3_ipt_rule_limit(r, &redir->limit);
                fw3_ipt_rule_time(r, &redir->time);
                fw3_ipt_rule_mark(r, &redir->mark);
                set_target_nat(r, redir);
@@ -463,6 +467,7 @@ print_redirect(struct fw3_ipt_handle *h, struct fw3_state *state,
                fw3_ipt_rule_sport_dport(r, spt, dpt);
                fw3_ipt_rule_mac(r, mac);
                fw3_ipt_rule_ipset(r, &redir->ipset);
+               fw3_ipt_rule_limit(r, &redir->limit);
                fw3_ipt_rule_time(r, &redir->time);
                fw3_ipt_rule_mark(r, &redir->mark);
                set_target_filter(r, redir);
@@ -489,6 +494,7 @@ print_reflection(struct fw3_ipt_handle *h, struct fw3_state *state,
        case FW3_TABLE_NAT:
                r = fw3_ipt_rule_create(h, proto, NULL, NULL, ia, ea);
                fw3_ipt_rule_sport_dport(r, NULL, &redir->port_dest);
+               fw3_ipt_rule_limit(r, &redir->limit);
                fw3_ipt_rule_time(r, &redir->time);
                set_comment(r, redir->name, num, true);
                set_snat_dnat(r, FW3_FLAG_DNAT, &redir->ip_redir, &redir->port_redir);
@@ -496,6 +502,7 @@ print_reflection(struct fw3_ipt_handle *h, struct fw3_state *state,
 
                r = fw3_ipt_rule_create(h, proto, NULL, NULL, ia, &redir->ip_redir);
                fw3_ipt_rule_sport_dport(r, NULL, &redir->port_redir);
+               fw3_ipt_rule_limit(r, &redir->limit);
                fw3_ipt_rule_time(r, &redir->time);
                set_comment(r, redir->name, num, true);
                set_snat_dnat(r, FW3_FLAG_SNAT, ra, NULL);
@@ -505,6 +512,7 @@ print_reflection(struct fw3_ipt_handle *h, struct fw3_state *state,
        case FW3_TABLE_FILTER:
                r = fw3_ipt_rule_create(h, proto, NULL, NULL, ia, &redir->ip_redir);
                fw3_ipt_rule_sport_dport(r, NULL, &redir->port_redir);
+               fw3_ipt_rule_limit(r, &redir->limit);
                fw3_ipt_rule_time(r, &redir->time);
                set_comment(r, redir->name, num, true);
                fw3_ipt_rule_target(r, "zone_%s_dest_ACCEPT", redir->dest.name);