ExitOnForwardFailure not behaving as expected...



Hello everyone,

I'm experiencing some strange behavior with ssh and I'm trying to figure
out where the problem might be. I'm running Ubuntu 9.04. Relevant
version numbers:

$ ssh -V
OpenSSH_5.1p1 Debian-5ubuntu1, OpenSSL 0.9.8g 19 Oct 2007

$ dpkg-query -W openssh-client
openssh-client 1:5.1p1-5ubuntu1

$ uname -a
Linux bodhi 2.6.28-9-generic #31-Ubuntu SMP Wed Mar 11 15:43:49 UTC 2009 x86_64 GNU/Linux

Now, ExitOnForwardFailure is not behaving the way I'd expect it to. Let
me show you what I'm experiencing. In the following examples port 50001
is already used by some other process. Port 55555 and 50505 are free.
This first example is the one which causes me trouble. It finds that
50001 is already in use but it does not exit. I'd expect it to exit
because the binding failed.

$ ssh -N -L 50001:localhost:55555 -o ExitOnForwardFailure=yes ldd@localhost
bind: Address already in use

When I run ssh -v, I see that ssh fails to bind on 127.0.0.1:50001 but
successfully binds [::1]:50001. It considers the second binding to be
good enough to go forward.

This one exits on forward failure as expected... but the funny thing is
that * or leaving the binding address empty should be equivalent.

$ ssh -N -L '*':50001:localhost:55555 -o ExitOnForwardFailure=yes ldd@localhost
bind: Address already in use
channel_setup_fwd_listener: cannot listen to port: 50001
Could not request local forwarding.

This one exits on forward failure as expected, probably because IPV6 is
disabled:

$ ssh -4 -N -L 50001:localhost:55555 -o ExitOnForwardFailure=yes ldd@localhost
bind: Address already in use
channel_setup_fwd_listener: cannot listen to port: 50001
Could not request local forwarding.

This one exits on forward failure as expected, probably because both
bindings are requested separately:

$ ssh -N -L 127.0.0.1:50001:localhost:50505 -L [::1]:50001:localhost:55555 -o ExitOnForwardFailure=yes ldd@localhost
bind: Address already in use
channel_setup_fwd_listener: cannot listen to port: 50001
Could not request local forwarding.

Is there something I am misunderstanding? Is there a problem in ssh?
Is there some Linux peculiarity at play here?

Thanks,
Louis