All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jesper Dangaard Brouer <brouer@redhat.com>
To: Pablo Neira Ayuso <pablo@netfilter.org>,
	"Patrick McHardy" <kaber@trash.net>
Cc: netfilter-devel@vger.kernel.org, netdev@vger.kernel.org,
	mph@one.com, as@one.com,
	Jesper Dangaard Brouer <brouer@redhat.com>
Subject: [nf-next PATCH] netfilter: Extend SYNPROXY with a --continue option
Date: Wed, 28 Aug 2013 17:26:55 +0200	[thread overview]
Message-ID: <20130828152549.8250.97982.stgit@dragon> (raw)

Packets reaching SYNPROXY are default dropped, as they are most likely
invalid (given the state matching).  In other configurations it might
be beneficial to let packet not consumed by SYNPROXY (SYN and ACK) to
continue being processed by the stack.

Introducing a --continue option/flag for the SYNPROXY target to allow
these unmatched packets to continue being processed.  This would also
help in debugging the module via LOG.

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
---
Comment:
 This patch depend on the one send earlier, and I also have the
 userspace iptables part ready, if this patch is received positively

 include/uapi/linux/netfilter/xt_SYNPROXY.h |    1 +
 net/ipv4/netfilter/ipt_SYNPROXY.c          |    9 ++++++++-
 net/ipv6/netfilter/ip6t_SYNPROXY.c         |    9 ++++++++-
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/include/uapi/linux/netfilter/xt_SYNPROXY.h b/include/uapi/linux/netfilter/xt_SYNPROXY.h
index 2d59fba..6b788bc 100644
--- a/include/uapi/linux/netfilter/xt_SYNPROXY.h
+++ b/include/uapi/linux/netfilter/xt_SYNPROXY.h
@@ -6,6 +6,7 @@
 #define XT_SYNPROXY_OPT_SACK_PERM	0x04
 #define XT_SYNPROXY_OPT_TIMESTAMP	0x08
 #define XT_SYNPROXY_OPT_ECN		0x10
+#define XT_SYNPROXY_OPT_CONTINUE	0x20
 
 struct xt_synproxy_info {
 	__u8	options;
diff --git a/net/ipv4/netfilter/ipt_SYNPROXY.c b/net/ipv4/netfilter/ipt_SYNPROXY.c
index 90e489e..3a09759 100644
--- a/net/ipv4/netfilter/ipt_SYNPROXY.c
+++ b/net/ipv4/netfilter/ipt_SYNPROXY.c
@@ -285,9 +285,16 @@ synproxy_tg4(struct sk_buff *skb, const struct xt_action_param *par)
 					  XT_SYNPROXY_OPT_ECN);
 
 		synproxy_send_client_synack(skb, th, &opts);
-	} else if (th->ack && !(th->fin || th->rst || th->syn))
+		return NF_DROP;
+
+	} else if (th->ack && !(th->fin || th->rst || th->syn)) {
 		/* ACK from client */
 		synproxy_recv_client_ack(snet, skb, th, &opts, ntohl(th->seq));
+		return NF_DROP;
+	}
+
+	if (info->options & XT_SYNPROXY_OPT_CONTINUE)
+		return XT_CONTINUE;
 
 	return NF_DROP;
 }
diff --git a/net/ipv6/netfilter/ip6t_SYNPROXY.c b/net/ipv6/netfilter/ip6t_SYNPROXY.c
index a5af0bf..02f41fa 100644
--- a/net/ipv6/netfilter/ip6t_SYNPROXY.c
+++ b/net/ipv6/netfilter/ip6t_SYNPROXY.c
@@ -300,9 +300,16 @@ synproxy_tg6(struct sk_buff *skb, const struct xt_action_param *par)
 					  XT_SYNPROXY_OPT_ECN);
 
 		synproxy_send_client_synack(skb, th, &opts);
-	} else if (th->ack && !(th->fin || th->rst || th->syn))
+		return NF_DROP;
+
+	} else if (th->ack && !(th->fin || th->rst || th->syn)) {
 		/* ACK from client */
 		synproxy_recv_client_ack(snet, skb, th, &opts, ntohl(th->seq));
+		return NF_DROP;
+	}
+
+	if (info->options & XT_SYNPROXY_OPT_CONTINUE)
+		return XT_CONTINUE;
 
 	return NF_DROP;
 }


             reply	other threads:[~2013-08-28 15:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-28 15:26 Jesper Dangaard Brouer [this message]
2013-08-28 16:00 ` [nf-next PATCH] netfilter: Extend SYNPROXY with a --continue option Patrick McHardy
2013-08-29  8:23   ` Jesper Dangaard Brouer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130828152549.8250.97982.stgit@dragon \
    --to=brouer@redhat.com \
    --cc=as@one.com \
    --cc=kaber@trash.net \
    --cc=mph@one.com \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.