netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tcp: restore rcv_wscale in a repair mode (v2)
@ 2012-09-19 19:40 Andrew Vagin
  2012-09-20  9:31 ` Pavel Emelyanov
  2012-09-20 21:50 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Andrew Vagin @ 2012-09-19 19:40 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, Andrew Vagin, David S. Miller, Alexey Kuznetsov,
	James Morris, Hideaki YOSHIFUJI, Patrick McHardy, Pavel Emelyanov

rcv_wscale is a symetric parameter with snd_wscale.

Both this parameters are set on a connection handshake.

Without this value a remote window size can not be interpreted correctly,
because a value from a packet should be shifted on rcv_wscale.

And one more thing is that wscale_ok should be set too.

This patch doesn't break a backward compatibility.
If someone uses it in a old scheme, a rcv window
will be restored with the same bug (rcv_wscale = 0).

v2: Save backward compatibility on big-endian system. Before
    the first two bytes were snd_wscale and the second two bytes were
    rcv_wscale. Now snd_wscale is opt_val & 0xFFFF and rcv_wscale >> 16.
    This approach is independent on byte ordering.

Cc: David S. Miller <davem@davemloft.net>
Cc: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
Cc: James Morris <jmorris@namei.org>
Cc: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>
Cc: Patrick McHardy <kaber@trash.net>
CC: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Andrew Vagin <avagin@openvz.org>
---
 net/ipv4/tcp.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index df83d74..42689aa 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2348,10 +2348,17 @@ static int tcp_repair_options_est(struct tcp_sock *tp,
 			tp->rx_opt.mss_clamp = opt.opt_val;
 			break;
 		case TCPOPT_WINDOW:
-			if (opt.opt_val > 14)
-				return -EFBIG;
+			{
+				u16 snd_wscale = opt.opt_val & 0xFFFF;
+				u16 rcv_wscale = opt.opt_val >> 16;
+
+				if (snd_wscale > 14 || rcv_wscale > 14)
+					return -EFBIG;
 
-			tp->rx_opt.snd_wscale = opt.opt_val;
+				tp->rx_opt.snd_wscale = snd_wscale;
+				tp->rx_opt.rcv_wscale = rcv_wscale;
+				tp->rx_opt.wscale_ok = 1;
+			}
 			break;
 		case TCPOPT_SACK_PERM:
 			if (opt.opt_val != 0)
-- 
1.7.1

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

* Re: [PATCH] tcp: restore rcv_wscale in a repair mode (v2)
  2012-09-19 19:40 [PATCH] tcp: restore rcv_wscale in a repair mode (v2) Andrew Vagin
@ 2012-09-20  9:31 ` Pavel Emelyanov
  2012-09-20 21:50 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Pavel Emelyanov @ 2012-09-20  9:31 UTC (permalink / raw)
  To: David S. Miller
  Cc: Andrew Vagin, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, Alexey Kuznetsov, James Morris,
	Hideaki YOSHIFUJI, Patrick McHardy

On 09/19/2012 11:40 PM, Andrew Vagin wrote:
> rcv_wscale is a symetric parameter with snd_wscale.
> 
> Both this parameters are set on a connection handshake.
> 
> Without this value a remote window size can not be interpreted correctly,
> because a value from a packet should be shifted on rcv_wscale.
> 
> And one more thing is that wscale_ok should be set too.
> 
> This patch doesn't break a backward compatibility.
> If someone uses it in a old scheme, a rcv window
> will be restored with the same bug (rcv_wscale = 0).
> 
> v2: Save backward compatibility on big-endian system. Before
>     the first two bytes were snd_wscale and the second two bytes were
>     rcv_wscale. Now snd_wscale is opt_val & 0xFFFF and rcv_wscale >> 16.
>     This approach is independent on byte ordering.
> 
> Cc: David S. Miller <davem@davemloft.net>
> Cc: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
> Cc: James Morris <jmorris@namei.org>
> Cc: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>
> Cc: Patrick McHardy <kaber@trash.net>
> CC: Pavel Emelyanov <xemul@parallels.com>
> Signed-off-by: Andrew Vagin <avagin@openvz.org>

Acked-by: Pavel Emelyanov <xemul@parallels.com>

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

* Re: [PATCH] tcp: restore rcv_wscale in a repair mode (v2)
  2012-09-19 19:40 [PATCH] tcp: restore rcv_wscale in a repair mode (v2) Andrew Vagin
  2012-09-20  9:31 ` Pavel Emelyanov
@ 2012-09-20 21:50 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2012-09-20 21:50 UTC (permalink / raw)
  To: avagin; +Cc: netdev, linux-kernel, kuznet, jmorris, yoshfuji, kaber, xemul

From: Andrew Vagin <avagin@openvz.org>
Date: Wed, 19 Sep 2012 23:40:00 +0400

> rcv_wscale is a symetric parameter with snd_wscale.
> 
> Both this parameters are set on a connection handshake.
> 
> Without this value a remote window size can not be interpreted correctly,
> because a value from a packet should be shifted on rcv_wscale.
> 
> And one more thing is that wscale_ok should be set too.
> 
> This patch doesn't break a backward compatibility.
> If someone uses it in a old scheme, a rcv window
> will be restored with the same bug (rcv_wscale = 0).
> 
> v2: Save backward compatibility on big-endian system. Before
>     the first two bytes were snd_wscale and the second two bytes were
>     rcv_wscale. Now snd_wscale is opt_val & 0xFFFF and rcv_wscale >> 16.
>     This approach is independent on byte ordering.
> 
> Cc: David S. Miller <davem@davemloft.net>
> Cc: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
> Cc: James Morris <jmorris@namei.org>
> Cc: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>
> Cc: Patrick McHardy <kaber@trash.net>
> CC: Pavel Emelyanov <xemul@parallels.com>
> Signed-off-by: Andrew Vagin <avagin@openvz.org>

Applied, thanks.

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

end of thread, other threads:[~2012-09-20 21:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-19 19:40 [PATCH] tcp: restore rcv_wscale in a repair mode (v2) Andrew Vagin
2012-09-20  9:31 ` Pavel Emelyanov
2012-09-20 21:50 ` 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).