Date: Mon, 13 Aug 2012 21:46:35 +0200 From: Olli Hauer <ohauer@FreeBSD.org> To: "apache@FreeBSD.org" <apache@freebsd.org> Cc: "Philip M. Gollucci" <pgollucci@p6m7g8.com>, curtis@occnc.com Subject: Re: patch to apache for IPv6 only httpd Message-ID: <5029599B.6050601@FreeBSD.org> In-Reply-To: <201208131808.q7DI8Xgb004238@gateway.ipv6.occnc.com> References: <201208131808.q7DI8Xgb004238@gateway.ipv6.occnc.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2012-08-13 20:08, Curtis Villamizar wrote: > In message <CACM2dAaQLa38rLvbOfXJb6wFzrV_E0DUL6cxT9dher6G_6v4bA@mail.gmail.com> > "Philip M. Gollucci" writes: > >> What happens if you try to bind to an ip address the machine doesn't >> have whether v4 or v6 with this patch ? > > > In that case there is no change to the behavior although "assert" may > not be the best diagnostic, the same thing happens with or without the > patch if the address is not present. > > The code here insures that the server does not start unless it has at > least one valid address. The hostname is provided as NULL and a > lookup is done. The old code looks for any valid IPv4 address. The > code breaks if there are no IPv4 addresses, there are only valid IPv6 > addresses. The patch repeats the check with AF_UNSPEC (accept > anything) and this would pick up a valid IPv6 address and avoid the > assert. If there were no valid addresses, then prior code that > produced a list of addresses is broken and this code does the same as > before the patch - it asserts. > > apr_sockaddr_info_get is in srclib/apr/network_io/unix/sockaddr.c > where it does some checking, calls call_resolver if getaddrinfo > exists, otherwise gethostbyname with the hostname. In call_resolver > getaddrinfo (see man page) is called which returns a struct addrinfo > which has a list of addresses. If an address string is provided, > there will be one address in the list. call_resolver will only return > an AF_INET or AF_INET6 address (it creates a linked list in the > argument p, using calloc to allocate entries). > > The assumption in this code is that you can't get here without a valid > address, but then in testing that assumption, only a valid IPv4 > address is accepted. > > After this test, the result does not appear to be used (otherwise DS > machines wouldn't work). The addresses from the config file are used > in alloc_listener which calls apr_sockaddr_info_get with APR_UNSPEC > and a port number. The addresses from the config file may have > absolutely nothing to do with the list of addresses returned by > gethostbyname in the prior check. > > Curtis I think we can include the diff from Curtis as general patch. The test for an IPv6 address (APR_INE6) will be done only if the first test on APR_INET fails. @Phillip any objection? @Cutis: the resulting patch with APR_INET6 instead APR_UNSPEC --- ./server/config.c.orig 2012-08-13 21:15:02.000000000 +0200 +++ ./server/config.c 2012-08-13 21:22:15.000000000 +0200 @@ -1979,6 +1979,11 @@ /* NOT virtual host; don't match any real network interface */ rv = apr_sockaddr_info_get(&s->addrs->host_addr, NULL, APR_INET, 0, 0, p); + /* Support for IPv6 only, reported by Curtis Villamizar <curtis@occnc.com> */ + /* http://lists.freebsd.org/pipermail/freebsd-apache/2012-August/002836.html */ + if (rv != APR_SUCCESS) + rv = apr_sockaddr_info_get(&s->addrs->host_addr, + NULL, APR_INET6, 0, 0, p); ap_assert(rv == APR_SUCCESS); /* otherwise: bug or no storage */ s->addrs->host_port = 0; /* matches any port */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5029599B.6050601>