Bug 1392 - Systems with IPV6_V6ONLY = 0 have unexpected behavior
Summary: Systems with IPV6_V6ONLY = 0 have unexpected behavior
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: sshd (show other bugs)
Version: 4.7p1
Hardware: All Linux
: P2 normal
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks: V_4_8
  Show dependency treegraph
 
Reported: 2007-11-17 20:47 AEDT by Gordon Stratton
Modified: 2008-03-31 15:22 AEDT (History)
1 user (show)

See Also:


Attachments
turn on IPV6_V6ONLY in sshd before binding for systems that support it (770 bytes, patch)
2007-11-17 20:47 AEDT, Gordon Stratton
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gordon Stratton 2007-11-17 20:47:15 AEDT
Created attachment 1382 [details]
turn on IPV6_V6ONLY in sshd before binding for systems that support it

I noticed that sshd on a Linux 2.6.23 system complains when it starts up:

sshd[6292]: Server listening on :: port 22.
sshd[6292]: error: Bind to port 22 on 0.0.0.0 failed: Address already in use.

From what I understand, sshd is operating under the assumption that it will not accept IPv4 connections on an IPv6 socket and vice versa (e.g., -4 and -6 options that state that sshd will be forced to use IPv[46] addresses only).

Currently, if I start sshd with the -6 flag, my expectation is that sshd will only be able to accept connections over IPv6, but that is not the case on Linux (v4-mapped addresses get used when a client connects to an IPv6 socket over IPv4).

The attached patch turns on IPV6_V6ONLY if it is defined before binding to a socket using AF_INET6. This resolves the bind error that sshd logs on my system as well as giving users the (in my opinion) expected behavior for the -6 command line option and Listen options in sshd_config.

Patch has been tested on Linux 2.6.23, and it is against openssh-SNAP-20071117
Comment 1 Damien Miller 2008-01-20 08:56:32 AEDT
yes, that makes sense and matches what we already do in channels.c - applied, thanks!
Comment 2 Damien Miller 2008-03-31 15:22:38 AEDT
Fix shipped in 4.9/4.9p1 release.