Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 09 Jan 2013 14:14:18 +0100
From:      Michiel Boland <michiel@boland.org>
To:        Hiroki Sato <hrs@freebsd.org>
Cc:        stable@freebsd.org, uqs@freebsd.org
Subject:   Re: sendmail vs ipv6 broken after upgrade to 9.1
Message-ID:  <50ED6D2A.5080908@boland.org>
In-Reply-To: <20130109.073354.730245417155474512.hrs@allbsd.org>
References:  <20130108151837.GF35868@acme.spoerlein.net> <50EC5922.5030600@boland.org> <20130108184051.GI35868@acme.spoerlein.net> <20130109.073354.730245417155474512.hrs@allbsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 01/08/2013 23:33, Hiroki Sato wrote:
> Ulrich Spörlein <uqs@freebsd.org> wrote
>    in <20130108184051.GI35868@acme.spoerlein.net>:
>
> uq> After setting this, it now looks like this:
> uq> root@acme: ~# ip6addrctl
> uq> Prefix                          Prec Label      Use
> uq> ::1/128                           50     0        0
> uq> ::/0                              40     1        0
> uq> 2002::/16                         30     2        0
> uq> ::/96                             20     3        0
> uq> ::ffff:0.0.0.0/96                 10     4        0
> uq>
> uq> And even sendmail is happily finding the sockets to bind to. Thanks for the hint!
>
>   I think this just hides the problem.  If gshapiro@'s explanation is
>   correct, no ::ffff:0.0.0.0/96 address should be returned if the name
>   resolution works fine...
>
> -- Hiroki
>

getipnodebyname(xx, AF_INET6, AI_DEFAULT|AI_ALL) does this:-

If a host has both IPv6 and IPv4 addresses, both are returned.
The IPv4 address is presented as a mapped address.
The order in which the addresses are returns depends on the
address selection policy (_hpreorder in lib/libc/net/name6.c)

#include <netinet/in.h>
#include <netdb.h>
#include <resolv.h>
#include <stdio.h>

static void resolve(const char *);

int main(int argc, char *argv[])
{
         int i;

         for (i = 1; i < argc; i++) {
                 resolve(argv[i]);
         }
         return 0;
}

static void resolve(const char *hostname)
{
         struct hostent *h;
         char **a;
         int i;
         int e = 0;
         h = getipnodebyname(hostname, AF_INET6, AI_DEFAULT|AI_ALL, &e);
         if (!h) {
                 return;
         }
         printf("h_name: %s\n", h->h_name);
         for (a = h->h_aliases; *a; a++) {
                 printf("  alias: %s\n", *a);
         }
         printf("h_addrtype: %d\n", h->h_addrtype);
         printf("h_length: %d\n", h->h_length);
         for (a = h->h_addr_list; *a; a++) {
         printf("h_length: %d\n", h->h_length);
                 printf("  address: 0x");
                 for (i = 0; i < h->h_length; i++) {
                         printf("%02x", (unsigned char)(*a)[i]);
                 }
                 printf("\n");
         }
}

prefer_ipv4:

$ ./a.out youtube.com
h_name: youtube.com
h_addrtype: 28
h_length: 16
h_length: 16
   address: 0x00000000000000000000ffffadc241be
h_length: 16
   address: 0x00000000000000000000ffffadc2415b
h_length: 16
   address: 0x00000000000000000000ffffadc2415d
h_length: 16
   address: 0x00000000000000000000ffffadc24188
h_length: 16
   address: 0x2a00145040130c00000000000000005b

prefer_ipv6:
$ ./a.out youtube.com
h_name: youtube.com
h_addrtype: 28
h_length: 16
h_length: 16
   address: 0x2a00145040130c00000000000000005b
h_length: 16
   address: 0x00000000000000000000ffffadc2415b
h_length: 16
   address: 0x00000000000000000000ffffadc2415d
h_length: 16
   address: 0x00000000000000000000ffffadc24188
h_length: 16
   address: 0x00000000000000000000ffffadc241be





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?50ED6D2A.5080908>