netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tcp: fix tcp header size miscalculation when window scale is unused
@ 2008-08-23 17:18 Philip Love
  2008-08-23 17:20 ` Adam Langley
  2008-08-24  4:40 ` David Miller
  0 siblings, 2 replies; 7+ messages in thread
From: Philip Love @ 2008-08-23 17:18 UTC (permalink / raw)
  To: netdev

tcp: fix tcp header size miscalculation when window scale is unused

The size of the TCP header is miscalculated when the window scale ends  
up being
0. Additionally, this can be induced by sending a SYN to a passive  
open port
with a window scale option with value 0.

Signed-off-by: Philip Love <love_phil@emc.com>

---

net/ipv4/tcp_output.c |    6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index a00532d..71eea00 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -468,7 +468,8 @@ static unsigned tcp_syn_options(struct sock *sk,  
struct sk_buff *skb,
	}
	if (likely(sysctl_tcp_window_scaling)) {
		opts->ws = tp->rx_opt.rcv_wscale;
-		size += TCPOLEN_WSCALE_ALIGNED;
+		if (likely(opts->ws))
+			size += TCPOLEN_WSCALE_ALIGNED;
	}
	if (likely(sysctl_tcp_sack)) {
		opts->options |= OPTION_SACK_ADVERTISE;
@@ -509,7 +510,8 @@ static unsigned tcp_synack_options(struct sock *sk,

	if (likely(ireq->wscale_ok)) {
		opts->ws = ireq->rcv_wscale;
-		size += TCPOLEN_WSCALE_ALIGNED;
+		if (likely(opts->ws))
+			size += TCPOLEN_WSCALE_ALIGNED;
	}
	if (likely(doing_ts)) {
		opts->options |= OPTION_TS;

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-08-25 21:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-23 17:18 [PATCH] tcp: fix tcp header size miscalculation when window scale is unused Philip Love
2008-08-23 17:20 ` Adam Langley
2008-08-24  4:40 ` David Miller
2008-08-24 17:40   ` Adam Langley
2008-08-25  0:45     ` David Miller
2008-08-25 16:30       ` Phil Love
2008-08-25 21:07         ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).