Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 53154 - glibc 2.3.3_pre20040529 resolver uses ipv4 address before ipv6 address
Summary: glibc 2.3.3_pre20040529 resolver uses ipv4 address before ipv6 address
Status: RESOLVED UPSTREAM
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: AMD64 Linux
: High normal (vote)
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-06-06 12:23 UTC by Mark Kamichoff
Modified: 2004-11-23 22:21 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Kamichoff 2004-06-06 12:23:17 UTC
After upgrading to glibc 2.3.3_pre20040529, I noticed the resolver prefers A records instead of AAAA records, if a hostname has both.  The application (wget, telnet, ssh, etc.) will resolve both addresses, but pick the IPv4 one by default.

From what I understand, this is an incorrect behavior.  Libraries and applications that are IPv6-aware should try the IPv6 address first, and if that fails, then fall back to IPv4.  I believe this is stated in an RFC, too.

Reproducible: Always
Steps to Reproduce:
1. Use wget/ssh/telnet/etc. to connect to a hostname that has both A and AAAA records
2. Notice that the IPv4 address is chosen before the IPv6 one.

Actual Results:  
The IPv4 address was chosen, instead of the IPv6 one.

Expected Results:  
The IPv6 address should have been tried first.  If that failed, it should fall
back to the IPv4 one.

Portage 2.0.50-r7 (default-amd64-2004.0, gcc-3.3.3, glibc-2.3.3_pre20040529-r0,
2.6.5-gentoo-r1)
=================================================================
System uname: 2.6.5-gentoo-r1 x86_64 4
Gentoo Base System version 1.4.15
Autoconf: sys-devel/autoconf-2.58-r1
Automake: sys-devel/automake-1.8.3
ACCEPT_KEYWORDS="amd64"
AUTOCLEAN="yes"
CFLAGS="-O2"
CHOST="x86_64-pc-linux-gnu"
COMPILER="gcc3"
CONFIG_PROTECT="/etc /usr/X11R6/lib/X11/xkb /usr/kde/2/share/config
/usr/kde/3/share/config /usr/lib/mozilla/defaults/pref /usr/share/config
/var/qmail/control"
CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d"
CXXFLAGS="-O2"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoaddcvs ccache sandbox"
GENTOO_MIRRORS="http://mirrors.acm.cs.rpi.edu/gentoo http://gentoo.noved.org/"
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY=""
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="X acpi alsa amd64 apache2 apm avi berkdb cdr crypt cups dvd encode esd flac
foomaticdb gd gdbm gif gpm gtk gtk2 imap imlib ipv6 jpeg kde libg++ libwww
maildir mbox mikmod motif mozilla mpeg mysql ncurses nls nogcj oggvorbis opengl
oss pam pdflib perl png python quicktime readline sdl slang spell ssl tcpd tiff
truetype usb xml2 xmms xv zlib"
Comment 1 Kalin KOZHUHAROV 2004-06-17 13:16:47 UTC
Do you have such RFC by hand?

At present, IPv6 is still experimental (=not widely working), IPv4 is still "the snatdard".

Why "applications" choose IPv4 by default? Because it is more stable. Most of them have otions (usually -6) to make them prefer IPv6.

IMHO, which is preferred should be a system setting (like somewhere in /proc), changeble on the fly, but at the moment it is not. Aiting for broken IPv6 implementations to time out is simply no good though.

If I was writing a network application (for the moment) -4 -6 and --prefer-IPv6 --prefer-IPv4 whould have been a standard set of options (-4 -6 meaning use *only*).

There was a similar discussion wheather gethostbyname() should sort (or randomize) the list of names on return. IMHO it is up to the application to choose wheather to use the firs in the list (simple logic), some random one (daubtfully better) or a few (all) in parallel (=waste of resources). Every approach is app-specific and glibc cannot know what is required.

I suggest wonfix for this one, unless somebody comes with a working patch to change that at runtime as system config.
Comment 2 Martin Schlemmer (RETIRED) gentoo-dev 2004-06-17 15:08:23 UTC
You might try to change in /etc/nsswitch.conf:

--
hosts:       files dns6 dns
--

not 100% sure if its supported though by glibc ...
Comment 3 pasi.valminen 2004-06-17 23:44:38 UTC
Why would you spend time waiting for broken IPv6 implementations if you don't have IPv6 support in kernel? On the other hand why would you build IPv6 into your kernel unless you want to use it, test it or do developement? BUT you can't drop IPv4 from linux kernel, so you end up timeouting when connecting on dual stack hosts if they don't serve on IPv4.