Bug 16826 - getaddrinfo() doesn't get scope ID for IPv6-only look-ups
Summary: getaddrinfo() doesn't get scope ID for IPv6-only look-ups
Status: NEW
Alias: None
Product: glibc
Classification: Unclassified
Component: network (show other bugs)
Version: 2.17
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on: 14413
Blocks: 14505
  Show dependency treegraph
 
Reported: 2014-04-10 00:25 UTC by Craig McQueen
Modified: 2023-03-22 03:17 UTC (History)
9 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Craig McQueen 2014-04-10 00:25:56 UTC
I'm trying to follow up on Ubuntu Launchpad bug #369008, in which mDNS IPv6 look-ups don't get the scope ID. There is a patch for nss-mdns which makes it work by implementing _nss_gethostbyname4_r(), which is the only way to pass through the IPv6 scope ID. However, while it works for lookups with family AF_UNSPEC, it doesn't work for family AF_INET6.

It turns out that getaddrinfo() is calling _nss_gethostbyname4_r() only for lookups with family AF_UNSPEC. But for family AF_INET6, it is calling _nss_gethostbyname2_r() instead. It really should always call _nss_gethostbyname4_r() for any IPv6 look-ups, in order to get the IPv6 scope ID.

It used to work, however, I've traced the problem to glibc git commit 8479f23aa1.
http://repo.or.cz/w/glibc.git/commit/8479f23aa1d5e5477a37f46823856bdafaedfa46

In that commit, it was changed to only use _nss_gethostbyname4_r() for AF_UNSPEC, and not AF_INET6. That breaks IPv6 scope ID retrieval. Can we revert that change?
Comment 1 Craig McQueen 2014-04-10 00:50:53 UTC
By the way, Ubuntu Launchpad bug #369008 "mdns lookups fail over ipv6" affects look-ups of Zeroconf ".local" names through mDNS. Zeroconf is "zero configuration networking" and that's the application in which IPv6 scope ID is most important--where you want to plug things together and have it "just work". On a network without assigned IPv6 addresses, IPv6 Unique Local Addresses (ULA) are used, and it's necessary to have scope ID look-ups working to be able to communicate to the IPv6 ULA.

With nss-mdns working (patched from the above Ubuntu Launchpad bug), it's possible to do:

telnet mycomputername.local

(it uses a family AF_UNSPEC look-up, which works)

But due to this bug, on a network without assigned IPv6 addresses (ULA only) it's not possible to do:
telnet -6 mycomputername.local
ping6 mycomputername.local

(it uses a family AF_INET6 look-up, which doesn't work with IPv6 ULA because scope ID is missing)
Comment 2 Matthias-Christian Ott 2014-12-29 01:29:20 UTC
Are there any plans to address this issue? Is there any information missing that blocks fixing this (5 year old) issue?
Comment 3 Craig McQueen 2015-11-30 05:01:08 UTC
Any updates on this?
Comment 4 Carlos O'Donell 2015-12-01 16:14:15 UTC
(In reply to Craig McQueen from comment #3)
> Any updates on this?

For most core library issues it isn't that information is missing, but that a motivated developer needs to step up to help with the work. There is no one working on this issue that I know of (note the issue is not yet assigned).

Someone would have to look at bug 14505 and reconcile why the change was made. Simply reverting the change is insufficient since it would regress bug 14505. After an analysis of both bugs is made a subsequent fix needs to be decided and posted to libc-alpha following the contribution checklist:
https://sourceware.org/glibc/wiki/Contribution%20checklist
Comment 5 Mike Frysinger 2016-11-26 21:11:55 UTC
is the nss API documented anywhere ?  do we have a callback that'd provide IPv6-only resolution ?  or do we need to add one ?
Comment 6 Florian Weimer 2016-11-27 11:31:33 UTC
(In reply to Mike Frysinger from comment #5)
> is the nss API documented anywhere ?

There is a section in the manual.

> do we have a callback that'd provide
> IPv6-only resolution ?  or do we need to add one ?

struct gaih_addrtuple (which is used by the version 4 name lookup API) contains a scope ID.  I have not checked if it is properly propagated up to the application.  nss_files does not used it; we could fix that as a first step.
Comment 7 Michał Górny 2016-11-27 12:11:16 UTC
(In reply to Mike Frysinger from comment #5)
> do we have a callback that'd provide IPv6-only resolution ?

The API <4 can do IPv6-only but it doesn't support returning scope IDs. The API 4 supports that but doesn't support IPv6-only resolution.

> or do we need to add one ?

Bug #14413 requested that.