diff options
author | Eric Dumazet <edumazet@google.com> | 2016-08-22 14:31:10 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-08-23 19:55:49 -0400 |
commit | 20a2b49fc538540819a0c552877086548cff8d8d (patch) | |
tree | ee2139e2ca455ec54ba6ba83c3ca134c27bff1b7 /net/ipv4/tcp_ipv4.c | |
parent | 6c389fc931bcda88940c809f752ada6d7799482c (diff) |
tcp: properly scale window in tcp_v[46]_reqsk_send_ack()
When sending an ack in SYN_RECV state, we must scale the offered
window if wscale option was negotiated and accepted.
Tested:
Following packetdrill test demonstrates the issue :
0.000 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
+0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
+0 bind(3, ..., ...) = 0
+0 listen(3, 1) = 0
// Establish a connection.
+0 < S 0:0(0) win 20000 <mss 1000,sackOK,wscale 7, nop, TS val 100 ecr 0>
+0 > S. 0:0(0) ack 1 win 28960 <mss 1460,sackOK, TS val 100 ecr 100, nop, wscale 7>
+0 < . 1:11(10) ack 1 win 156 <nop,nop,TS val 99 ecr 100>
// check that window is properly scaled !
+0 > . 1:1(0) ack 1 win 226 <nop,nop,TS val 200 ecr 100>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Yuchung Cheng <ycheng@google.com>
Cc: Neal Cardwell <ncardwell@google.com>
Acked-by: Yuchung Cheng <ycheng@google.com>
Acked-by: Neal Cardwell <ncardwell@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/tcp_ipv4.c')
-rw-r--r-- | net/ipv4/tcp_ipv4.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 32b048e524d6..7158d4f8dae4 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c | |||
@@ -814,8 +814,14 @@ static void tcp_v4_reqsk_send_ack(const struct sock *sk, struct sk_buff *skb, | |||
814 | u32 seq = (sk->sk_state == TCP_LISTEN) ? tcp_rsk(req)->snt_isn + 1 : | 814 | u32 seq = (sk->sk_state == TCP_LISTEN) ? tcp_rsk(req)->snt_isn + 1 : |
815 | tcp_sk(sk)->snd_nxt; | 815 | tcp_sk(sk)->snd_nxt; |
816 | 816 | ||
817 | /* RFC 7323 2.3 | ||
818 | * The window field (SEG.WND) of every outgoing segment, with the | ||
819 | * exception of <SYN> segments, MUST be right-shifted by | ||
820 | * Rcv.Wind.Shift bits: | ||
821 | */ | ||
817 | tcp_v4_send_ack(sock_net(sk), skb, seq, | 822 | tcp_v4_send_ack(sock_net(sk), skb, seq, |
818 | tcp_rsk(req)->rcv_nxt, req->rsk_rcv_wnd, | 823 | tcp_rsk(req)->rcv_nxt, |
824 | req->rsk_rcv_wnd >> inet_rsk(req)->rcv_wscale, | ||
819 | tcp_time_stamp, | 825 | tcp_time_stamp, |
820 | req->ts_recent, | 826 | req->ts_recent, |
821 | 0, | 827 | 0, |