[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: broken IPv6 code



>>>>> "Arkadiusz" == Arkadiusz Miskiewicz <misiek@pld.ORG.PL> writes:

    Arkadiusz> On/Dnia Mon, Jan 08, 2001 at 09:26:09AM +1100, Craig
    Arkadiusz> Small wrote/napisał(a)
    >> > > > 1. getaddrinfo should not return IPv4 addresses if an
    >> IPv6 address exist, > > > since using the IPv6 address implies
    >> usage of the IPv4 address.
    Arkadiusz> this idea is sick :) getaddrinfo() should return all
    Arkadiusz> possible addresses and then you can filter out ipv6
    Arkadiusz> addresses if you want. Thing about situations where on
    Arkadiusz> ipv4-only kernel you use getaddrinfo(host,...) where
    Arkadiusz> host has A and AAAA records in DNS. You won't be able
    Arkadiusz> to connect to such host if your getaddrinfo() will
    Arkadiusz> return only v6 address.

How is the application meant to know if it is has to filter out
IPv4 addresses though?

This is OS specific.

Why should AF independent applications have to treat IPv4 as a special
case? IPv4 and IPv6 are just two possible protocols that exist,
others exist as well. 

Worse case, if an application had to treat every protocol as a special
case, you lose all advantage of the sockets layer altogether (which is
meant help programmers write protocol independent software).

I think allowing a an application to filter out certain addresses is a
good thing for special situations (can't think of any examples of
hand).  It should not be a requirement though that applications filter
out addresses (after second guessing the operating system to see if
this is even required or not) just to get the basic bind operation to
work.

Besides, you may have misunderstood my suggestion[1]: getaddrinfo
should return either IPv4 or IPv6 addresses, not both. So, for your
example, it would not break, as interfaces (eg IPv6 not compiled in
the kernel) which do not support IPv6, so the IPv4 address will be
returned instead.

This is because there is no point to binding to the IPv4 address if an
IPv6 address exists[2], you only need to bind to the IPv6 address, at
least on Linux. So why not just forget about the IPv4 address
altogether, and have the OS claim that only the IPv6 socket exists?

Note:

[1] I am not sure of the getaddrinfo API, but in my code the first
parameter is set to NULL. I assume this gets all the addresses of the
configured interfaces on the local machine, and doesn't need to do any
DNS lookups.

[2] I assume if a program is smart enough to use getaddrinfo, it will
also be IPv6 compatable. Is this a safe assumption?
-- 
Brian May <bam@debian.org>



Reply to: