Bug 606980

Summary: getaddrinfo() returns duplicate addresses under AI_ADDRCONFIG
Product: [openSUSE] openSUSE 11.2 Reporter: Matthias Andree <matthias.andree>
Component: BasesystemAssignee: Michael Matz <matz>
Status: RESOLVED WONTFIX QA Contact: E-mail List <qa-bugs>
Severity: Major    
Priority: P3 - Medium    
Version: Final   
Target Milestone: ---   
Hardware: i686   
OS: openSUSE 11.2   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: demo code that shows the problem

Description Matthias Andree 2010-05-19 00:09:58 UTC
Created attachment 363088 [details]
demo code that shows the problem

User-Agent:       Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.2.3) Gecko/20100423 Ubuntu/10.04 (lucid) Firefox/3.6.3

Presume I have a computer that has no global IPv6 addresses, but a few IPv4 addresses.

Applications using getaddrinfo() with hints.ai_flags = AI_ADDRCONFIG set will properly omit IPv6 addresses, HOWEVER they will return duplicate IPv4 addresses.

Demonstration code attached.

Without IPv6 addresses:

# show setup
$ grep -w localhost /etc/hosts
127.0.0.1       localhost 
::1             localhost ipv6-localhost ipv6-loopback
$ ip a d fe80::260:XXXX:XXXX:XXXX/64 dev eth0 # fill in your HWADDR
$ ip a s | grep inet
    inet 127.0.0.1/8 brd 127.255.255.255 scope host lo
    inet 127.0.0.2/8 brd 127.255.255.255 scope host secondary lo
    inet6 ::1/128 scope host
    inet 192.168.0.1/24 brd 192.168.0.255 scope global eth0

# compile test case
$ gcc -Wall -Wextra -pedantic -O -o libcbug-demo libcbug-demo.c

# run test case
$ ./libcbug-demo localhost echo
Address 1: 127.0.0.1
Address 2: 127.0.0.1

(127.0.0.1 should be listed only once, Solaris 10 for instance achieves that)

Now configure a fake IPv6 address (don't do this on hosts with real IPv6 connectivity, it suffices to use your real IPv6 address) and re-run the application:

$ ip a a 2001::2001 dev eth0 # set up IPv6
$ ./libcbug-demo localhost echo
Address 1: ::1
Address 2: 127.0.0.1
$ ip a d 2001::2001 dev eth0 # deconfigure bogus address

(This is fine)

Practical consequence: excessive connection retries by applications that possibly take a long time.


This also affects Ubuntu 10.04 LTS on amd64, please consider forwarding upstream.

Reproducible: Always

Steps to Reproduce:
see details
Actual Results:  
Duplicate 127.0.0.1 address.

Expected Results:  
127.0.0.1 address listed once.
Comment 1 Matthias Andree 2010-05-19 00:11:28 UTC
Note that the tested machine (openSUSE) is not the same as the reporting (Ubuntu). Just my convenience of running Firefox on the stronger machine. Meaning: please disregard the User-Agent.
Comment 2 Petr Baudis 2010-06-01 01:42:16 UTC
Hmm, curious that you see this on Ubuntu too, since Debian Lenny does not seem to be suffering AFAICS.
Comment 3 Matthias Andree 2010-06-01 08:17:48 UTC
I am not surprised, Ubuntu (1) use eglibc (Embedded...), (2) have local changes that deliberately break automatic synching with Debian, (3) has changing policies across releases WRT what branch they synch to. 10.04LTS aka Lucid Lynx for instance was branched off an older Debian/testing.

Nevermind that curiosity.

This bug report is about openSUSE and Ubuntu has a separate report,
https://bugs.launchpad.net/ubuntu/+source/eglibc/+bug/582585 - I'd suggested to forward upstream because it apparently wasn't SUSE-specific and hence possibly not related to local patches.
Comment 5 Michael Matz 2011-07-07 12:27:10 UTC
See https://bugzilla.redhat.com/show_bug.cgi?id=496300 where
Ulrich decided that this behaviour is okay with him for localhost.
I've verified that for DNS queries the answers are as expected,
in particular that if there's no local ipv6 address, that there's only
one answer for each ipv4 address of the host.

So, this might be inconvenient, but should not lead to any further timeouts
as localhost is supposed to be loopback and if loopback times out something
more serious is broken --> WONTFIX.
Comment 6 Matthias Andree 2011-07-07 13:58:28 UTC
<irony>Alright. Ulrich is God and his silence is sufficient to defend his unsubstantiated "should" clauses.</irony>

Ulrich isn't deciding what's a bug or not. His "should" clauses are not backed by system documentation are just personal opinions, but irrelevant.

The point is that we get an UNLISTED and UNWARRANTED IPv4 address in return.  While the IPv4 duplicate 127.0.0.1 is not typically a practical problem, the whole discussion sidesteps the actual resolver bug, and that is that IPv6 /etc/hosts entries yield IPv4 results that should not be there -- whether that is a malfunction of the AI_ADDRCONFIG flag or whatnot, I don't care.

Reopening.
Comment 7 Matthias Andree 2011-07-07 13:58:56 UTC
demoting importance
Comment 8 Michael Matz 2011-07-07 14:35:23 UTC
So, what exactly are you complaining about?  It seems not to be the duplicate
returns of 127.0.0.1 .  Is that correct?

You seem to complain about getaddrinfo returning an unlisted ipv4 address
from /etc/hosts.  But you haven't shown this.  127.0.0.1 _is_ listed in
your /etc/hosts; it's returned twice, okay, but that's no issue to you it seems.

So, please file a bug report about what actually worries you, not what you
think are symptoms of a suspected problem.

Note that the double-return of 127.0.0.1 will remain WONTFIX, meaning I agree
it's a deficiency but I decided to not do anything about it.  Take it upstream
yourself if you disagree.  Now, if you can report a different bug, the one
that actually worries you, matters may be different.