Return-Path: Delivered-To: apmail-httpd-dev-archive@httpd.apache.org Received: (qmail 52551 invoked by uid 500); 25 Aug 2003 10:19:28 -0000 Mailing-List: contact dev-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list dev@httpd.apache.org Received: (qmail 52509 invoked from network); 25 Aug 2003 10:19:27 -0000 Date: Mon, 25 Aug 2003 09:27:03 +0100 From: Joe Orton To: dev@httpd.apache.org Subject: Re: cvs commit: httpd-2.0/server listen.c Message-ID: <20030825082703.GA30636@redhat.com> Mail-Followup-To: dev@httpd.apache.org References: <20030824224336.3893.qmail@minotaur.apache.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="NzB8fVQJ5HfG6fxh" Content-Disposition: inline In-Reply-To: <20030824224336.3893.qmail@minotaur.apache.org> User-Agent: Mutt/1.4.1i X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N --NzB8fVQJ5HfG6fxh Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sun, Aug 24, 2003 at 10:43:36PM -0000, jerenkrantz@apache.org wrote: ... > +#if APR_HAVE_IPV6 > + int v6only_setting; > + /* If we are trying to bind to 0.0.0.0 and the previous listener > + * was :: on the same port and in turn that socket does not have > + * the IPV6_V6ONLY flag set; we must skip the current attempt to > + * listen (which would generate an error). IPv4 will be handled > + * on the established IPv6 socket. > + */ > + if (previous != NULL && > + lr->bind_addr->family == APR_INET && > + *((in_addr_t *)lr->bind_addr->ipaddr_ptr) == INADDR_ANY && > + lr->bind_addr->port == previous->bind_addr->port && > + previous->bind_addr->family == APR_INET6 && > + IN6_IS_ADDR_UNSPECIFIED( > + (struct in6_addr*)(previous->bind_addr->ipaddr_ptr)) && This doesn't compile on some older Unixes since in_addr_t is a recent invention; the casts aren't really necessary anyway. Also the below conditional looks dubious - previous->bind_addr should be lr->bind_addr, and the lr->next family is never checked? Attached a patch which looks logically right and fixes the compile error, not tested though - can you test it? > else { > +#if APR_HAVE_IPV6 > + /* If we tried to bind to ::, and the next listener is > + * on 0.0.0.0 with the same port, don't give a fatal > + * error. The user will still get a warning from make_sock > + * though. > + */ > + if (lr->next != NULL && lr->bind_addr->family == APR_INET6 && > + IN6_IS_ADDR_UNSPECIFIED( > + (struct in6_addr*)(previous->bind_addr->ipaddr_ptr)) && > + lr->bind_addr->port == lr->next->bind_addr->port && > + *((in_addr_t *)lr->next->bind_addr->ipaddr_ptr) > + == INADDR_ANY) { --NzB8fVQJ5HfG6fxh Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="ap2_listen.diff" Index: listen.c =================================================================== RCS file: /home/cvs/httpd-2.0/server/listen.c,v retrieving revision 1.90 diff -u -r1.90 listen.c --- listen.c 24 Aug 2003 22:43:36 -0000 1.90 +++ listen.c 25 Aug 2003 08:14:39 -0000 @@ -355,11 +355,11 @@ */ if (previous != NULL && lr->bind_addr->family == APR_INET && - *((in_addr_t *)lr->bind_addr->ipaddr_ptr) == INADDR_ANY && + lr->bind_addr->sa.sin.sin_addr.s_addr == INADDR_ANY && lr->bind_addr->port == previous->bind_addr->port && previous->bind_addr->family == APR_INET6 && IN6_IS_ADDR_UNSPECIFIED( - (struct in6_addr*)(previous->bind_addr->ipaddr_ptr)) && + previous->bind_addr->sa.sin6.sin6_addr.s6_addr) && apr_socket_opt_get(previous->sd, APR_IPV6_V6ONLY, &v6only_setting) == APR_SUCCESS && v6only_setting == 0) { @@ -382,10 +382,10 @@ */ if (lr->next != NULL && lr->bind_addr->family == APR_INET6 && IN6_IS_ADDR_UNSPECIFIED( - (struct in6_addr*)(previous->bind_addr->ipaddr_ptr)) && + lr->bind_addr->sa.sin6.sin6_addr.s6_addr) && lr->bind_addr->port == lr->next->bind_addr->port && - *((in_addr_t *)lr->next->bind_addr->ipaddr_ptr) - == INADDR_ANY) { + lr->next->bind_addr->family == APR_INET && + lr->next->bind_addr->sa.sin.sin_addr.s_addr == INADDR_ANY) { /* Remove the current listener from the list */ if (previous) { --NzB8fVQJ5HfG6fxh--