OpenWrt busybox ipv6 problems

Denys Vlasenko vda.linux at googlemail.com
Wed Nov 14 03:00:42 UTC 2007


On Monday 12 November 2007 04:50, Russell Senior wrote:
> I am subscribed to too many mailing lists already.  I just want to
> report a bug.  Can you please forward this to the list and CC me on
> replies?  Thanks, I appreciate your understanding.

It's actually pretty simple:

libbb/xconnect.c

static len_and_sockaddr* str2sockaddr(
                const char *host, int port,
USE_FEATURE_IPV6(sa_family_t af,)
                int ai_flags)
{
        int rc;
        len_and_sockaddr *r = NULL;
        struct addrinfo *result = NULL;
        const char *org_host = host; /* only for error msg */
        const char *cp;
        struct addrinfo hint;
...
        rc = getaddrinfo(host, NULL, &hint, &result);
        if (rc || !result) {
                bb_error_msg("bad address '%s'", org_host);
                if (ai_flags & DIE_ON_ERROR)
                        xfunc_die();
                goto ret;
        }
        r = xmalloc(offsetof(len_and_sockaddr, sa) + result->ai_addrlen);
        r->len = result->ai_addrlen;
        memcpy(&r->sa, result->ai_addr, result->ai_addrlen);
        set_nport(r, htons(port));
 ret:
        freeaddrinfo(result);
        return r;
}

We just use the first result from getaddrinfo(). We can walk down
result->ai_next and examine alternative addresses. From practical
point of view, it's of course possible to check whether there is
a IPv4 address and return that, and otherwise return first one.

However, it's arbitrary. Who says that IPv4 is "better" than IPv6?
On the same grounds I may complain when a host have two different
IP addresses (and getaddrinfo() returns both), but it so happens that
first one turns out to be blocked whereas second works.
But programs don't know that and they are using first one, and failing.

What shall I do?
--
vda



More information about the busybox mailing list