Skip to contentSkip to conversation

Netfilter SYNPROXY mss and wscale bugfix

PATCH Applied Martin Topholm 3 participants 6 messages Nov 14, 2013 – Nov 19, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Netfilter SYNPROXY mss and wscale bugfix

The following series fixes two bugs we have discovered in the netfilter module SYNPROXY.

The first is related to the mss option not getting transferred to the backend servers.

And the second it related to passing of the windows scaling option.

Martin Topholm (2):
netfilter: synproxy: send mss option to backend
netfilter: synproxy: correct wscale option passing

 net/ipv4/netfilter/ipt_SYNPROXY.c  | 1 +
 net/ipv6/netfilter/ip6t_SYNPROXY.c | 1 +
 net/netfilter/nf_synproxy_core.c   | 7 ++++---
 3 files changed, 6 insertions(+), 3 deletions(-)
#1 lore raw

PATCH 1/2 netfilter: synproxy: send mss option to backend

When the synproxy_parse_options is called on the client ack the mss option will not be present. Consequently mss wont be included in the backend syn packet, which falls back to 536 bytes mss.

Therefore XT_SYNPROXY_OPT_MSS is explicitly flagged when recovering mss value from cookie.

---
 net/ipv4/netfilter/ipt_SYNPROXY.c  | 1 +
 net/ipv6/netfilter/ip6t_SYNPROXY.c | 1 +
 2 files changed, 2 insertions(+)
net/ipv4/netfilter/ipt_SYNPROXY.c +1 -0
index 01cffea..f13bd91 100644
@@ -244,6 +244,7 @@ synproxy_recv_client_ack(const struct synproxy_net *snet,
 
 	this_cpu_inc(snet->stats->cookie_valid);
 	opts->mss = mss;
+	opts->options |= XT_SYNPROXY_OPT_MSS;
 
 	if (opts->options & XT_SYNPROXY_OPT_TIMESTAMP)
 		synproxy_check_timestamp_cookie(opts);
net/ipv6/netfilter/ip6t_SYNPROXY.c +1 -0
index bf9f612..f78f41a 100644
@@ -259,6 +259,7 @@ synproxy_recv_client_ack(const struct synproxy_net *snet,
 
 	this_cpu_inc(snet->stats->cookie_valid);
 	opts->mss = mss;
+	opts->options |= XT_SYNPROXY_OPT_MSS;
 
 	if (opts->options & XT_SYNPROXY_OPT_TIMESTAMP)
 		synproxy_check_timestamp_cookie(opts);
maintainer Applied
#2 lore raw

Re: [PATCH 1/2] netfilter: synproxy: send mss option to backend

Quoted 6 lines · Martin Topholm

When the synproxy_parse_options is called on the client ack the mss option will not be present. Consequently mss wont be included in the backend syn packet, which falls back to 536 bytes mss.

Therefore XT_SYNPROXY_OPT_MSS is explicitly flagged when recovering mss value from cookie.

Applied, thanks Martin.

#3 lore raw

PATCH 2/2 netfilter: synproxy: correct wscale option passing

In reply to Martin Topholm

Timestamp are used to store additional syncookie parameters such as sack, ecn, and wscale. The wscale value we need to encode is the client's wscale, since we can't recover that later in the session. Next overwrite the wscale option so the later synproxy_send_client_synack will send the backend's wscale to the client.

---
 net/netfilter/nf_synproxy_core.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
net/netfilter/nf_synproxy_core.c +4 -3
index cdf4567..9858e3e 100644
@@ -151,9 +151,10 @@ void synproxy_init_timestamp_cookie(const struct xt_synproxy_info *info,
 	opts->tsecr = opts->tsval;
 	opts->tsval = tcp_time_stamp & ~0x3f;
 
-	if (opts->options & XT_SYNPROXY_OPT_WSCALE)
-		opts->tsval |= info->wscale;
-	else
+	if (opts->options & XT_SYNPROXY_OPT_WSCALE) {
+		opts->tsval |= opts->wscale;
+		opts->wscale = info->wscale;
+	} else
 		opts->tsval |= 0xf;
 
 	if (opts->options & XT_SYNPROXY_OPT_SACK_PERM)
#4 lore raw

Re: [PATCH 2/2] netfilter: synproxy: correct wscale option passing

Quoted 5 lines · Martin Topholm

Timestamp are used to store additional syncookie parameters such as sack, ecn, and wscale. The wscale value we need to encode is the client's wscale, since we can't recover that later in the session. Next overwrite the wscale option so the later synproxy_send_client_synack will send the backend's wscale to the client.

Also applied, thanks.

#5 lore raw
In reply to Martin Topholm
Quoted 8 lines · On Thu, 14 Nov 2013 15:35:29 +0100 Martin Topholm <[email protected]> wrote:

The following series fixes two bugs we have discovered in the netfilter module SYNPROXY.

The first is related to the mss option not getting transferred to the backend servers.

And the second it related to passing of the windows scaling option.

Quoted 8 lines

Martin Topholm (2):
netfilter: synproxy: send mss option to backend
netfilter: synproxy: correct wscale option passing

 net/ipv4/netfilter/ipt_SYNPROXY.c  | 1 +
 net/ipv6/netfilter/ip6t_SYNPROXY.c | 1 +
 net/netfilter/nf_synproxy_core.c   | 7 ++++---
 3 files changed, 6 insertions(+), 3 deletions(-)

ACK series

I have already reviewed the patches offlist with Martin and helped him on howto submit patches etc.. Nice work Martin :-)

Signature · 5 lines
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Sr. Network Kernel Developer at Red Hat
  Author of http://www.iptv-analyzer.org
  LinkedIn: http://www.linkedin.com/in/brouer