Bug 1648 - Fix IPV6_V6ONLY for -L with -g
Summary: Fix IPV6_V6ONLY for -L with -g
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: ssh (show other bugs)
Version: -current
Hardware: All Linux
: P2 minor
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks: V_5_4
  Show dependency treegraph
 
Reported: 2009-09-13 23:58 AEST by Jan Kratochvil
Modified: 2023-01-13 13:56 AEDT (History)
1 user (show)

See Also:


Attachments
Fix following the current openssh style. (935 bytes, patch)
2009-09-13 23:58 AEST, Jan Kratochvil
no flags Details | Diff
unify setsockopt(...,IPV6_V6ONLY,...) calls (2.89 KB, patch)
2009-11-10 14:13 AEDT, Damien Miller
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Kratochvil 2009-09-13 23:58:45 AEST
Created attachment 1695 [details]
Fix following the current openssh style.

$ /usr/bin/ssh -g -L 5000:localhost:22 localhost cat
bind: Address already in use
[... running]
# netstat -apn|grep 5000
tcp  0  0  0.0.0.0:5000  0.0.0.0:*  LISTEN  23526/ssh
$ telnet localhost6 5000
Trying ::1...
telnet: connect to address ::1: Connection refused

patched:

$ ./ssh -g -L 5000:localhost:22 localhost cat
[... running]
# netstat -apn|grep 5000
tcp  0  0  0.0.0.0:5000  0.0.0.0:*  LISTEN  23139/ssh
tcp  0  0  :::5000       :::*       LISTEN  23139/ssh
$ telnet localhost6 5000
Trying ::1...
Connected to localhost6.
Escape character is '^]'.
SSH-2.0-OpenSSH_5.2


Using Fedora 11 kernel with its (+AFAIK upstream) defaults:
# cat /proc/version 
Linux version 2.6.30.5-43.fc11.x86_64
(mockbuild@xenbuilder4.fedora.phx.redhat.com) (gcc version 4.4.1
20090725 (Red Hat 4.4.1-2) (GCC) ) #1 SMP Thu Aug 27 21:39:52 EDT 2009
# cat /proc/sys/net/ipv6/bindv6only
0

In the current case one cannot access IPv6 because the IPv4 socket was
created first.  If IPv6 would be created first it would work.

The copy-pasted code could be probably moved to some unified function. 
This is out of scope of this patch.

Similiar problem+resolution was in Bug 164, Bug 1309 and Bug 1392.
Comment 1 Damien Miller 2009-11-10 14:13:52 AEDT
Created attachment 1720 [details]
unify setsockopt(...,IPV6_V6ONLY,...) calls

Good idea about unifying the calls to setsockopt. Here is a diff that does that (includes your change too).
Comment 2 Damien Miller 2009-11-18 17:49:05 AEDT
patch applied. this will be in openssh-5.4, thanks for the report+patch.
Comment 3 Darren Tucker 2010-03-26 10:51:11 AEDT
With the release of 5.4p1, this bug is now considered closed.