getaddrinfo and AI_PASSIVE is broken for net.ipv6.bindv6only=0
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
eglibc (Ubuntu) |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
When calling getaddrinfo and specifying AF_UNSPEC and AI_PASSIVE it returns both IPv4 and IPv6 addresses when the sysctl net.ipv6.bindv6only = 0. Proper app behavior for AI_PASSIVE should be to bind and listen to all returned addresses, but the kernel does not allow binding to a V4 and V6 address with the same port. In this case getaddrinfo should return only a IPv4 or only a IPv6 address.
Illustrated with python because I'm lazy:
>>> resx = socket.
>>> print resx
[(2, 1, 6, '', ('0.0.0.0', 1234)), (10, 1, 6, '', ('::', 1234, 0, 0))]
>>> res = resx[0]
>>> fd = socket.
>>> fd.bind(res[4]);
>>> res = resx[1]
>>> fd2 = socket.
>>> fd2.bind(res[4]);
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 1, in bind
socket.error: [Errno 98] Address already in use
At least in earlier Ubuntu releases this case returned the IPv6 address first, so most apps which don't properly use all addresses 'worked' but it was still wrong to return both addresses. The new behavior breaks IPv6 in various cases, with no possible app work-around!
Apps should not be expected to 'sense' if the system is bindv6only. getaddrinfo AF_UNSPEC/
At a minimum the old sorting behavior of putting v6 first should be restored! Real apps depend on this!
I've noted various other bugs in this same theme:
http://
http://
So here is one for Ubuntu with a bit more clarity on the exact problem.
ProblemType: Bug
DistroRelease: Ubuntu 10.10
Package: libc6 2.12.1-0ubuntu8
ProcVersionSign
Uname: Linux 2.6.35-22-generic x86_64
Architecture: amd64
Date: Wed Nov 10 12:52:08 2010
InstallationMedia: Ubuntu 10.10 "Maverick Meerkat" - Release amd64 (20101007)
ProcEnviron:
PATH=(custom, no user)
LANG=C
SHELL=/bin/bash
SourcePackage: eglibc
Upstream bug report:
http:// sourceware. org/bugzilla/ show_bug. cgi?id= 14967
More information:
https:/ /fedoraproject. org/wiki/ Networking/ NameResolution# Binding_ to_the_ INADDR_ ANY_and. 2For_in6addr_ any_addresses