apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lucian Adrian Grijincu" <lucian.griji...@gmail.com>
Subject Re: [Vote] Release APR 1.2.9/0.9.14 and apr-iconv 1.2.0
Date Wed, 06 Jun 2007 21:24:07 GMT
On 6/6/07, Lucian Adrian Grijincu <lucian.grijincu@gmail.com> wrote:
> On 6/6/07, Davi Arnaut <davi@haxent.com.br> wrote:
> > Joe Orton wrote:
> > > On Wed, Jun 06, 2007 at 06:06:44PM +0300, Lucian Adrian Grijincu wrote:
> > >> $>./test ::1 ssh
> > >> ./test: getaddrinfo: Address family for hostname not supported
> > >>
> > >> $> telnet ::1 ssh
> > >> Trying ::1...
> > >> Connected to ::1.
> > >
> > > That makes little sense.  I presume you do in fact have the "ipv6"
> > > module loaded (lsmod | grep ipv6)?  What version of glibc is this?  Does
> > > it make any difference if you set ai_flags to 0 in your test program?
> > >
> >
>
>
> u@h:~$ lsmod | grep ipv6
> ipv6                  268960  12
>
> I guess 2.5 :)
> Ubuntu reports it as 2.5-0ubuntu14
>
> u@h:~$ ls -al /lib/libc.so.6
> lrwxrwxrwx 1 root root 11 2007-05-18 01:12 /lib/libc.so.6 -> libc-2.5.so
>
> I think that telnet could see that "::1" is the IPv6 loopback string
> and replace it with "127.0.0.1" if it wanted. Haven' looked at the
> code, just why this behaviour may be possible.
>
>
>
> > In case anyone wanna try.. test attached.
>
> This is the output:
> getaddrinfo AF_UNSPEC/SOCK_STREAM/AI_ADDRCONFIG failed
> so, yes:     hints.ai_flags = AI_ADDRCONFIG; makes getaddrinfo fail.
>

commenting out AI_ADDRCONFIG in the malfunctioning code makes it pass all tests.

#ifdef HAVE_GAI_ADDRCONFIG
    if (family == APR_UNSPEC) {
        /* By default, only look up addresses using address types for
         * which a local interface is configured, i.e. no IPv6 if no
         * IPv6 interfaces configured. */
	
        //hints.ai_flags = AI_ADDRCONFIG;
    }
#endif

I hear that there are real performance reasons to maintain
AI_ADDRCONFIG for AF_UNSPEC:
http://www.ops.ietf.org/lists/v6ops/v6ops.2003/msg01377.html

I first though we could do a strcmp to check for "127.0.0.1" or "::1",
but it's not going to work, because users may have altered the hosts
file to set a specific hostname to loopback and this code should be
able to get things like "localhost" as a valid parameter.

I see three getaways:
1. kill AI_ADDRCONFIG for APR_UNSPEC
2. document "::1" and any other link-local addresses and hostnames as
invalid if APR_UNSPEC is used.
3. retry without AI_ADDRCONFIG if first try fails

1. BAD: this is the only place where AI_ADDRCONFIG is used and not
using it would mean a performance regression for applications that do
not care about loopback.
2. UGLY: APR should work arround platform specific issues and present
a simple interface. Having the user check for link-localness
beforehand is ... ugly. :)
3. GOOD: We already retry for some other errors and retrying would
only harm performance-wise only in case of a:
  a) link-local address or hostname. This should be resolved locally,
which means the drawback is little
  b) failing external lookup. This can mean we'll take longer to say:
"I can't find the hostname you specified", or (not very probable)
manage to find it at the second try


I've attached a patch against the tarball that does what's needed for 3.

Rebuilt from scratch + patch:
   finally, all test pass now :)


--
Lucian Adrian Grijincu

Mime
View raw message