From owner-freebsd-apache@FreeBSD.ORG Mon Aug 13 18:08:58 2012 Return-Path: Delivered-To: apache@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CC1A9106566C for ; Mon, 13 Aug 2012 18:08:58 +0000 (UTC) (envelope-from curtis@occnc.com) Received: from gateway.ipv6.occnc.com (gateway.ipv6.occnc.com [IPv6:2001:470:1f07:1545::1:132]) by mx1.freebsd.org (Postfix) with ESMTP id 630E58FC14 for ; Mon, 13 Aug 2012 18:08:58 +0000 (UTC) Received: from newharbor.ipv6.occnc.com (newharbor.ipv6.occnc.com [IPv6:2001:470:1f07:1545::1:320]) (authenticated bits=0) by gateway.ipv6.occnc.com (8.14.5/8.14.5) with ESMTP id q7DI8Xgb004238; Mon, 13 Aug 2012 14:08:33 -0400 (EDT) (envelope-from curtis@occnc.com) Message-Id: <201208131808.q7DI8Xgb004238@gateway.ipv6.occnc.com> To: "Philip M. Gollucci" From: Curtis Villamizar In-reply-to: Your message of "Mon, 13 Aug 2012 14:33:00 -0000." Date: Mon, 13 Aug 2012 14:08:33 -0400 Cc: "apache@FreeBSD.org" , curtis@occnc.com Subject: Re: patch to apache for IPv6 only httpd X-BeenThere: freebsd-apache@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: curtis@occnc.com List-Id: Support of apache-related ports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Aug 2012 18:08:59 -0000 In message "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 > On Sun, Aug 12, 2012 at 11:53 PM, Curtis Villamizar wrote: > > > > > In message <50282D58.5070605@FreeBSD.org> > > Olli Hauer writes: > > > > > On 2012-08-11 23:22, Curtis Villamizar wrote: > > > > FYI- > > > > > > > > This very simple patch prevents an assert when httpd is run on a > > > > server that has no IPv4 address. An example is a BSD jail running > > > > with only an IPv6 address on the interface (no loopback so no > > > > 127.0.0.1 address to bind to). > > > > > > > > Copy the patch below into the files directory as > > > > /usr/ports/www/apache22/files/patch-server__config.c > > > > > > > > The port maintainer is on the Cc. No bug has been reported. > > > > > > > > BTW- I noticed this a long time ago. I don't remember if I reported > > > > it or forgot to. Appologies if this is a duplicate. It is not in the > > > > httpd-2.2.22.tar.bz2 tarball, in the distinfo dated 23 July 2012. > > > > > > > > Curtis > > > > > > > > > > > > --- ./server/config.c.orig 2010-10-07 09:56:54.000000000 -0700 > > > > +++ ./server/config.c 2011-09-26 21:20:35.000000000 -0700 > > > > @@ -1979,6 +1979,9 @@ > > > > /* 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); > > > > + if (rv != APR_SUCCESS) > > > > + rv = apr_sockaddr_info_get(&s->addrs->host_addr, > > > > + NULL, APR_UNSPEC, 0, 0, p); > > > > ap_assert(rv == APR_SUCCESS); /* otherwise: bug or no storage */ > > > > > > > > s->addrs->host_port = 0; /* matches any port */ > > > > > > Hi Curtis, > > > > > > Is this patch also relevant if apache22 was build with > > > -DWITH_IPV6_V6ONLY ? > > > > > > -- > > > olli > > > > > > No. Apache was not built with -DWITH_IPV6_V6ONLY. It is apache built > > with dual stack support though I don't think the code is any different > > if built with WITH_IPV6_V6ONLY. Nothing here is conditionally > > compiled. I also checked the .h where APR_INET is defined (in > > srclib/apr/include/apr_network_io.h). It is unconditionally defined > > to AF_INET. > > > > The code compiles but the server fails to run, giving an assert when > > starting up. Its a simple patch. APR_INET6 could be used instead of > > APR_UNSPEC in the patch. > > > > Curtis