From patchwork Mon Aug 31 17:44:56 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Octavian Purdila X-Patchwork-Id: 32672 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@bilbo.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (ozlabs.org [203.10.76.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx.ozlabs.org", Issuer "CA Cert Signing Authority" (verified OK)) by bilbo.ozlabs.org (Postfix) with ESMTPS id 619F5B708C for ; Tue, 1 Sep 2009 03:47:25 +1000 (EST) Received: by ozlabs.org (Postfix) id 48413DDD0C; Tue, 1 Sep 2009 03:47:25 +1000 (EST) Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 5344CDDD0B for ; Tue, 1 Sep 2009 03:47:24 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753575AbZHaRrP (ORCPT ); Mon, 31 Aug 2009 13:47:15 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753415AbZHaRrP (ORCPT ); Mon, 31 Aug 2009 13:47:15 -0400 Received: from ixro-out-rtc.ixiacom.com ([92.87.192.98]:17327 "EHLO ixro-ex1.ixiacom.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753301AbZHaRrO (ORCPT ); Mon, 31 Aug 2009 13:47:14 -0400 Received: from ixro-opurdila-lap.localnet ([10.205.9.70]) by ixro-ex1.ixiacom.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 31 Aug 2009 20:47:15 +0300 Subject: [PATCH] [net-next] tcp: avoid sending zero TSval From: Octavian Purdila Organization: Ixia To: netdev@vger.kernel.org Date: Mon, 31 Aug 2009 20:44:56 +0300 MIME-Version: 1.0 Message-Id: <200908312044.56235.opurdila@ixiacom.com> X-OriginalArrivalTime: 31 Aug 2009 17:47:15.0777 (UTC) FILETIME=[13EAE310:01CA2A63] Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Per RFC1323, zero TSecr is considered invalid. Thus we must avoid when possible sending a zero TSval. Currently, we use the least significant 32 bits of jiffies to fill in TSval. But that can wrap around to zero (in 5 minutes after reboot, and every 49 days after that in the worst case). This patch approximate a wrap-around zero TSval to 1. This is better then emitting a value which will be ignored. Signed-off-by: Octavian Purdila --- net/ipv4/tcp_output.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 4e00442..607d675 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -415,7 +415,10 @@ static void tcp_options_write(__be32 *ptr, struct tcp_sock *tp, (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP); } - *ptr++ = htonl(opts->tsval); + /* Currently, opts->tsval always comes from tcp_time_stamp. + * Thus, if zero, its caused by jiffie wrap-around, and we can + * approximate it to one to avoid a later TSecr drop */ + *ptr++ = htonl(opts->tsval?:1); *ptr++ = htonl(opts->tsecr); }