From owner-freebsd-net@FreeBSD.ORG Mon Aug 11 21:29:17 2014 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 57A06B3F for ; Mon, 11 Aug 2014 21:29:17 +0000 (UTC) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3054A271E for ; Mon, 11 Aug 2014 21:29:17 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 29D44B94A; Mon, 11 Aug 2014 17:29:16 -0400 (EDT) From: John Baldwin To: freebsd-net@freebsd.org Subject: Re: Question about tcp keep-alive timer Date: Mon, 11 Aug 2014 15:50:31 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.4-CBSD-20140415; KDE/4.5.5; amd64; ; ) References: In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201408111550.31642.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Mon, 11 Aug 2014 17:29:16 -0400 (EDT) Cc: David Bar X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Aug 2014 21:29:17 -0000 On Sunday, August 10, 2014 4:09:55 pm David Bar wrote: > Hi > > > (Forgive me if this topic has been discussed before. I didn't find it in > the archives) > > In tcp_input(), when a packet is received on an established socket the code > re-arms the keep-alive timer, for each packet. > Here: > https://svnweb.freebsd.org/base/release/10.0.0/sys/netinet/tcp_input.c?revision=260789&view=markup#l1518 > > Isn't this a waste to do this for each packet? > > The setting of the timer when the connection becomes established should > suffice if there was a small change in tcp_timer_keep(). > If tcp_timer_keep() would first checks if tp->t_rcvtime is recent (newer > than the TT_KEEPIDLE time), and would just re-arm the timer to go off > later, then we would keep the same functionality. > > I can't think of any downsides to this idea. Any good reason why this > hasn't been done before? I think it is just a tradeoff between having the timer run at all. However, I suspect that with high packet rates it probably is cheaper to have the timer run periodically and reschedule itself if it notices it isn't needed as you suggested. Do you want to write up a patch and test it? -- John Baldwin