You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Jeff Trawick <tr...@attglobal.net> on 2002/04/25 16:30:48 UTC

[PATCH] get mod_unique_id to work on IPv6-only boxes

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...

Re: [PATCH] get mod_unique_id to work on IPv6-only boxes

Posted by Jeff Trawick <tr...@attglobal.net>.
Justin Erenkrantz <je...@apache.org> writes:

> On Thu, Apr 25, 2002 at 10:30:48AM -0400, Jeff Trawick wrote:
> > 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.
> 
> Looks good.  If no one wants to maintain it, well it doesn't get
> maintained.  =)  
> 
> Can/should we get this into .36?  -- justin

I need to verify on another machine, after which I'm reasonably
certain that it doesn't regress anybody.  It will prevent a fatal
startup error for some small set of people.  I'll commit after one
last test and am in favor of making it part of 2.0.36.

-- 
Jeff Trawick | trawick@attglobal.net
Born in Roswell... married an alien...

Re: [PATCH] get mod_unique_id to work on IPv6-only boxes

Posted by Justin Erenkrantz <je...@apache.org>.
On Thu, Apr 25, 2002 at 10:30:48AM -0400, Jeff Trawick wrote:
> 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.

Looks good.  If no one wants to maintain it, well it doesn't get
maintained.  =)  

Can/should we get this into .36?  -- justin