From owner-freebsd-net@FreeBSD.ORG Sun Aug 10 20:09:57 2014 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 7E0F3733 for ; Sun, 10 Aug 2014 20:09:57 +0000 (UTC) Received: from mail-wg0-x230.google.com (mail-wg0-x230.google.com [IPv6:2a00:1450:400c:c00::230]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1C0C1294A for ; Sun, 10 Aug 2014 20:09:56 +0000 (UTC) Received: by mail-wg0-f48.google.com with SMTP id x13so7738817wgg.7 for ; Sun, 10 Aug 2014 13:09:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=7EU5W3QJtEqDeDChDpD8KI1o0l/+jXKPn+n4Hbkwjvw=; b=AiLD3w9QRoS1GLHYm+0aaMtMdUOoQhb+vRH1kmH81aEkhvzQjrEmfBKr3Jft1Y7JxH eA+x/YJnTyMwHP0jiBnBOsGhA8yOcRLwI/tvDcW6OmTVJv5TJFVR9giRvUkwQRsn/CrP yBFzcbsHKaXh3lqFw+NvVf8QdNSQaVtlS0O8Dc83Gb/4t5BffDVV0d7bNmYkqf94O8Zd LfUiNNYpbwzrgmveCIepxbp+WgCYpMxFYJq79rfoq0RfZp6HI3lxmhGTYoxzjRyHrdco UIU5usgHictsVQA/LySd02hKqXtEupGnLsNn95fvelzPIPEbS7gtSJQaXEfNTgVX6CzZ Frng== MIME-Version: 1.0 X-Received: by 10.180.73.6 with SMTP id h6mr19773445wiv.65.1407701395087; Sun, 10 Aug 2014 13:09:55 -0700 (PDT) Received: by 10.216.22.129 with HTTP; Sun, 10 Aug 2014 13:09:55 -0700 (PDT) Date: Sun, 10 Aug 2014 23:09:55 +0300 Message-ID: Subject: Question about tcp keep-alive timer From: David Bar To: freebsd-net@freebsd.org Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.18 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: Sun, 10 Aug 2014 20:09:57 -0000 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? Thanks, David Bar dbar at gmail dot com