This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug network/12377] getaddrinfo() should disregard link-local IPv6 addresses for AI_ADDRCONFIG purposes


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

--- Comment #15 from Tore Anderson <tore at fud dot no> 2012-07-31 12:19:37 UTC ---
(In reply to comment #13)

> This option is probably meant to guess whether we can sendto() data to this
> address (for connect() it is not necessary as connect() immediately returns
> failure for nonroutable addresses). But I can't think of *any* reason
> to use this hack when it's so easy to ask the system if the address is
> actually routable.

I am assuming that by Âthis option you mean AI_ADDRCONFIG?

If so, I disagree. The way I see it, the primary reason for using AI_ADDRCONFIG
is to avoid making lookups from which any results cannot be used. In other
words, if there is no IPv4 connectivity, avoid making "IN A" lookups. If there
is no IPv6 connectivity, avoid making "IN AAAA" lookups. Making useless lookups
consume bandwidth/battery, and in the case of broken DNS server implementations
that choke on the useless lookup type (e.g. IPv4-only home gateways that don't
respond to IN AAAA lookups), they may even cause getaddrinfo() stall for a long
time, waiting for the IN AAAA lookup to time out, before returning to the
caller.

> $ ip route get 2001:db8:1:1::1
> $
> 
> You see, this address is *not* routable. But even if you try to fool it:
> 
> # ip route add default via fe80::23:45ff:fe67:8901 dev eth0
> 
> $ ip route get 2001:db8:1:1::1
> 2001:db8:1:1::1 from :: via fe80::23:45ff:fe67:8901 dev eth0  src
> fe80::12:34ff:fe56:7890  metric 0
>     cache
> 
> You can still easily detect the problem as the dst address is global and src
> address is link-local. So there's actually no guessing needed when the
> information is right at your hand.

I don't think AI_ADDRCONFIG makes much sense when passing literal IP addresses
to getaddrinfo(). It could probably be ignored in that case, I think. However,
when passing hostnames to getaddrinfo() you can't do a routing test before
doing the lookup(s), because the IP addresses aren't known at that point.

That said, it is possible to connect to a global address from a link-local
source address in one corner case. For example, say that your default router in
the example above (fe80::23:45ff:fe67:8901) has 2001:db8:1:1::1 configured on
its loopback interface. In that case, you could communicate with
2001:db8:1:1::1 from fe80::12:34ff:fe56:7890 without any problems.

Tore

-- 
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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]