This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: SSH Local Port Forwarding


On Jan 31 15:25, Jon Dixon wrote:
> Hi Corinna,
> 
> I have tested the cygwin-inst-20060130.tar.bz2 snapshot. 
> Unfortunately, this snapshot runs the same way as release 1.5.19-4. 

No, it doesn't, definitely.  1.5.19-4 has not set the SO_EXCLUSIVEADDRUSE
option, and I could easily reuse ports for listening before.  I didn't
just add SO_EXCLUSIVEADDRUSE without testing.  Keep in mind that the
ssh testcase is sort of flawed by the fact, that ssh uses the SO_REUSEADDR
option on locally forwarded ports.  There's a combination which already
disallowed port reuse without implementing SO_EXCLUSIVEADDRUSE.

> Cygwin does however behave differently on Windows 2000 Server than on
> Windows 2003 Server.
> 
> The following describes the behavior of Cygwin (release or snapshot)
> running on Windows 2000 Server sp 4.
> 
> The SSH local port forwarding is activated with the command line statement:
>    ssh -L2001:server.com:23 server.com.
> 
> If another program is executed that also listens on port 2001, the
> program immediately throws the bind error exception: Address already
> in use.
> 
> Cygwin (release or snapshot) running on Windows 2003 Server sp 1
> however does not throw a bind exception.

That's not what I can reproduce easily.  I have a small test application
called "fsu", which does nothing but socket/bind/listen/accept on port
9998.  The two test scenarios are starting ssh first, then fsu and vice
versa.  Below are the output logs of both scenarios which happen IDENTICALLY
on 2K SP4, XP SP2 and 2K3 SP1, with a recent snapshot.  I just tested it on
all three OSes again:

  Window 1:  $ fsu
             server socket at 3
             Listening at host cathi, port 9998
             waiting for the messages

  Window 2:  $ ssh -L9998:calimero:1234 calimero
             bind: Operation not permitted
             channel_setup_fwd_listener: cannot listen to port: 9998
             Could not request local forwarding.
             Last login: Sun Jan 29 12:18:46 2006 from cathi
             calimero>

Now starting ssh first, then fsu:

  Window 1:  $ ssh -L9998:calimero:1234 calimero
             Last login: Wed Feb  1 09:50:23 2006 from cathi
             calimero>

  Window 2:  $ fsu
             server socket at 3
             Error: server binding error
             $ 

If you think there's still something not ok, I need a short, concise,
minimal testcase, preferredly in plain C, which builds OOTB and allows
reproducing the unwanted port reuse.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]