Patchwork [v2,3/6] netfilter: tarpit: Move XTTARPIT_RESET to its own function

login
register
mail settings
Submitter Josh Hunt
Date July 8, 2012, 6:11 p.m.
Message ID <1341771085-5771-4-git-send-email-johunt@akamai.com>
Download mbox | patch
Permalink /patch/169658/
State Superseded
Headers show

Comments

Josh Hunt - July 8, 2012, 6:11 p.m.
Moves XTTARPIT_RESET into its own function.

Signed-off-by: Josh Hunt <johunt@akamai.com>
---
 extensions/xt_TARPIT.c |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)

Patch

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 */