From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E1CC8386F006; Wed, 16 Sep 2020 20:57:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E1CC8386F006 From: "dj at redhat dot com" To: glibc-bugs@sourceware.org Subject: [Bug libc/26630] New: getaddrinfo drops ipv6 V4MAPPED addresses from ncsd results Date: Wed, 16 Sep 2020 20:57:31 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: libc X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: dj at redhat dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: glibc-bugs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-bugs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Sep 2020 20:57:32 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D26630 Bug ID: 26630 Summary: getaddrinfo drops ipv6 V4MAPPED addresses from ncsd results Product: glibc Version: unspecified Status: NEW Severity: normal Priority: P2 Component: libc Assignee: unassigned at sourceware dot org Reporter: dj at redhat dot com CC: drepper.fsp at gmail dot com Target Milestone: --- Consider a set of DNS records like this: testv5c IN A 1.2.3.9 testv5c IN AAAA 2001:1234::8393 testv5c IN AAAA ::ffff:2.3.4.5 "getent ahosts testv5c" normally returns: 1.2.3.9 STREAM testv5c 1.2.3.9 DGRAM=20=20 1.2.3.9 RAW=20=20=20=20 ::ffff:2.3.4.5 STREAM=20 ::ffff:2.3.4.5 DGRAM=20=20 ::ffff:2.3.4.5 RAW=20=20=20=20 2001:1234::8393 STREAM=20 2001:1234::8393 DGRAM=20=20 2001:1234::8393 RAW=20=20=20=20 If NSCD is running, it instead returns: 1.2.3.9 STREAM testv5c 1.2.3.9 DGRAM=20=20 1.2.3.9 RAW=20=20=20=20 2001:1234::8393 STREAM=20 2001:1234::8393 DGRAM=20=20 2001:1234::8393 RAW=20=20=20=20 While this seems (arguably) normal, if the second AAAA DNS entry is missing, only the IPv4 records are printed. If the *only* DNS response is a V4MAPPED address (i.e. ::ffff:*), getent will return nothing. The root cause of this is thus: * In sysdeps/posix/getaddrinfo.c around line 691, we are iterating on the l= ist of addresses we got from nscd, and detect that we've gotten at least one va= lid IPv6 address, and set the "got_ipv6" flag[1]. * Around line 1035 we iterate over the list of addresses and discard any "V4MAPPED" addresses if we've seen any IPv6 addresses. The problem is, the IPv6 address we saw - and set the flag for - is the same address we're later discarding. If the test around line 691 adds a conditi= onal on not being a V4-mapped address, the test case seems to work correctly, although the actual fix may be more complicated than that. Testing should include all eight permutations of address family availability (v4, v4mapped, v6) with and without nscd running. [1] Note this flag is also set around line 807, for non-nscd lookups, but d= oes not seem to cause the same problem. Further investigation is warranted her= e. Originally reported at https://bugzilla.redhat.com/show_bug.cgi?id=3D901532 --=20 You are receiving this mail because: You are on the CC list for the bug.=