From nobody@FreeBSD.org  Sun May  6 16:02:55 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 343261065673
	for <freebsd-gnats-submit@FreeBSD.org>; Sun,  6 May 2012 16:02:55 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 1BF338FC1E
	for <freebsd-gnats-submit@FreeBSD.org>; Sun,  6 May 2012 16:02:55 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q46G2siZ009029
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 6 May 2012 16:02:54 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id q46G2rOj009028;
	Sun, 6 May 2012 16:02:54 GMT
	(envelope-from nobody)
Message-Id: <201205061602.q46G2rOj009028@red.freebsd.org>
Date: Sun, 6 May 2012 16:02:54 GMT
From: Martin Birgmeier <Martin.Birgmeier@aon.at>
To: freebsd-gnats-submit@FreeBSD.org
Subject: IPv6 TCP connection hangs/drops when time/clock on the client is stepped backwards
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         167646
>Category:       kern
>Synopsis:       [ip6] IPv6 TCP connection hangs/drops when time/clock on the client is stepped backwards
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    hrs
>State:          analyzed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun May 06 16:10:11 UTC 2012
>Closed-Date:    
>Last-Modified:  Thu May 17 17:40:01 UTC 2012
>Originator:     Martin Birgmeier
>Release:        9.0.0, 8.2.0
>Organization:
MBi at home
>Environment:
X server running on:
FreeBSD mizar-v1.xyzzy 9.0-RELEASE FreeBSD 9.0-RELEASE #2: Sun Apr  1 19:48:11 CEST 2012     root@mizar.xyzzy:/usr/obj/.../hal/z/SRC/FreeBSD/release/9.0.0/sys/XYZZY_SMP  amd64

Client running on:
FreeBSD hal.xyzzy 8.2-RELEASE FreeBSD 8.2-RELEASE #4: Sat Aug 27 09:30:11 CEST 2011     root@hal.xyzzy:/z/OBJ/FreeBSD/amd64/RELENG_8_2_0_RELEASE/src/sys/XYZZY_SMP  amd64
>Description:
I am using xterm over IPv6. The client is 8.2.0 and runs several xterms which connect to the X server on 9.0.0. When a backward time step happens on the client, some of the TCPv6 connections get stuck (the affected xterm windows do not refresh any more) and are ultimately lost.

For me, this can happen when ntpd steps the time on the client (it happened twice today, when the first and the third time step occurred):
[0]# grep ntp /var/log/messages
..
May  6 08:34:56 hal ntpd[965]: time reset -0.354682 s
May  6 08:34:56 hal ntpd[965]: kernel time sync status change 2001
May  6 11:58:33 hal ntpd[965]: time reset -0.148885 s
May  6 11:58:33 hal ntpd[965]: kernel time sync status change 6001
May  6 12:02:53 hal ntpd[965]: kernel time sync status change 2001
May  6 17:35:29 hal ntpd[965]: time reset -0.274529 s

It seems that connections via IPv4 are not affected (not fully sure about that).

This is not limited to xterm sessions, see https://bugs.freedesktop.org/show_bug.cgi?id=23325 As can be seen, this problem seems to exist since quite some time.

>How-To-Repeat:
Establish an IPv6 xterm connection. Step the time on the client (where the xterm runs) backwards.
>Fix:


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-net 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Mon May 7 18:53:38 UTC 2012 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=167646 
State-Changed-From-To: open->analyzed 
State-Changed-By: hrs 
State-Changed-When: Thu May 10 23:42:14 UTC 2012 
State-Changed-Why:  
I'll take this. 


Responsible-Changed-From-To: freebsd-net->hrs 
Responsible-Changed-By: hrs 
Responsible-Changed-When: Thu May 10 23:42:14 UTC 2012 
Responsible-Changed-Why:  
I'll take this. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=167646 

From: "Bjoern A. Zeeb" <bz@FreeBSD.org>
To: bug-followup@FreeBSD.org, Martin.Birgmeier@aon.at
Cc:  
Subject: Re: kern/167646: [ip6] IPv6 TCP connection hangs/drops when time/clock
 on the client is stepped backwards
Date: Wed, 16 May 2012 00:01:03 +0000 (UTC)

 Hi,
 
 the problem has been known for a while; the problem is the "time" used
 depending on the real time clock rather than on something monotonically
 increasing.
 
 The TCP connections can come back (quickly) btw. as new RA/NS/NA
 cycles are ondergone.
 
 -- 
 Bjoern A. Zeeb                                 You have to have visions!
           Stop bit received. Insert coin for new address family.

From: Hiroki Sato <hrs@FreeBSD.org>
To: Martin.Birgmeier@aon.at, bz@FreeBSD.org
Cc: bug-followup@FreeBSD.org
Subject: Re: kern/167646: [ip6] IPv6 TCP connection hangs/drops when
 time/clock on the client is stepped backwards
Date: Wed, 16 May 2012 09:21:59 +0900 (JST)

 ----Security_Multipart(Wed_May_16_09_21_59_2012_608)--
 Content-Type: Text/Plain; charset=us-ascii
 Content-Transfer-Encoding: 7bit
 
 "Bjoern A. Zeeb" <bz@FreeBSD.org> wrote
   in <201205160010.q4G0A4xk075017@freefall.freebsd.org>:
 
 bz> The following reply was made to PR kern/167646; it has been noted by GNATS.
 bz>
 bz> From: "Bjoern A. Zeeb" <bz@FreeBSD.org>
 bz> To: bug-followup@FreeBSD.org, Martin.Birgmeier@aon.at
 bz> Cc:
 bz> Subject: Re: kern/167646: [ip6] IPv6 TCP connection hangs/drops when time/clock
 bz>  on the client is stepped backwards
 bz> Date: Wed, 16 May 2012 00:01:03 +0000 (UTC)
 bz>
 bz>  Hi,
 bz>
 bz>  the problem has been known for a while; the problem is the "time" used
 bz>  depending on the real time clock rather than on something monotonically
 bz>  increasing.
 bz>
 bz>  The TCP connections can come back (quickly) btw. as new RA/NS/NA
 bz>  cycles are ondergone.
 
  Yes.  I have had a patchset to solve this issue by using time_uptime
  (monotonic counter) instead of time_second throughout IPv6 stack.  I
  think I will adjust it to HEAD.
 
 -- Hiroki
 
 ----Security_Multipart(Wed_May_16_09_21_59_2012_608)--
 Content-Type: application/pgp-signature
 Content-Transfer-Encoding: 7bit
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.11 (FreeBSD)
 
 iEYEABECAAYFAk+y8ycACgkQTyzT2CeTzy1zcgCgv5SVt63p7XdfLVkbSNw5Pt4l
 +xwAnAvs/9QauimUGTPoMyKF1GuzRQ6o
 =OsZN
 -----END PGP SIGNATURE-----
 
 ----Security_Multipart(Wed_May_16_09_21_59_2012_608)----

From: Martin Birgmeier <Martin.Birgmeier@aon.at>
To: "Bjoern A. Zeeb" <bz@FreeBSD.org>
Cc: bug-followup@FreeBSD.org
Subject: Re: kern/167646: [ip6] IPv6 TCP connection hangs/drops when time/clock
 on the client is stepped backwards
Date: Thu, 17 May 2012 19:10:08 +0200

 Hmmm... my experience has been that the connections do not come up again 
 and in fact time out after a while. It even seems that I cannot start 
 new TCPv6 connections. On the other hand, at the same time some of the 
 existing connections seem to survive.
 
 On 05/16/12 02:01, Bjoern A. Zeeb wrote:
 > Hi,
 >
 > the problem has been known for a while; the problem is the "time" used
 > depending on the real time clock rather than on something monotonically
 > increasing.
 >
 > The TCP connections can come back (quickly) btw. as new RA/NS/NA
 > cycles are ondergone.
 >
>Unformatted:
