public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug network/14969] New: getaddrinfo() with AI_ADDRCONFIG replaces ::1 with 127.0.0.1
@ 2012-12-17 17:08 psimerda at redhat dot com
  2012-12-17 17:09 ` [Bug network/14969] " psimerda at redhat dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: psimerda at redhat dot com @ 2012-12-17 17:08 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=14969

             Bug #: 14969
           Summary: getaddrinfo() with AI_ADDRCONFIG replaces ::1 with
                    127.0.0.1
           Product: glibc
           Version: 2.15
            Status: NEW
          Severity: normal
          Priority: P2
         Component: network
        AssignedTo: unassigned@sourceware.org
        ReportedBy: psimerda@redhat.com
    Classification: Unclassified


getaddrinfo() with AI_ADDRCONFIG replaces all ::1 with 127.0.0.1 on hosts
without non-loopback IPv6 addresses. See the following test result:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP
qlen 1000
    link/ether f0:de:f1:b8:6a:ee brd ff:ff:ff:ff:ff:ff
    inet 84.246.161.88/28 brd 84.246.161.95 scope global eth0

getaddrinfo host="None" hints.ai_flags=AI_ADDRCONFIG:
  ::1
  127.0.0.1
getaddrinfo host="localhost" hints.ai_flags=AI_ADDRCONFIG:
  127.0.0.1
  127.0.0.1
getaddrinfo host="127.0.0.1" hints.ai_flags=AI_ADDRCONFIG:
  127.0.0.1
getaddrinfo host="localhost4" hints.ai_flags=AI_ADDRCONFIG:
  127.0.0.1
getaddrinfo host="::1" hints.ai_flags=AI_ADDRCONFIG:
  ::1
getaddrinfo host="localhost6" hints.ai_flags=AI_ADDRCONFIG:
  127.0.0.1
getaddrinfo host="195.47.235.3" hints.ai_flags=AI_ADDRCONFIG:
  195.47.235.3
getaddrinfo host="2a02:38::1001" hints.ai_flags=AI_ADDRCONFIG:
  2a02:38::1001
getaddrinfo host="info.nix.cz" hints.ai_flags=AI_ADDRCONFIG:
  195.47.235.3
getaddrinfo host="www.google.com" hints.ai_flags=AI_ADDRCONFIG:
  173.194.39.81
  173.194.39.82
  173.194.39.80
  173.194.39.84
  173.194.39.83

Especially notable are:

getaddrinfo(localhost) -> 127.0.0.1, 127.0.0.1 (duplicate)
getaddrinfo(localhost6) -> 127.0.0.1 (wrong)

Contents of /etc/hosts:

127.0.0.1    localhost localhost4
::1        localhost localhost6

Looks like some sort of black magic someone was trying to solve something.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug network/14969] getaddrinfo() with AI_ADDRCONFIG replaces ::1 with 127.0.0.1
  2012-12-17 17:08 [Bug network/14969] New: getaddrinfo() with AI_ADDRCONFIG replaces ::1 with 127.0.0.1 psimerda at redhat dot com
@ 2012-12-17 17:09 ` psimerda at redhat dot com
  2014-06-14  5:31 ` fweimer at redhat dot com
  2020-07-16  7:52 ` alex.gronholm at nextday dot fi
  2 siblings, 0 replies; 4+ messages in thread
From: psimerda at redhat dot com @ 2012-12-17 17:09 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=14969

--- Comment #1 from Pavel Šimerda <psimerda at redhat dot com> 2012-12-17 17:09:23 UTC ---
Testing script:

#!/usr/bin/python3
import sys
from socket import *
hosts = [
    None,
    "localhost",
    "127.0.0.1",
    "localhost4",
    "::1",
    "localhost6",
    "195.47.235.3",
    "2a02:38::1001",
    "info.nix.cz",
    "www.google.com",
]
for host in hosts:
    print("getaddrinfo host=\"{}\" hints.ai_flags=AI_ADDRCONFIG:".format(host))
    try:
        for item in getaddrinfo(host, "http", AF_UNSPEC, SOCK_STREAM, SOL_TCP,
AI_ADDRCONFIG):
            print("  {}".format(item[4][0]))
    except gaierror as error:
        print("  !! {} !!".format(error))

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug network/14969] getaddrinfo() with AI_ADDRCONFIG replaces ::1 with 127.0.0.1
  2012-12-17 17:08 [Bug network/14969] New: getaddrinfo() with AI_ADDRCONFIG replaces ::1 with 127.0.0.1 psimerda at redhat dot com
  2012-12-17 17:09 ` [Bug network/14969] " psimerda at redhat dot com
@ 2014-06-14  5:31 ` fweimer at redhat dot com
  2020-07-16  7:52 ` alex.gronholm at nextday dot fi
  2 siblings, 0 replies; 4+ messages in thread
From: fweimer at redhat dot com @ 2014-06-14  5:31 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=14969

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
              Flags|                            |security-

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug network/14969] getaddrinfo() with AI_ADDRCONFIG replaces ::1 with 127.0.0.1
  2012-12-17 17:08 [Bug network/14969] New: getaddrinfo() with AI_ADDRCONFIG replaces ::1 with 127.0.0.1 psimerda at redhat dot com
  2012-12-17 17:09 ` [Bug network/14969] " psimerda at redhat dot com
  2014-06-14  5:31 ` fweimer at redhat dot com
@ 2020-07-16  7:52 ` alex.gronholm at nextday dot fi
  2 siblings, 0 replies; 4+ messages in thread
From: alex.gronholm at nextday dot fi @ 2020-07-16  7:52 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=14969

Alex Grönholm <alex.gronholm at nextday dot fi> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |alex.gronholm at nextday dot fi

--- Comment #2 from Alex Grönholm <alex.gronholm at nextday dot fi> ---
This is what the attached script gives me now (Fedora 32, Glibc 2.31):

getaddrinfo host="None" hints.ai_flags=AI_ADDRCONFIG:
  ::1
  127.0.0.1
getaddrinfo host="localhost" hints.ai_flags=AI_ADDRCONFIG:
  ::1
  127.0.0.1
getaddrinfo host="127.0.0.1" hints.ai_flags=AI_ADDRCONFIG:
  127.0.0.1
getaddrinfo host="localhost4" hints.ai_flags=AI_ADDRCONFIG:
  127.0.0.1
getaddrinfo host="::1" hints.ai_flags=AI_ADDRCONFIG:
  ::1
getaddrinfo host="localhost6" hints.ai_flags=AI_ADDRCONFIG:
  ::1
getaddrinfo host="195.47.235.3" hints.ai_flags=AI_ADDRCONFIG:
  195.47.235.3
getaddrinfo host="2a02:38::1001" hints.ai_flags=AI_ADDRCONFIG:
  2a02:38::1001
getaddrinfo host="info.nix.cz" hints.ai_flags=AI_ADDRCONFIG:
  2a02:38::1001
  195.47.235.3
getaddrinfo host="www.google.com" hints.ai_flags=AI_ADDRCONFIG:
  2a00:1450:400f:809::2004
  172.217.21.132

So the output is fine now.
HOWEVER, if I query with family=AF_INET, I still get two results:
[(<AddressFamily.AF_INET: 2>, <SocketKind.SOCK_STREAM: 1>, 6, '', ('127.0.0.1',
0)),
 (<AddressFamily.AF_INET: 2>, <SocketKind.SOCK_STREAM: 1>, 6, '', ('127.0.0.1',
0))]

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-07-16  7:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-17 17:08 [Bug network/14969] New: getaddrinfo() with AI_ADDRCONFIG replaces ::1 with 127.0.0.1 psimerda at redhat dot com
2012-12-17 17:09 ` [Bug network/14969] " psimerda at redhat dot com
2014-06-14  5:31 ` fweimer at redhat dot com
2020-07-16  7:52 ` alex.gronholm at nextday dot fi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).