From owner-freebsd-apache@FreeBSD.ORG Mon Aug 13 19:46:51 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 CF896106566B for ; Mon, 13 Aug 2012 19:46:51 +0000 (UTC) (envelope-from ohauer@FreeBSD.org) Received: from p578be941.dip0.t-ipconnect.de (p578be941.dip0.t-ipconnect.de [87.139.233.65]) by mx1.freebsd.org (Postfix) with ESMTP id 516FA8FC16 for ; Mon, 13 Aug 2012 19:46:51 +0000 (UTC) Received: from [192.168.0.100] (cde1100.uni.vrs [192.168.0.100]) (Authenticated sender: ohauer) by p578be941.dip0.t-ipconnect.de (Postfix) with ESMTPSA id C845E2089A; Mon, 13 Aug 2012 21:46:46 +0200 (CEST) Message-ID: <5029599B.6050601@FreeBSD.org> Date: Mon, 13 Aug 2012 21:46:35 +0200 From: Olli Hauer User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:14.0) Gecko/20120713 Thunderbird/14.0 MIME-Version: 1.0 To: "apache@FreeBSD.org" References: <201208131808.q7DI8Xgb004238@gateway.ipv6.occnc.com> In-Reply-To: <201208131808.q7DI8Xgb004238@gateway.ipv6.occnc.com> X-Enigmail-Version: 1.4.3 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Cc: "Philip M. Gollucci" , 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: "apache@FreeBSD.org" 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 19:46:52 -0000 On 2012-08-13 20:08, Curtis Villamizar wrote: > 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 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 */ + /* 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 */