Bug 343 - Only try connect to first address when creating tunnel
Summary: Only try connect to first address when creating tunnel
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: sshd (show other bugs)
Version: -current
Hardware: All All
: P2 normal
Assignee: Damien Miller
URL:
Keywords:
Depends on:
Blocks: V_5_1
  Show dependency treegraph
 
Reported: 2002-07-09 04:08 AEST by Stig Venaas
Modified: 2023-01-13 13:56 AEDT (History)
0 users

See Also:


Attachments
try subsequent addresses (11.79 KB, patch)
2008-05-09 01:01 AEST, Damien Miller
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stig Venaas 2002-07-09 04:08:21 AEST
In connect_to() in channels.c there is a loop trying to connect to each
address returned by getaddrinfo() until connect() is successful or
EINPROGRESS is returned. The socket is non-blocking so unless something
immediately fails, EINPROGRESS is returned and we happily leave the loop.
Then when we later attempt to write to the socket, we realize that we're
not connected. No route to host, connection refused etc. I would like
sshd to try another address if possible when this happens. Or in other
words, loop through all candidates until we are absolutely positive we
have established a connection. I think this can be done by selecting
the socket for writing without actually writing anything. I'm happy to
elaborate why this is a real life problem if necessary.
Comment 1 Damien Miller 2003-05-15 18:36:44 AEST
The fix for Bug #207 may be useful here
Comment 2 Damien Miller 2008-05-09 01:01:36 AEST
Created attachment 1498 [details]
try subsequent addresses

This patch should fix the bug. (better late than never)
Comment 3 Damien Miller 2008-05-09 01:02:54 AEST
Target release openssh-5.1
Comment 4 Damien Miller 2008-05-09 15:05:32 AEST
Fix committed and will be in openssh-5.1:

> CVSROOT:        /cvs
> Module name:    src
> Changes by:     djm@cvs.openbsd.org     2008/05/08 22:55:57
> 
> Modified files:
>         usr.bin/ssh    : channels.c channels.h clientloop.c serverloop.c
> 
> Log message:
> Try additional addresses when connecting to a port forward destination
> whose DNS name resolves to more than one address. The previous behaviour
> was to try the first address and give up.
> 
> Reported by stig AT venaas.com in bz#343
> 
> great feedback and ok markus@
Comment 5 Damien Miller 2008-07-22 12:06:39 AEST
Mass update RESOLVED->CLOSED after release of openssh-5.1