Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 21 Oct 2004 15:40:25 +0200
From:      Andre Oppermann <andre@freebsd.org>
To:        Fernando Gont <fernando@gont.com.ar>
Cc:        freebsd-net@freebsd.org
Subject:   Re: tcp_notify() and the connection establishment timer
Message-ID:  <4177BC49.73B6D910@freebsd.org>
References:  <4.3.2.7.2.20041021044818.00d5a560@server.frh.utn.edu.ar>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4177BC49.73B6D910>