Netdev List
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: David Miller <davem@davemloft.net>
Cc: leandroal@gmail.com, netdev@vger.kernel.org,
	"Ilpo Järvinen" <ilpo.jarvinen@helsinki.fi>
Subject: Re: TCP packet size and delivery packet decisions
Date: Tue, 07 Sep 2010 13:39:12 +0200	[thread overview]
Message-ID: <1283859552.2338.402.camel@edumazet-laptop> (raw)
In-Reply-To: <20100906.223010.173858342.davem@davemloft.net>

Le lundi 06 septembre 2010 à 22:30 -0700, David Miller a écrit :


> The small 78 byte window is why the sending system is splitting up the
> writes into smaller pieces.
> 
> I presume that the system advertises exactly a 78 byte window because
> this is how large the commands are.  But this is an extremely foolish
> and baroque thing to do, and it's why you are having problems.

I am not sure why TSO added a "Bound mss with half of window"
requirement for tcp_sync_mss()

I tried with MSS=1000 and WIN=1000, and segment size chosen is 500

With WIN=78, 78/2->39 is then capped to 48 (68U - tp->tcp_header_len)

Is there a hard requirement about segment size being at most half the
window ?

Following patch solves the problem for me :

[PATCH] tcp: bound mss to window in tcp_sync_mss()

Leandro Melo de Sales noticed that if a peer announces a very small
initial tcp window (78 in his case), first sent frames have unnecessary
small lengths (48 in his case)

CLNT->SRV    [SYN] Seq=0 Win=5840 Len=0 MSS=1460
SRV->CLNT    [SYN, ACK] Seq=0 Ack=1 Win=78 Len=0 MSS=78
CLNT->SRV    [ACK] Seq=1 Ack=1 Win=5840 Len=0
CLNT->SRV    [PSH, ACK] Seq=1 Ack=1 Win=5840 Len=48
CLNT->SRV    [PSH, ACK] Seq=49 Ack=1 Win=5840 Len=30
SRV->CLNT    [ACK] Seq=1 Ack=49 Win=78 Len=0
SRV->CLNT    [RST, ACK] Seq=1 Ack=79 Win=78 Len=0

tcp_sync_mss() bounds mss to half the window, while it could use full
window:

CLNT->SRV    [SYN] Seq=0 Win=5840 Len=0 MSS=1460
SRV->CLNT    [SYN, ACK] Seq=0 Ack=1 Win=78 Len=0 MSS=78
CLNT->SRV    [ACK] Seq=1 Ack=1 Win=5840 Len=0
CLNT->SRV    [PSH, ACK] Seq=1 Ack=1 Win=5840 Len=78
SRV->CLNT    [ACK] Seq=1 Ack=79 Win=78 Len=0

Reported-by: ツ Leandro Melo de Sales <leandroal@gmail.com>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>
---
 include/net/tcp.h     |    9 +++++++++
 net/ipv4/tcp_output.c |    2 +-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/include/net/tcp.h b/include/net/tcp.h
index eaa9582..c262676 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -481,6 +481,15 @@ static inline int tcp_bound_to_half_wnd(struct tcp_sock *tp, int pktsize)
 		return pktsize;
 }
 
+/* Bound MSS / TSO packet size with the window */
+static inline int tcp_bound_to_wnd(struct tcp_sock *tp, int pktsize)
+{
+	if (tp->max_window && pktsize > tp->max_window)
+		return max(tp->max_window, 68U - tp->tcp_header_len);
+	else
+		return pktsize;
+}
+
 /* tcp.c */
 extern void tcp_get_info(struct sock *, struct tcp_info *);
 
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index de3bd84..49cdbe4 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -1224,7 +1224,7 @@ unsigned int tcp_sync_mss(struct sock *sk, u32 pmtu)
 		icsk->icsk_mtup.search_high = pmtu;
 
 	mss_now = tcp_mtu_to_mss(sk, pmtu);
-	mss_now = tcp_bound_to_half_wnd(tp, mss_now);
+	mss_now = tcp_bound_to_wnd(tp, mss_now);
 
 	/* And store cached results */
 	icsk->icsk_pmtu_cookie = pmtu;



  parent reply	other threads:[~2010-09-07 11:39 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <AANLkTi=_heUejVf-wmEcKd910gVtpD7Hr=cZ_cs2Q8n9@mail.gmail.com>
2010-09-07  4:20 ` TCP packet size and delivery packet decisions ツ Leandro Melo de Sales
2010-09-07  4:36   ` Eric Dumazet
2010-09-07  5:13     ` ツ Leandro Melo de Sales
2010-09-07  5:16       ` David Miller
2010-09-07  5:21         ` ツ Leandro Melo de Sales
2010-09-07  5:30           ` David Miller
2010-09-07  6:02             ` ツ Leandro Melo de Sales
2010-09-07  6:09               ` Eric Dumazet
2010-09-07  7:16                 ` ツ Leandro Melo de Sales
2010-09-07  7:32                   ` Eric Dumazet
2010-09-08 14:01                     ` ツ Leandro Melo de Sales
2010-09-07 11:39             ` Eric Dumazet [this message]
2010-09-07 12:15               ` Ilpo Järvinen
2010-09-08  3:18                 ` David Miller
2010-09-08 12:14                   ` Alexey Kuznetsov
2010-09-13  1:23                     ` David Miller
2010-09-14  9:37                       ` Alexey Kuznetsov
2010-09-15 17:29                         ` David Miller
2010-09-07 16:35               ` David Miller
2010-09-07 16:57               ` Rick Jones
2010-09-08 14:06               ` ツ Leandro Melo de Sales
2010-09-08 15:24                 ` David Miller
2010-09-08 16:03                   ` ツ Leandro Melo de Sales

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=1283859552.2338.402.camel@edumazet-laptop \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=ilpo.jarvinen@helsinki.fi \
    --cc=leandroal@gmail.com \
    --cc=netdev@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox