Return-Path: Delivered-To: apmail-httpd-dev-archive@httpd.apache.org Received: (qmail 73730 invoked by uid 500); 25 Apr 2002 14:34:49 -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 73717 invoked from network); 25 Apr 2002 14:34:49 -0000 X-Authentication-Warning: rdu88-250-035.nc.rr.com: trawick set sender to trawick@attglobal.net using -f Sender: trawick@rdu88-250-035.nc.rr.com To: dev@httpd.apache.org Subject: [PATCH] get mod_unique_id to work on IPv6-only boxes From: Jeff Trawick Date: 25 Apr 2002 10:30:48 -0400 Message-ID: Lines: 55 User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N In this context, "IPv6-only boxes" means "boxes with an IPv6 address but no IPv4 address corresponding to their hostname". This is an easy change to use the low-order four bytes of the IPv6 address for part of the id when no IPv4 address is available. This should resolve the most problematic aspect for the person who wrote PR 7642. The big picture is probably that mod_unique_id should be reworked to use APR uuid support. That is beyond the scope of what I can do at this time. Index: mod_unique_id.c =================================================================== RCS file: /home/cvs/httpd-2.0/modules/metadata/mod_unique_id.c,v retrieving revision 1.35 diff -u -r1.35 mod_unique_id.c --- mod_unique_id.c 13 Mar 2002 20:47:53 -0000 1.35 +++ mod_unique_id.c 25 Apr 2002 14:23:13 -0000 @@ -213,16 +213,25 @@ return HTTP_INTERNAL_SERVER_ERROR; } - /* XXX theoretically there are boxes out there which want to use - * mod_unique_id but which have no IPv4 address... send in a patch :) - */ - if ((rv = apr_sockaddr_info_get(&sockaddr, str, AF_INET, 0, 0, p)) != APR_SUCCESS) { + if ((rv = apr_sockaddr_info_get(&sockaddr, str, AF_INET, 0, 0, p)) == APR_SUCCESS) { + global_in_addr = sockaddr->sa.sin.sin_addr.s_addr; + } + else { ap_log_error(APLOG_MARK, APLOG_ALERT, rv, main_server, "mod_unique_id: unable to find IPv4 address of \"%s\"", str); +#if APR_HAVE_IPV6 + if ((rv = apr_sockaddr_info_get(&sockaddr, str, AF_INET6, 0, 0, p)) == APR_SUCCESS) { + memcpy(&global_in_addr, + sockaddr->ipaddr_ptr + sockaddr->ipaddr_len - sizeof(global_in_addr), + sizeof(global_in_addr)); + ap_log_error(APLOG_MARK, APLOG_ALERT, rv, main_server, + "mod_unique_id: using low-order bits of IPv6 address " + "as if they were unique"); + } + else +#endif return HTTP_INTERNAL_SERVER_ERROR; } - - global_in_addr = sockaddr->sa.sin.sin_addr.s_addr; apr_sockaddr_ip_get(&ipaddrstr, sockaddr); ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, 0, main_server, -- Jeff Trawick | trawick@attglobal.net Born in Roswell... married an alien...