From patchwork Sun Jul 8 18:11:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [v2,3/6] netfilter: tarpit: Move XTTARPIT_RESET to its own function Date: Sun, 08 Jul 2012 08:11:22 -0000 From: Josh Hunt X-Patchwork-Id: 169658 Message-Id: <1341771085-5771-4-git-send-email-johunt@akamai.com> To: jengelh@inai.de, netfilter-devel@vger.kernel.org Cc: Josh Hunt Moves XTTARPIT_RESET into its own function. Signed-off-by: Josh Hunt --- extensions/xt_TARPIT.c | 21 +++++++++++++++------ 1 files changed, 15 insertions(+), 6 deletions(-) diff --git a/extensions/xt_TARPIT.c b/extensions/xt_TARPIT.c index 6c75184..5d8af70 100644 --- a/extensions/xt_TARPIT.c +++ b/extensions/xt_TARPIT.c @@ -133,6 +133,19 @@ static bool xttarpit_honeypot(struct tcphdr *oth, struct tcphdr *tcph, return true; } +static bool xttarpit_reset(struct tcphdr *oth, struct tcphdr *tcph) +{ + + tcph->window = 0; + tcph->ack = false; + tcph->syn = false; + tcph->rst = true; + tcph->seq = oth->ack_seq; + tcph->ack_seq = oth->seq; + + return true; +} + static void tarpit_tcp(struct sk_buff *oldskb, unsigned int hook, unsigned int mode) { @@ -205,12 +218,8 @@ static void tarpit_tcp(struct sk_buff *oldskb, unsigned int hook, if (!xttarpit_honeypot(oth, tcph, payload)) return; } else if (mode == XTTARPIT_RESET) { - tcph->window = 0; - tcph->ack = false; - tcph->syn = false; - tcph->rst = true; - tcph->seq = oth->ack_seq; - tcph->ack_seq = oth->seq; + if (!xttarpit_reset(oth, tcph)) + return; } /* Adjust TCP checksum */