From owner-freebsd-net@FreeBSD.ORG Thu Oct 21 13:40:19 2004 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 59A8216A4CE for ; Thu, 21 Oct 2004 13:40:19 +0000 (GMT) Received: from c00l3r.networx.ch (c00l3r.networx.ch [62.48.2.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8E2FF43D53 for ; Thu, 21 Oct 2004 13:40:18 +0000 (GMT) (envelope-from andre@freebsd.org) Received: (qmail 76981 invoked from network); 21 Oct 2004 13:38:56 -0000 Received: from unknown (HELO freebsd.org) ([62.48.0.53]) (envelope-sender ) by c00l3r.networx.ch (qmail-ldap-1.03) with SMTP for ; 21 Oct 2004 13:38:56 -0000 Message-ID: <4177BC49.73B6D910@freebsd.org> Date: Thu, 21 Oct 2004 15:40:25 +0200 From: Andre Oppermann X-Mailer: Mozilla 4.8 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 To: Fernando Gont References: <4.3.2.7.2.20041021044818.00d5a560@server.frh.utn.edu.ar> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit cc: freebsd-net@freebsd.org Subject: Re: tcp_notify() and the connection establishment timer X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Oct 2004 13:40:19 -0000 Fernando Gont wrote: > > Folks, > > I was trying to figure out what the BSD policy for aborting > connection-establishment attempts was. > > According to Stevens' TCPv2, when TCP sends the first SYN for establishing > a connection, a 75-seconds timer is initialized. If the connection cannot > be established before that 75-second period is over, the conenction will be > aborted. > > However, looking at the tcp_notify() function, I see the following code: > > static struct inpcb * > tcp_notify(inp, error) > struct inpcb *inp; > int error; > { > struct tcpcb *tp = (struct tcpcb *)inp->inp_ppcb; > > /* > * Ignore some errors if we are hooked up. > * If connection hasn't completed, has retransmitted several times, > * and receives a second error, give up now. This is better > * than waiting a long time to establish a connection that > * can never complete. > */ > if (tp->t_state == TCPS_ESTABLISHED && > (error == EHOSTUNREACH || error == ENETUNREACH || > error == EHOSTDOWN)) { > return inp; > } else if (tp->t_state < TCPS_ESTABLISHED && tp->t_rxtshift > 3 && > tp->t_softerror) { > tcp_drop(tp, error); > return (struct inpcb *)0; > } else { > tp->t_softerror = error; > return inp; > } > #if 0 > wakeup( &so->so_timeo); > sorwakeup(so); > sowwakeup(so); > #endif > } > > Maybe I'm missing something, but I get the impression that, considering the > value (six seconds) to which the RTO is initialized, that part that says > > } else if (tp->t_state < TCPS_ESTABLISHED && tp->t_rxtshift > 3 && > tp->t_softerror) { > tcp_drop(tp, error); > return (struct inpcb *)0; > > will never be executed, as the connection-establishment timer will always > timeout before the evaluated condition becomes true. > > Am I missing something? Or is it that this code is there just in case the > initial RTO is reduced to such a value that, in that case, this code would > kick in before the 75-seconds tconnection-establishment timer? Yes, tcp_notify() gets called from icmp_input() when ICMP unreachable or related error messages from the network are received. In those cases you don't want to wait the full 75 seconds because the network tells you that a connection cannot be established to that destination. It doesn't do that the first time the network tells us that to avoid too fast reaction on spurious network problems, outages or re-routings. -- Andre